Skip to content

Commit

Permalink
Merge pull request #27 from andreyvb/bag19
Browse files Browse the repository at this point in the history
  • Loading branch information
kawamataryo authored Dec 28, 2023
2 parents 9d09624 + 55e5d58 commit e93eeff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fun getRepositoryPathFromRemoteUrl(
remoteUrl: String,
): String {
val result =
Regex(".*(?:@|\\/\\/)(.[^:\\/]*)(?::[0-9]{1,4})?.([^\\.]+)(\\.git)?\$").matchEntire(
Regex(".*(?:@|//)(.[^:/]*)(:?:[0-9]{1,4})?.([^.]+)(\\.git)?\$").matchEntire(
remoteUrl
)
return result?.groupValues?.get(1) + "/" + result?.groupValues?.get(2) ?: ""
return result?.groupValues?.get(1) + result?.groupValues?.get(2) + "/" + result?.groupValues?.get(3) ?: ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class UtilsKtTest {
"ssh://[email protected]:user/repo.git, github.com/user/repo",
"git://github.com/user/repo.git, github.com/user/repo",
"https://github.com/YandexClassifieds/projectname, github.com/YandexClassifieds/projectname",
"https://gitlab.self-hosted.com:8443/projgroup/projectname, gitlab.self-hosted.com:8443/projgroup/projectname",
)
fun testGetRepositoryPathFromRemoteUrl(remoteUrl: String, expectedPath: String) {
val actualPath = getRepositoryPathFromRemoteUrl(remoteUrl)
Expand Down

0 comments on commit e93eeff

Please sign in to comment.