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 authored 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{"[email protected]:org/repo.git", "[email protected]:org/repo.git"}, true, false},
{"3", args{"[email protected]:org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
{"4", args{"[email protected]:org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"5", args{"ssh://[email protected]:123/path/to/repo.git", "ssh://[email protected]:123/path/to/REPO.GIT"}, true, false},
{"6", args{"ssh://[email protected]/org/repo.git", "[email protected]:org/repo.git"}, true, false},
{"7", args{"ssh://[email protected]/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
{"8", args{"ssh://[email protected]/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", "[email protected]:org/repo.git"}, true, false},
{"11", args{"https://github.com/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
{"12", args{"https://github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
{"13", args{"[email protected]:123:path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
{"14", args{"[email protected]:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"15", args{"ssh://[email protected]:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
{"16", args{"ssh://[email protected]: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", "[email protected]:123:path/to/repo.git"}, true, false},
{"18", args{"https://host.xz:123/path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
{"5", args{"[email protected]:org/repo.git", "https://github.com/org/repo"}, true, false},
{"6", args{"ssh://[email protected]:123/path/to/repo.git", "ssh://[email protected]:123/path/to/REPO.GIT"}, true, false},
{"7", args{"ssh://[email protected]/org/repo.git", "[email protected]:org/repo.git"}, true, false},
{"8", args{"ssh://[email protected]/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
{"9", args{"ssh://[email protected]/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", "[email protected]:org/repo.git"}, true, false},
{"12", args{"https://github.com/org/repo.git", "ssh://[email protected]/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", "[email protected]:org/repo.git"}, true, false},
{"15", args{"https://github.com/org/repo", "ssh://[email protected]/org/repo.git"}, true, false},
{"16", args{"https://github.com/org/repo", "https://github.com/org/repo.git"}, true, false},
{"17", args{"[email protected]:123:path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
{"18", args{"[email protected]:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
{"19", args{"ssh://[email protected]:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
{"20", args{"ssh://[email protected]: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", "[email protected]:123:path/to/repo.git"}, true, false},
{"22", args{"https://host.xz:123/path/to/repo.git", "ssh://[email protected]: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.