From ef26ce410f8202ba69699ea7696058648887c71a Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 8 Apr 2023 14:45:22 +0100 Subject: setbranch : store the branches and remotes in a dict, simplyfying the code --- src/backend/setbranch.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/backend/setbranch.py b/src/backend/setbranch.py index 5aa6a65..23b1b86 100644 --- a/src/backend/setbranch.py +++ b/src/backend/setbranch.py @@ -12,24 +12,30 @@ import sisyphus.setjobs import sisyphus.setprofile +brch_rmt_map = { + "master": { + "github": sisyphus.getfs.rmt_gh_addr, + "gitlab": sisyphus.getfs.rmt_gl_addr, + "pagure": sisyphus.getfs.rmt_pg_addr + }, + "next": { + "github": sisyphus.getfs.rmt_gh_addr, + "gitlab": sisyphus.getfs.rmt_gl_addr, + "pagure": sisyphus.getfs.rmt_pg_addr + } +} + + def get_brch_rmt(branch, remote): g_rmt = [] r_rmt = [] p_cfg_rmt = [] - if "master" in branch: - if "github" in remote: - remote = sisyphus.getfs.rmt_gh_addr - elif "gitlab" in remote: - remote = sisyphus.getfs.rmt_gl_addr - elif "pagure" in remote: - remote = sisyphus.getfs.rmt_pg_addr - elif "next" in branch: - if "github" in remote: - remote = sisyphus.getfs.rmt_gh_addr - elif "gitlab" in remote: - remote = sisyphus.getfs.rmt_gl_addr - elif "pagure" in remote: - remote = sisyphus.getfs.rmt_pg_addr + + if branch in brch_rmt_map and remote in brch_rmt_map[branch]: + remote = brch_rmt_map[branch][remote] + else: + # set a default remote here if needed + pass g_rmt = [remote, sisyphus.getfs.g_repo] r_rmt = [remote, sisyphus.getfs.r_repo] -- cgit v1.2.3