diff --git a/crates/git_hosting_providers/src/providers/github.rs b/crates/git_hosting_providers/src/providers/github.rs index 7d2f20ff70..eb6d606195 100644 --- a/crates/git_hosting_providers/src/providers/github.rs +++ b/crates/git_hosting_providers/src/providers/github.rs @@ -60,6 +60,9 @@ impl Github { pub fn from_remote_url(remote_url: &str) -> Result { let host = get_host_from_git_remote_url(remote_url)?; + if host == "github.com" { + bail!("the GitHub instance is not self-hosted"); + } // TODO: detecting self hosted instances by checking whether "github" is in the url or not // is not very reliable. See https://github.com/zed-industries/zed/issues/26393 for more @@ -236,6 +239,13 @@ mod tests { use super::*; + #[test] + fn test_invalid_self_hosted_remote_url() { + let remote_url = "git@github.com:zed-industries/zed.git"; + let github = Github::from_remote_url(remote_url); + assert!(github.is_err()); + } + #[test] fn test_from_remote_url_ssh() { let remote_url = "git@github.my-enterprise.com:zed-industries/zed.git"; diff --git a/crates/git_hosting_providers/src/providers/gitlab.rs b/crates/git_hosting_providers/src/providers/gitlab.rs index abdfc491f4..8158b45444 100644 --- a/crates/git_hosting_providers/src/providers/gitlab.rs +++ b/crates/git_hosting_providers/src/providers/gitlab.rs @@ -26,6 +26,9 @@ impl Gitlab { pub fn from_remote_url(remote_url: &str) -> Result { let host = get_host_from_git_remote_url(remote_url)?; + if host == "gitlab.com" { + bail!("the GitLab instance is not self-hosted"); + } // TODO: detecting self hosted instances by checking whether "gitlab" is in the url or not // is not very reliable. See https://github.com/zed-industries/zed/issues/26393 for more @@ -123,6 +126,13 @@ mod tests { use super::*; + #[test] + fn test_invalid_self_hosted_remote_url() { + let remote_url = "https://gitlab.com/zed-industries/zed.git"; + let github = Gitlab::from_remote_url(remote_url); + assert!(github.is_err()); + } + #[test] fn test_parse_remote_url_given_ssh_url() { let parsed_remote = Gitlab::new()