diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2022-05-04 15:04:46 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2022-05-04 15:04:46 +0200 |
commit | 1ec64ccb178a4164ac204925c20c559d96508a9b (patch) | |
tree | a11105d202afa7fb54273ab9d74985bfe7098faa /labbot/addons | |
parent | 27b8241380d5f02fdcf00a832c281767ef258d9f (diff) | |
download | lab-bot-1ec64ccb178a4164ac204925c20c559d96508a9b.tar.gz lab-bot-1ec64ccb178a4164ac204925c20c559d96508a9b.zip |
add logging, offload addons into config, allow external addons
Diffstat (limited to 'labbot/addons')
-rw-r--r-- | labbot/addons/approve-merge.py | 10 | ||||
-rw-r--r-- | labbot/addons/merge-label.py | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/labbot/addons/approve-merge.py b/labbot/addons/approve-merge.py index 0fdeaa9..3c0ef30 100644 --- a/labbot/addons/approve-merge.py +++ b/labbot/addons/approve-merge.py @@ -2,6 +2,9 @@ automatically merges merge requests if a certain number of approvals is reached. """ +import logging + +log = logging.getLogger(__name__) required_approval_count = 2 @@ -9,12 +12,13 @@ async def merge_label_hook(event, gl, *args, **kwargs): title = event.object_attributes["title"] state = event.object_attributes["state"] merge_status = event.object_attributes["merge_status"] + iid = event.object_attributes['iid'] if state != "opened" or title.lower().startswith("draft"): return - approvals_url = f"/projects/{event.project_id}/merge_requests/{event.object_attributes['iid']}/approvals" - merge_url = f"/projects/{event.project_id}/merge_requests/{event.object_attributes['iid']}/merge" + approvals_url = f"/projects/{event.project_id}/merge_requests/{iid}/approvals" + merge_url = f"/projects/{event.project_id}/merge_requests/{iid}/merge" data = await gl.getitem(approvals_url) @@ -24,6 +28,8 @@ async def merge_label_hook(event, gl, *args, **kwargs): 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}`") def setup(bot): bot.register(merge_label_hook, "Merge Request Hook") diff --git a/labbot/addons/merge-label.py b/labbot/addons/merge-label.py index 9379b59..4798d4a 100644 --- a/labbot/addons/merge-label.py +++ b/labbot/addons/merge-label.py @@ -5,6 +5,10 @@ specified labels. import os import re +import logging + +log = logging.getLogger(__name__) + title_regex = r"^(?:#|)(\d+)\s*" word_regex = r"^#(\d+)$" |