@@ -40,6 +40,7 @@ pub enum ReviewPlatformError {
4040pub enum ReviewPlatformKind {
4141 Github ,
4242 Gitlab ,
43+ Codehub ,
4344 Gitcode ,
4445 Unknown ,
4546}
@@ -49,6 +50,7 @@ impl ReviewPlatformKind {
4950 match self {
5051 Self :: Github => "github" ,
5152 Self :: Gitlab => "gitlab" ,
53+ Self :: Codehub => "codehub" ,
5254 Self :: Gitcode => "gitcode" ,
5355 Self :: Unknown => "unknown" ,
5456 }
@@ -498,6 +500,7 @@ fn provider_for(platform: ReviewPlatformKind) -> &'static dyn ReviewProvider {
498500 match platform {
499501 ReviewPlatformKind :: Github => & GithubProvider ,
500502 ReviewPlatformKind :: Gitlab => & GitlabProvider ,
503+ ReviewPlatformKind :: Codehub => & GitlabProvider ,
501504 ReviewPlatformKind :: Gitcode => & GitcodeProvider ,
502505 ReviewPlatformKind :: Unknown => & UnsupportedProvider ,
503506 }
@@ -1124,6 +1127,7 @@ fn provider_context(
11241127 let api_base_url = match remote. platform {
11251128 ReviewPlatformKind :: Github => "https://api.github.com" . to_string ( ) ,
11261129 ReviewPlatformKind :: Gitlab => format ! ( "https://{}/api/v4" , remote. host) ,
1130+ ReviewPlatformKind :: Codehub => "https://codehub-y.huawei.com/api/v4" . to_string ( ) ,
11271131 ReviewPlatformKind :: Gitcode => "https://api.gitcode.com/api/v5" . to_string ( ) ,
11281132 ReviewPlatformKind :: Unknown => {
11291133 return Err ( ReviewPlatformError :: UnsupportedPlatform ( remote. host ) ) ;
@@ -1151,6 +1155,7 @@ fn env_token_for_platform(platform: ReviewPlatformKind) -> Option<String> {
11511155 let names: & [ & str ] = match platform {
11521156 ReviewPlatformKind :: Github => & [ "GITHUB_TOKEN" , "GH_TOKEN" ] ,
11531157 ReviewPlatformKind :: Gitlab => & [ "GITLAB_TOKEN" , "GITLAB_PRIVATE_TOKEN" ] ,
1158+ ReviewPlatformKind :: Codehub => & [ "CODEHUB_TOKEN" ] ,
11541159 ReviewPlatformKind :: Gitcode => & [ "GITCODE_TOKEN" ] ,
11551160 ReviewPlatformKind :: Unknown => & [ ] ,
11561161 } ;
@@ -1353,7 +1358,11 @@ fn capabilities_for_remote(remote: &ReviewPlatformRemote) -> ReviewPlatformCapab
13531358 ReviewPlatformCapabilities {
13541359 can_create_review : has_token,
13551360 can_reply_to_thread : has_token,
1356- can_resolve_thread : has_token && remote. platform == ReviewPlatformKind :: Gitlab ,
1361+ can_resolve_thread : has_token
1362+ && matches ! (
1363+ remote. platform,
1364+ ReviewPlatformKind :: Gitlab | ReviewPlatformKind :: Codehub
1365+ ) ,
13571366 can_merge : false ,
13581367 supports_draft_review : remote. platform == ReviewPlatformKind :: Github ,
13591368 }
@@ -1363,6 +1372,7 @@ fn platform_label(platform: ReviewPlatformKind) -> &'static str {
13631372 match platform {
13641373 ReviewPlatformKind :: Github => "GitHub" ,
13651374 ReviewPlatformKind :: Gitlab => "GitLab" ,
1375+ ReviewPlatformKind :: Codehub => "CodeHub" ,
13661376 ReviewPlatformKind :: Gitcode => "GitCode" ,
13671377 ReviewPlatformKind :: Unknown => "Git" ,
13681378 }
@@ -1377,6 +1387,8 @@ fn parse_remote(
13771387 let host_lower = parsed. host . to_ascii_lowercase ( ) ;
13781388 let platform = if host_lower. contains ( "github.com" ) {
13791389 ReviewPlatformKind :: Github
1390+ } else if host_lower. contains ( "-y" ) && host_lower. contains ( "codehub" ) {
1391+ ReviewPlatformKind :: Codehub
13801392 } else if host_lower. contains ( "gitlab" ) {
13811393 ReviewPlatformKind :: Gitlab
13821394 } else if host_lower. contains ( "gitcode" ) {
0 commit comments