Skip to content

Commit

Permalink
bug(kawamataryo#19): Port misplaced for self-fosted gitlab
Browse files Browse the repository at this point in the history
- fix regex
- added test-data for self-fosted gitlab ULR
  • Loading branch information
andreyvb committed Sep 20, 2023
1 parent 9d09624 commit 55e5d58
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 55e5d58

Please sign in to comment.