aboutsummaryrefslogtreecommitdiff
path: root/labbot/addons/merge-label.py
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 /labbot/addons/merge-label.py
parentfadd1eab07c9dfe317dfc31efa8ea254a78c3eeb (diff)
downloadlab-bot-7bb73cd925a0dc9547699dd555b9f990d8f3ae39.tar.gz
lab-bot-7bb73cd925a0dc9547699dd555b9f990d8f3ae39.zip
remove debug prints, add act labels to merge-label addon
Diffstat (limited to 'labbot/addons/merge-label.py')
-rw-r--r--labbot/addons/merge-label.py28
1 files changed, 23 insertions, 5 deletions
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)