Skip to content

Commit bdecfe6

Browse files
authored
Merge pull request #19 from utilitywarehouse/as-fix-bug
https url might not have .git suffix
2 parents f4d4ee6 + f4abf56 commit bdecfe6

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

Diff for: pkg/giturl/git_url.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func Parse(rawURL string) (*URL, error) {
104104
func SameURL(lURL, rURL *URL) bool {
105105
return lURL.Host == rURL.Host &&
106106
lURL.Path == rURL.Path &&
107-
lURL.Repo == rURL.Repo
107+
(lURL.Repo == rURL.Repo ||
108+
strings.TrimSuffix(lURL.Repo, ".git") == strings.TrimSuffix(rURL.Repo, ".git"))
108109
}
109110

110111
// SameRawURL returns whether or not the two remote URL strings are equivalent

Diff for: pkg/giturl/git_url_test.go

+18-14
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,24 @@ func TestSameRawURL(t *testing.T) {
125125
{"2", args{"[email protected]:org/repo.git", "[email protected]:org/repo.git"}, true, false},
126126
{"3", args{"[email protected]:org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
127127
{"4", args{"[email protected]:org/repo.git", "https://github.com/org/repo.git"}, true, false},
128-
{"5", args{"ssh://[email protected]:123/path/to/repo.git", "ssh://[email protected]:123/path/to/REPO.GIT"}, true, false},
129-
{"6", args{"ssh://[email protected]/org/repo.git", "[email protected]:org/repo.git"}, true, false},
130-
{"7", args{"ssh://[email protected]/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
131-
{"8", args{"ssh://[email protected]/org/repo.git", "https://github.com/org/repo.git"}, true, false},
132-
{"9", args{"https://host.xz:345/path/to/repo.git", "HTTPS://HOST.XZ:345/path/to/repo.git"}, true, false},
133-
{"10", args{"https://github.com/org/repo.git", "[email protected]:org/repo.git"}, true, false},
134-
{"11", args{"https://github.com/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
135-
{"12", args{"https://github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
136-
{"13", args{"[email protected]:123:path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
137-
{"14", args{"[email protected]:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
138-
{"15", args{"ssh://[email protected]:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
139-
{"16", args{"ssh://[email protected]:123/path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
140-
{"17", args{"https://host.xz:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
141-
{"18", args{"https://host.xz:123/path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
128+
{"5", args{"[email protected]:org/repo.git", "https://github.com/org/repo"}, true, false},
129+
{"6", args{"ssh://[email protected]:123/path/to/repo.git", "ssh://[email protected]:123/path/to/REPO.GIT"}, true, false},
130+
{"7", args{"ssh://[email protected]/org/repo.git", "[email protected]:org/repo.git"}, true, false},
131+
{"8", args{"ssh://[email protected]/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
132+
{"9", args{"ssh://[email protected]/org/repo.git", "https://github.com/org/repo.git"}, true, false},
133+
{"10", args{"https://host.xz:345/path/to/repo.git", "HTTPS://HOST.XZ:345/path/to/repo.git"}, true, false},
134+
{"11", args{"https://github.com/org/repo.git", "[email protected]:org/repo.git"}, true, false},
135+
{"12", args{"https://github.com/org/repo.git", "ssh://[email protected]/org/repo.git"}, true, false},
136+
{"13", args{"https://github.com/org/repo.git", "https://github.com/org/repo.git"}, true, false},
137+
{"14", args{"https://github.com/org/repo", "[email protected]:org/repo.git"}, true, false},
138+
{"15", args{"https://github.com/org/repo", "ssh://[email protected]/org/repo.git"}, true, false},
139+
{"16", args{"https://github.com/org/repo", "https://github.com/org/repo.git"}, true, false},
140+
{"17", args{"[email protected]:123:path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
141+
{"18", args{"[email protected]:123:path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
142+
{"19", args{"ssh://[email protected]:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
143+
{"20", args{"ssh://[email protected]:123/path/to/repo.git", "https://host.xz:123/path/to/repo.git"}, true, false},
144+
{"21", args{"https://host.xz:123/path/to/repo.git", "[email protected]:123:path/to/repo.git"}, true, false},
145+
{"22", args{"https://host.xz:123/path/to/repo.git", "ssh://[email protected]:123/path/to/repo.git"}, true, false},
142146
}
143147
for _, tt := range tests {
144148
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)