From a2eb2e4dac9de1ba9e60453cb392ccd9a3841778 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Wed, 19 Jul 2023 20:31:10 +0300 Subject: [PATCH] Update pr_agent/git_providers/github_provider.py --- pr_agent/git_providers/github_provider.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pr_agent/git_providers/github_provider.py b/pr_agent/git_providers/github_provider.py index 2f19487b..7c6257a1 100644 --- a/pr_agent/git_providers/github_provider.py +++ b/pr_agent/git_providers/github_provider.py @@ -309,15 +309,11 @@ class GithubProvider(GitProvider): def publish_labels(self, pr_types): try: - if type(pr_types) is not list: - pr_types = [pr_types] - colors = ["1d76db", "e99695", "c5def5", "bfdadc", "bfd4f2", "d4c5f9", "d1bcf9"] - labels = ["Bug fix", "Tests", "Bug fix with tests", "Refactoring", "Enhancement", "Documentation", "Other"] + label_color_map = {"Bug fix": "1d76db", "Tests": "e99695", "Bug fix with tests": "c5def5", "Refactoring": "bfdadc", "Enhancement": "bfd4f2", "Documentation": "d4c5f9", "Other": "d1bcf9"} post_parameters = [] for p in pr_types: - ind = 0 - if p in labels: - ind = labels.index(p) + color = label_color_map.get(p, "d1bcf9") # default to "Other" color + post_parameters.append({"name": p, "color": color}) post_parameters.append({"name": p, "color": colors[ind]}) headers, data = self.pr._requester.requestJsonAndCheck( "PUT", f"{self.pr.issue_url}/labels", input=post_parameters