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 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