Skip to content

Commit

Permalink
Merge pull request #19 from utilitywarehouse/as-fix-bug
Browse files Browse the repository at this point in the history
https url might not have .git suffix
  • Loading branch information
asiyani committed Jul 3, 2024
2 parents f4d4ee6 + f4abf56 commit bdecfe6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pkg/giturl/git_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func Parse(rawURL string) (*URL, error) {
func SameURL(lURL, rURL *URL) bool {
return lURL.Host == rURL.Host &&
lURL.Path == rURL.Path &&
lURL.Repo == rURL.Repo
(lURL.Repo == rURL.Repo ||
strings.TrimSuffix(lURL.Repo, ".git") == strings.TrimSuffix(rURL.Repo, ".git"))
}

// SameRawURL returns whether or not the two remote URL strings are equivalent
Expand Down
32 changes: 18 additions & 14 deletions pkg/giturl/git_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,24 @@ func TestSameRawURL(t *testing.T) {
{"2", args{"git@github.com:org/repo.git", "git@github.com:org/repo.git"}, true, false},
{"3", args{"git@github.com:org/repo.git", "ssh://git@github.com/org/repo.git"}, true, false},
{"4", args{"git@github.com:org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"5", args{"ssh://user@host.xz:123/path/to/repo.git", "ssh://user@host.xz:123/path/to/REPO.GIT"}, true, false},
{"6", args{"ssh://git@github.com/org/repo.git", "git@github.com:org/repo.git"}, true, false},
{"7", args{"ssh://git@github.com/org/repo.git", "ssh://git@github.com/org/repo.git"}, true, false},
{"8", args{"ssh://git@github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"9", args{"https://host.xz:345/path/to/repo.git", "HTTPS://HOST.XZ:345/path/to/repo.git"}, true, false},
{"10", args{"https://github.com/org/repo.git", "git@github.com:org/repo.git"}, true, false},
{"11", args{"https://github.com/org/repo.git", "ssh://git@github.com/org/repo.git"}, true, false},
{"12", args{"https://github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"13", args{"user@host.xz:123:path/to/repo.git", "ssh://user@host.xz:123/path/to/repo.git"}, true, false},
{"14", args{"user@host.xz:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"15", args{"ssh://user@host.xz:123/path/to/repo.git", "user@host.xz:123:path/to/repo.git"}, true, false},
{"16", args{"ssh://user@host.xz:123/path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"17", args{"https://host.xz:123/path/to/repo.git", "user@host.xz:123:path/to/repo.git"}, true, false},
{"18", args{"https://host.xz:123/path/to/repo.git", "ssh://user@host.xz:123/path/to/repo.git"}, true, false},
{"5", args{"git@github.com:org/repo.git", "https://github.com/org/repo"}, true, false},
{"6", args{"ssh://user@host.xz:123/path/to/repo.git", "ssh://user@host.xz:123/path/to/REPO.GIT"}, true, false},
{"7", args{"ssh://git@github.com/org/repo.git", "git@github.com:org/repo.git"}, true, false},
{"8", args{"ssh://git@github.com/org/repo.git", "ssh://git@github.com/org/repo.git"}, true, false},
{"9", args{"ssh://git@github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"10", args{"https://host.xz:345/path/to/repo.git", "HTTPS://HOST.XZ:345/path/to/repo.git"}, true, false},
{"11", args{"https://github.com/org/repo.git", "git@github.com:org/repo.git"}, true, false},
{"12", args{"https://github.com/org/repo.git", "ssh://git@github.com/org/repo.git"}, true, false},
{"13", args{"https://github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"14", args{"https://github.com/org/repo", "git@github.com:org/repo.git"}, true, false},
{"15", args{"https://github.com/org/repo", "ssh://git@github.com/org/repo.git"}, true, false},
{"16", args{"https://github.com/org/repo", "https://github.com/org/repo.git"}, true, false},
{"17", args{"user@host.xz:123:path/to/repo.git", "ssh://user@host.xz:123/path/to/repo.git"}, true, false},
{"18", args{"user@host.xz:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"19", args{"ssh://user@host.xz:123/path/to/repo.git", "user@host.xz:123:path/to/repo.git"}, true, false},
{"20", args{"ssh://user@host.xz:123/path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"21", args{"https://host.xz:123/path/to/repo.git", "user@host.xz:123:path/to/repo.git"}, true, false},
{"22", args{"https://host.xz:123/path/to/repo.git", "ssh://user@host.xz:123/path/to/repo.git"}, true, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit bdecfe6

Please sign in to comment.