Refactor config_util.py to handle gitlab host input

This commit is contained in:
bobo 2024-05-22 16:57:16 +08:00
parent 14b3197543
commit 62b450d677

View File

@ -1,10 +1,11 @@
import json import json
import os import os
from lib.chatmark import TextEditor, Radio from lib.chatmark import Radio, TextEditor
cache_repo_types = {} cache_repo_types = {}
# 根据PR URL获取不同的仓库管理类型 # 根据PR URL获取不同的仓库管理类型
# 支持的类型有github gitlab bitbucket bitbucket_server azure codecommit gerrit # 支持的类型有github gitlab bitbucket bitbucket_server azure codecommit gerrit
def get_repo_type(url): def get_repo_type(url):
@ -27,15 +28,7 @@ def get_repo_type(url):
return cache_repo_types[url] return cache_repo_types[url]
else: else:
radio = Radio( radio = Radio(
[ ["github", "gitlab", "bitbucket", "bitbucket_server", "azure", "codecommit", "gerrit"],
"github",
"gitlab",
"bitbucket",
"bitbucket_server",
"azure",
"codecommit",
"gerrit"
],
) )
radio.render() radio.render()
if radio.selection is None: if radio.selection is None:
@ -48,7 +41,7 @@ def get_repo_type(url):
"bitbucket_server", "bitbucket_server",
"azure", "azure",
"codecommit", "codecommit",
"gerrit" "gerrit",
][radio.selection] ][radio.selection]
cache_repo_types[url] = rtype cache_repo_types[url] = rtype
return rtype return rtype