Skip to content

Commit 0d1aa26

Browse files
committed
fix(preprod): Understand ghe.com as github_enterprise
To determine vcs_provider we use part of the origin of the URL: https://github.com/foo/bar -> github https://gitlab.com/abcdef -> gitlab This adds special handling for github enterprize remotes. Now instead of: https://foo.ghe.com/foo/bar -> ghe we end up with: https://foo.ghe.com/foo/bar -> github_enterprise as the backend expects.
1 parent c4ca248 commit 0d1aa26

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/utils/vcs.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ impl VcsUrl {
220220

221221
fn extract_provider_name(host: &str) -> &str {
222222
let trimmed = host.trim_end_matches('.');
223+
224+
// GitHub Enterprise Server uses *.ghe.com domains
225+
if trimmed.ends_with(".ghe.com") {
226+
return "github_enterprise";
227+
}
228+
223229
trimmed.rsplit('.').nth(1).unwrap_or(trimmed)
224230
}
225231

@@ -1085,6 +1091,13 @@ mod tests {
10851091
// Test edge case with trailing dots
10861092
assert_eq!(extract_provider_name("github.com."), "github");
10871093

1094+
// Test GitHub Enterprise Server (*.ghe.com)
1095+
assert_eq!(extract_provider_name("foo.ghe.com"), "github_enterprise");
1096+
assert_eq!(
1097+
extract_provider_name("mycompany.ghe.com"),
1098+
"github_enterprise"
1099+
);
1100+
10881101
// Test subdomain cases - we want the part before TLD, not the subdomain
10891102
assert_eq!(extract_provider_name("api.github.com"), "github");
10901103
assert_eq!(extract_provider_name("ssh.dev.azure.com"), "azure");
@@ -1125,6 +1138,15 @@ mod tests {
11251138
get_provider_from_remote("https://source.developers.google.com/p/project/r/repo"),
11261139
"google"
11271140
);
1141+
// Test GitHub Enterprise Server (*.ghe.com)
1142+
assert_eq!(
1143+
get_provider_from_remote("https://foo.ghe.com/bar/baz.git"),
1144+
"github_enterprise"
1145+
);
1146+
assert_eq!(
1147+
get_provider_from_remote("git@mycompany.ghe.com:org/repo.git"),
1148+
"github_enterprise"
1149+
);
11281150
// Test edge case with trailing dot in hostname
11291151
assert_eq!(
11301152
get_provider_from_remote("https://github.com./user/repo"),

0 commit comments

Comments
 (0)