feat: Support Google Cloud Builder VCS detection
* Support google cloud builder.
Authored-by: Will C
@@ -137,11 +137,14 @@ impl VcsUrl {
static ref VS_GIT_PATH_RE: Regex = Regex::new(r"^_git/(.+?)(?:\.git)?$").unwrap();
static ref VS_TRAILING_GIT_PATH_RE: Regex = Regex::new(r"^(.+?)/_git").unwrap();
static ref HOST_WITH_PORT: Regex = Regex::new(r"(.*):\d+$").unwrap();
+ static ref GCB_DOMAIN_RE: Regex = Regex::new(r"^source\.developers\.google\.com$").unwrap();
+ static ref GCB_GIT_PATH_RE: Regex = Regex::new(r"^p/.+/r/github_(.+?)_(.+?)(?:\.git)?$").unwrap();
}
if let Some(caps) = HOST_WITH_PORT.captures(host) {
return VcsUrl::from_git_parts(&caps[1], path);
}
+
if let Some(caps) = VS_DOMAIN_RE.captures(host) {
let username = &caps[1];
if let Some(caps) = VS_GIT_PATH_RE.captures(path) {
@@ -157,6 +160,7 @@ impl VcsUrl {
};
}
}
+
if let Some(caps) = AZUREDEV_DOMAIN_RE.captures(host) {
let hostname = &caps[1];
if let Some(caps) = AZUREDEV_VERSION_PATH_RE.captures(path) {
@@ -172,6 +176,16 @@ impl VcsUrl {
};
}
}
+
+ if let Some(_caps) = GCB_DOMAIN_RE.captures(host) {
+ if let Some(caps) = GCB_GIT_PATH_RE.captures(path) {
+ return VcsUrl {
+ provider: host.into(),
+ id: format!("{}/{}", &caps[1], &caps[2]),
+ };
+ }
+ }
+
VcsUrl {
provider: host.to_lowercase(),
id: strip_git_suffix(path).to_lowercase(),
@@ -195,6 +209,7 @@ fn find_reference_url(repo: &str, repos: &[Repo]) -> Result<String, Error> {
| "github"
| "bitbucket"
| "visualstudio"
+ | "google"
| "integrations:github"
| "integrations:github_enterprise"
| "integrations:gitlab"
@@ -579,6 +594,12 @@ fn test_url_parsing() {
id: "gitlab-org/gitlab-ce".into(),
}
);
+ assert_eq!(
+ VcsUrl::parse("https://source.developers.google.com/p/project-slug/r/github_org-slug_repo-slug"),
+ VcsUrl {
+ provider: "source.developers.google.com".into(),
+ id: "org-slug/repo-slug".into(),
+ );
assert_eq!(
VcsUrl::parse("git@gitlab.com:gitlab-org/GitLab-CE.git"),
VcsUrl {
