From 573824236f40fb68430f3bf2486a1716924fb2c7 Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 22 May 2024 17:36:51 +0800 Subject: [PATCH 1/2] chore: Add repository type selection prompt in config_util.py --- merico/pr/config_util.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/merico/pr/config_util.py b/merico/pr/config_util.py index ca2c9d2..11a30f3 100644 --- a/merico/pr/config_util.py +++ b/merico/pr/config_util.py @@ -10,6 +10,7 @@ # 支持的类型有:github gitlab bitbucket bitbucket_server azure codecommit gerrit def get_repo_type(url): # 根据URL的特征判断仓库管理类型 + support_repo_list = ["github", "gitlab", "bitbucket", "bitbucket_server", "azure", "codecommit", "gerrit"] if "github.com" in url: return "github" elif "gitlab.com" in url or "gitlab" in url: @@ -28,21 +29,14 @@ def get_repo_type(url): return cache_repo_types[url] else: radio = Radio( - ["github", "gitlab", "bitbucket", "bitbucket_server", "azure", "codecommit", "gerrit"], + support_repo_list, + title="Choose the type of repository:", ) radio.render() if radio.selection is None: return "" - rtype = [ - "github", - "gitlab", - "bitbucket", - "bitbucket_server", - "azure", - "codecommit", - "gerrit", - ][radio.selection] + rtype = support_repo_list[radio.selection] cache_repo_types[url] = rtype return rtype From a15f1a08a8ea9f8a83c297157ca0b215266db1e3 Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 22 May 2024 17:38:50 +0800 Subject: [PATCH 2/2] Refactor config_util.py to use a list for the supported repository types --- merico/pr/config_util.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/merico/pr/config_util.py b/merico/pr/config_util.py index 11a30f3..1cb0204 100644 --- a/merico/pr/config_util.py +++ b/merico/pr/config_util.py @@ -10,7 +10,15 @@ # 支持的类型有:github gitlab bitbucket bitbucket_server azure codecommit gerrit def get_repo_type(url): # 根据URL的特征判断仓库管理类型 - support_repo_list = ["github", "gitlab", "bitbucket", "bitbucket_server", "azure", "codecommit", "gerrit"] + support_repo_list = [ + "github", + "gitlab", + "bitbucket", + "bitbucket_server", + "azure", + "codecommit", + "gerrit", + ] if "github.com" in url: return "github" elif "gitlab.com" in url or "gitlab" in url: