mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-10 15:50:37 +08:00
Update get_pr_labels method to support label updates and prevent unnecessary label republishing
This commit is contained in:
@ -118,11 +118,15 @@ class PRDescription:
|
||||
if get_settings().config.publish_output:
|
||||
# publish labels
|
||||
if get_settings().pr_description.publish_labels and self.git_provider.is_supported("get_labels"):
|
||||
original_labels = self.git_provider.get_pr_labels()
|
||||
original_labels = self.git_provider.get_pr_labels(update=True)
|
||||
get_logger().debug(f"original labels", artifact=original_labels)
|
||||
user_labels = get_user_labels(original_labels)
|
||||
get_logger().debug(f"published labels:\n{pr_labels + user_labels}")
|
||||
self.git_provider.publish_labels(pr_labels + user_labels)
|
||||
new_labels = pr_labels + user_labels
|
||||
get_logger().debug(f"published labels", artifact=new_labels)
|
||||
if new_labels != original_labels:
|
||||
self.git_provider.publish_labels(new_labels)
|
||||
else:
|
||||
get_logger().debug(f"Labels are the same, not updating")
|
||||
|
||||
# publish description
|
||||
if get_settings().pr_description.publish_description_as_comment:
|
||||
|
@ -369,17 +369,20 @@ class PRReviewer:
|
||||
if security_concerns_bool:
|
||||
review_labels.append('Possible security concern')
|
||||
|
||||
current_labels = self.git_provider.get_pr_labels()
|
||||
current_labels = self.git_provider.get_pr_labels(update=True)
|
||||
get_logger().debug(f"Current labels:\n{current_labels}")
|
||||
if current_labels:
|
||||
current_labels_filtered = [label for label in current_labels if
|
||||
not label.lower().startswith('review effort [1-5]:') and not label.lower().startswith(
|
||||
'possible security concern')]
|
||||
else:
|
||||
current_labels_filtered = []
|
||||
if current_labels or review_labels:
|
||||
get_logger().debug(f"Current labels:\n{current_labels}")
|
||||
new_labels = review_labels + current_labels_filtered
|
||||
if (current_labels or review_labels) and new_labels != current_labels:
|
||||
get_logger().info(f"Setting review labels:\n{review_labels + current_labels_filtered}")
|
||||
self.git_provider.publish_labels(review_labels + current_labels_filtered)
|
||||
self.git_provider.publish_labels(new_labels)
|
||||
else:
|
||||
get_logger().info(f"Review labels are already set:\n{review_labels + current_labels_filtered}")
|
||||
except Exception as e:
|
||||
get_logger().error(f"Failed to set review labels, error: {e}")
|
||||
|
||||
|
Reference in New Issue
Block a user