Skip to content

Commit 38ff411

Browse files
authored
Merge pull request #156 from sommersoft/auto_label
Automatically Add Missing Standard Labels
2 parents cb47e08 + 5bb136e commit 38ff411

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

adabot/lib/circuitpython_library_validators.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,20 @@
142142
"Adafruit_CircuitPython_miniQR",
143143
]
144144

145-
STD_REPO_LABELS = ("bug", "documentation", "enhancement", "good first issue")
145+
STD_REPO_LABELS = {
146+
"bug": {
147+
"color": "ee0701"
148+
},
149+
"documentation": {
150+
"color": "d4c5f9"
151+
},
152+
"enhancement": {
153+
"color": "84b6eb"
154+
},
155+
"good first issue": {
156+
"color": "7057ff"
157+
}
158+
}
146159

147160
# Cache CircuitPython's subprojects on ReadTheDocs so its not fetched every repo check.
148161
rtd_subprojects = None
@@ -982,13 +995,27 @@ def validate_labels(self, repo):
982995
self.output_file_data.append("Labels request failed: {}".format(repo["full_name"]))
983996
return [ERROR_OUTPUT_HANDLER]
984997

998+
errors = []
999+
9851000
repo_labels = [label["name"] for label in response.json()]
1001+
9861002
has_all_labels = True
987-
for label in STD_REPO_LABELS:
1003+
for label, info in STD_REPO_LABELS.items():
9881004
if not label in repo_labels:
989-
has_all_labels = False
1005+
response = github.post(
1006+
"/repos/" + repo["full_name"] + "/labels",
1007+
json={"name": label, "color": info["color"]}
1008+
)
1009+
if not response.ok:
1010+
has_all_labels = False
1011+
self.output_file_data.append(
1012+
"Request to add '{}' label failed: {}".format(label,
1013+
repo["full_name"])
1014+
)
1015+
if ERROR_OUTPUT_HANDLER not in errors:
1016+
errors.append(ERROR_OUTPUT_HANDLER)
9901017

9911018
if not has_all_labels:
992-
return [ERROR_MISSING_STANDARD_LABELS]
993-
else:
994-
return []
1019+
errors.append(ERROR_MISSING_STANDARD_LABELS)
1020+
1021+
return errors

0 commit comments

Comments
 (0)