From 62b450d677c4eff8319544afdd63f46c2eae01c8 Mon Sep 17 00:00:00 2001 From: bobo Date: Wed, 22 May 2024 16:57:16 +0800 Subject: [PATCH] Refactor config_util.py to handle gitlab host input --- merico/pr/config_util.py | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/merico/pr/config_util.py b/merico/pr/config_util.py index c1c5b49..ca2c9d2 100644 --- a/merico/pr/config_util.py +++ b/merico/pr/config_util.py @@ -1,10 +1,11 @@ import json import os -from lib.chatmark import TextEditor, Radio - +from lib.chatmark import Radio, TextEditor cache_repo_types = {} + + # 根据PR URL获取不同的仓库管理类型 # 支持的类型有:github gitlab bitbucket bitbucket_server azure codecommit gerrit def get_repo_type(url): @@ -27,29 +28,21 @@ def get_repo_type(url): return cache_repo_types[url] else: radio = Radio( - [ - "github", - "gitlab", - "bitbucket", - "bitbucket_server", - "azure", - "codecommit", - "gerrit" - ], + ["github", "gitlab", "bitbucket", "bitbucket_server", "azure", "codecommit", "gerrit"], ) radio.render() if radio.selection is None: return "" rtype = [ - "github", - "gitlab", - "bitbucket", - "bitbucket_server", - "azure", - "codecommit", - "gerrit" - ][radio.selection] + "github", + "gitlab", + "bitbucket", + "bitbucket_server", + "azure", + "codecommit", + "gerrit", + ][radio.selection] cache_repo_types[url] = rtype return rtype