diff --git a/pkg/giturl/git_url.go b/pkg/giturl/git_url.go index ddb328a..3af0668 100644 --- a/pkg/giturl/git_url.go +++ b/pkg/giturl/git_url.go @@ -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 diff --git a/pkg/giturl/git_url_test.go b/pkg/giturl/git_url_test.go index f34f3da..aba96ac 100644 --- a/pkg/giturl/git_url_test.go +++ b/pkg/giturl/git_url_test.go @@ -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) {