support git providers with no label support

This commit is contained in:
Hussam.lawen
2023-11-06 14:11:49 +02:00
parent e96b03da57
commit db37ee819a
2 changed files with 12 additions and 5 deletions

View File

@ -228,7 +228,7 @@ class PRDescription:
# Iterate over the dictionary items and append the key and value to 'markdown_text' in a markdown format
markdown_text = ""
# Don't display 'PR Labels'
if 'PR Labels' in self.data:
if 'PR Labels' in self.data and self.git_provider.is_supported("get_labels"):
self.data.pop('PR Labels')
if not get_settings().pr_description.enable_pr_type:
self.data.pop('PR Type')

View File

@ -82,11 +82,18 @@ class PRGenerateLabels:
if get_settings().config.publish_output:
get_logger().info(f"Pushing labels {self.pr_id}")
current_labels = self.git_provider.get_labels()
if current_labels is None:
current_labels = []
pr_labels = pr_labels + current_labels
if self.git_provider.is_supported("get_labels"):
current_labels = self.git_provider.get_labels()
if current_labels is None:
current_labels = []
self.git_provider.publish_labels(pr_labels + current_labels)
self.git_provider.publish_labels(pr_labels)
elif pr_labels:
value = ', '.join(v for v in pr_labels)
pr_labels_text = f"## PR Labels:\n{value}\n"
self.git_provider.publish_comment(pr_labels_text, is_temporary=False)
self.git_provider.remove_initial_comment()
except Exception as e:
get_logger().error(f"Error generating PR labels {self.pr_id}: {e}")