Update pr_agent/git_providers/github_provider.py

This commit is contained in:
mrT23
2023-07-19 20:31:10 +03:00
committed by GitHub
parent d89792d379
commit a2eb2e4dac

View File

@ -309,15 +309,11 @@ class GithubProvider(GitProvider):
def publish_labels(self, pr_types): def publish_labels(self, pr_types):
try: try:
if type(pr_types) is not list: label_color_map = {"Bug fix": "1d76db", "Tests": "e99695", "Bug fix with tests": "c5def5", "Refactoring": "bfdadc", "Enhancement": "bfd4f2", "Documentation": "d4c5f9", "Other": "d1bcf9"}
pr_types = [pr_types]
colors = ["1d76db", "e99695", "c5def5", "bfdadc", "bfd4f2", "d4c5f9", "d1bcf9"]
labels = ["Bug fix", "Tests", "Bug fix with tests", "Refactoring", "Enhancement", "Documentation", "Other"]
post_parameters = [] post_parameters = []
for p in pr_types: for p in pr_types:
ind = 0 color = label_color_map.get(p, "d1bcf9") # default to "Other" color
if p in labels: post_parameters.append({"name": p, "color": color})
ind = labels.index(p)
post_parameters.append({"name": p, "color": colors[ind]}) post_parameters.append({"name": p, "color": colors[ind]})
headers, data = self.pr._requester.requestJsonAndCheck( headers, data = self.pr._requester.requestJsonAndCheck(
"PUT", f"{self.pr.issue_url}/labels", input=post_parameters "PUT", f"{self.pr.issue_url}/labels", input=post_parameters