aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-05-04 15:46:36 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-05-04 15:46:36 +0200
commit7bb73cd925a0dc9547699dd555b9f990d8f3ae39 (patch)
tree498ef22a9f9f54da781f804e123d47fc59476f4e
parentfadd1eab07c9dfe317dfc31efa8ea254a78c3eeb (diff)
downloadlab-bot-7bb73cd925a0dc9547699dd555b9f990d8f3ae39.tar.gz
lab-bot-7bb73cd925a0dc9547699dd555b9f990d8f3ae39.zip
remove debug prints, add act labels to merge-label addon
-rw-r--r--labbot/addons/approve-merge.py3
-rw-r--r--labbot/addons/merge-label.py28
2 files changed, 24 insertions, 7 deletions
diff --git a/labbot/addons/approve-merge.py b/labbot/addons/approve-merge.py
index 81ea68d..9b10ef6 100644
--- a/labbot/addons/approve-merge.py
+++ b/labbot/addons/approve-merge.py
@@ -26,10 +26,9 @@ async def merge_label_hook(event, gl, *args, **kwargs):
if approval_count >= required_approval_count:
if merge_status == "can_be_merged":
- print("test")
await gl.put(merge_url)
else:
- log.debug(f"Cannot merge !{iid} because of its merge_statuc `{merge_status}`")
+ log.debug(f"Cannot merge !{iid} because of its merge_status `{merge_status}`")
def setup(bot):
bot.register_merge_hook(merge_label_hook)
diff --git a/labbot/addons/merge-label.py b/labbot/addons/merge-label.py
index cf7bf82..506573e 100644
--- a/labbot/addons/merge-label.py
+++ b/labbot/addons/merge-label.py
@@ -19,9 +19,17 @@ relation_distance = 2
state_label = {
"closed": "In Progress",
- "opened": "C-R Bestanden",
- "merged": "Testing",
+ "opened": "Code-Review",
+ "merged": "C-R Bestanden",
}
+
+# Extra labels that the bot will check for before acting
+act_labels = [
+ "Sprint",
+ "Testing",
+ "TestingFailed",
+]
+
async def merge_label_hook(event, gl, *args, **kwargs):
state = event.object_attributes["state"]
related_issues = []
@@ -59,7 +67,18 @@ async def merge_label_hook(event, gl, *args, **kwargs):
base_url = f"/projects/{event.project_id}/issues/{issue}"
- delete_labels = list(state_label.values())
+ has_label = False
+ issue_data = await gl.getitem(base_url)
+ for label in issue_data["labels"]:
+ if label in act_labels or state_label.values():
+ has_label = True
+ break
+
+ if not has_label:
+ log.debug(f"Issue #{issue} does not have a relevant label")
+ continue
+
+ delete_labels = act_labels + list(state_label.values())
try:
label = state_label[state]
@@ -74,8 +93,7 @@ async def merge_label_hook(event, gl, *args, **kwargs):
})
except KeyError:
- # unknown state
- pass
+ log.exception("Unknown state")
def setup(bot) -> None:
bot.register_merge_hook(merge_label_hook)