Skip to content

Commit a3b5ade

Browse files
committed
pkg/vcs: support git@github.com repos
1 parent 1b9f647 commit a3b5ade

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pkg/vcs/vcs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ func link(url, hash, file string, line, typ int) string {
387387
if url == "" || hash == "" {
388388
return ""
389389
}
390+
if colon := strings.IndexByte(url, ':'); colon != -1 && strings.HasPrefix(url, "git@") {
391+
url = "https://" + url[4:colon] + "/" + url[colon+1:]
392+
}
390393
switch url {
391394
case "https://fuchsia.googlesource.com":
392395
// We collect hashes from the fuchsia repo.

pkg/vcs/vcs_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ func TestCommitLink(t *testing.T) {
183183
"06690d5c6466b604f674477b522a809673c17eff",
184184
"https://git.breakpoint.cc/cgit/fw/net-next.git/commit/?id=06690d5c6466b604f674477b522a809673c17eff",
185185
},
186+
{
187+
"git@github.com:torvalds/linux.git",
188+
"ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1",
189+
"https://github.com/torvalds/linux/commit/ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1",
190+
},
186191
}
187192
for _, test := range tests {
188193
link := CommitLink(test.URL, test.Hash)
@@ -222,6 +227,13 @@ func TestFileLink(t *testing.T) {
222227
42,
223228
"https://android.googlesource.com/kernel/common/+/d0c3914ffbe4c00f0a131bae83f811d5606699bc/Makefile#42",
224229
},
230+
{
231+
"git@github.com:torvalds/linux.git",
232+
"ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1",
233+
"Makefile",
234+
42,
235+
"https://github.com/torvalds/linux/blob/ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1/Makefile#L42",
236+
},
225237
}
226238
for _, test := range tests {
227239
link := FileLink(test.URL, test.Hash, test.File, test.Line)

0 commit comments

Comments
 (0)