Skip to content

Commit

Permalink
VCS: Support URLs ending with ".git" in splitUrl()
Browse files Browse the repository at this point in the history
Add handling of URLs ending with ".git" to the `splitUrl()` function.
Previously, the `VcsType` of such URLs could not be detected.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@here.com>
  • Loading branch information
mnonnenmacher committed Sep 3, 2019
1 parent 9fded2a commit a3d9450
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions downloader/src/main/kotlin/VersionControlSystem.kt
Expand Up @@ -222,6 +222,10 @@ abstract class VersionControlSystem {

else -> {
when {
vcsUrl.endsWith(".git") -> {
VcsInfo(VcsType.GIT, normalizeVcsUrl(vcsUrl), "", null, "")
}

vcsUrl.contains(".git/") -> {
val url = normalizeVcsUrl(vcsUrl.substringBefore(".git/"))
val path = vcsUrl.substringAfter(".git/")
Expand Down
13 changes: 13 additions & 0 deletions downloader/src/test/kotlin/VersionControlSystemTest.kt
Expand Up @@ -66,6 +66,19 @@ class VersionControlSystemTest : WordSpec({

"splitUrl" should {
"split paths from a URL to a Git repository" {
val actual = VersionControlSystem.splitUrl(
"https://git-wip-us.apache.org/repos/asf/zeppelin.git"
)
val expected = VcsInfo(
type = VcsType.GIT,
url = "https://git-wip-us.apache.org/repos/asf/zeppelin.git",
revision = "",
path = ""
)
actual shouldBe expected
}

"split paths from a URL to a Git repository with path" {
val actual = VersionControlSystem.splitUrl(
"https://git-wip-us.apache.org/repos/asf/zeppelin.git/zeppelin-interpreter"
)
Expand Down

0 comments on commit a3d9450

Please sign in to comment.