fix: Cloning projects from Azure DevOps (#522)

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/524/head
Anatolii Bazko 2023-06-08 12:44:06 +03:00 committed by GitHub
parent 98c2cc79eb
commit 7c598014a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View File

@ -70,17 +70,19 @@ public class AzureDevOpsURLParser {
throw new IllegalArgumentException(format("The given url %s is not a valid.", url));
}
String project = null;
try {
project = matcher.group("project");
} catch (IllegalArgumentException e) {
}
String repoName = matcher.group("repoName");
if (repoName.endsWith(".git")) {
repoName = repoName.substring(0, repoName.length() - 4);
}
String project = matcher.group("project");
if (project == null) {
// if project is not specified, repo name must be equal to project name
// https://dev.azure.com/<MyOrg>/<MyRepo>/_git/<MyRepo> ==
// https://dev.azure.com/<MyOrg>/_git/<MyRepo>
project = repoName;
}
String organization = matcher.group("organization");
String branch = matcher.group("branch");
String tag = matcher.group("tag");

View File

@ -149,11 +149,7 @@ public class AzureDevOpsUrl extends DefaultFactoryUrl {
}
private StringJoiner getRepoPathJoiner() {
StringJoiner repoPath = new StringJoiner("/").add(hostName).add(organization);
if (project != null) {
repoPath.add("_git");
}
return repoPath;
return new StringJoiner("/").add(hostName).add(organization).add(project);
}
@Override

View File

@ -133,7 +133,7 @@ public class AzureDevOpsURLParserTest {
null,
"MyTag"
},
{"https://MyOrg@dev.azure.com/MyOrg/_git/MyRepo", "MyOrg", null, "MyRepo", null, null},
{"https://MyOrg@dev.azure.com/MyOrg/_git/MyRepo", "MyOrg", "MyRepo", "MyRepo", null, null},
};
}