aboutsummaryrefslogtreecommitdiff
path: root/labbot/addons/merge-stable.py
diff options
context:
space:
mode:
Diffstat (limited to 'labbot/addons/merge-stable.py')
-rw-r--r--labbot/addons/merge-stable.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/labbot/addons/merge-stable.py b/labbot/addons/merge-stable.py
index d395160..f8e0ced 100644
--- a/labbot/addons/merge-stable.py
+++ b/labbot/addons/merge-stable.py
@@ -6,13 +6,18 @@ branch relation is figured out by looking at related merge requests
import logging
-log = logging.getLogger(__name__)
+from labbot.config import Config
+log = logging.getLogger(__name__)
-stable_branch = "main"
-staging_branch = "staging"
-merge_label = "Release"
+config = Config()
+config.set_global_data(
+ stable_branch = "main",
+ staging_branch = "staging",
+ merge_label = "Release",
+)
+@config.config_decorator()
async def issue_update_hook(event, gl, *args, **kwargs):
issue_id = event.object_attributes["iid"]
issue_url = f"/projects/{event.project_id}/issues/{issue_id}"
@@ -20,14 +25,14 @@ async def issue_update_hook(event, gl, *args, **kwargs):
branches = {}
- if merge_label in issue_data["labels"]:
+ if config["merge_label"] in issue_data["labels"]:
async for merge_data in gl.getiter(f"{issue_url}/related_merge_requests"):
source_branch = merge_data["source_branch"]
target_branch = merge_data["target_branch"]
merge_id = merge_data["iid"]
# we only want staging merges
- if target_branch != staging_branch:
+ if target_branch != config["staging_branch"]:
continue
if not source_branch in branches:
@@ -44,7 +49,7 @@ async def issue_update_hook(event, gl, *args, **kwargs):
async for merge_data in gl.getiter(merge_url, params={
"source_branch": branch,
- "target_branch": stable_branch
+ "target_branch": config["stable_branch"]
}):
if merge_data["state"] == "opened":
merge_exists = True
@@ -55,11 +60,12 @@ async def issue_update_hook(event, gl, *args, **kwargs):
merge_string = ", ".join(merge)
await gl.post(merge_url, data={
"source_branch": branch,
- "target_branch": stable_branch,
- "title": f"[stable] Merge `{branch}` into `{stable_branch}`",
+ "target_branch": config["stable_branch"],
+ "title": f"[stable] Merge `{branch}` into `{config['stable_branch']}`",
"description": f"Related to #{issue_id} \n \nStaging Merges: \n{merge_string}"
})
def setup(bot) -> None:
- bot.register_issue_hook(issue_update_hook) \ No newline at end of file
+ config.setup(__name__, bot.name)
+ bot.register_issue_hook(issue_update_hook)