diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-12-29 12:34:01 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2025-12-29 13:41:13 +0000 |
| commit | a3b5ade1a4211009e5cc092cccf94458bc9f2b97 (patch) | |
| tree | 5a264f788d245e0c96905afcbf5eed584aa16315 | |
| parent | 1b9f64757a7358e28cc89893899f4016d8d7b223 (diff) | |
pkg/vcs: support git@github.com repos
| -rw-r--r-- | pkg/vcs/vcs.go | 3 | ||||
| -rw-r--r-- | pkg/vcs/vcs_test.go | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index b14fbdcbf..b7197a7d6 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -387,6 +387,9 @@ func link(url, hash, file string, line, typ int) string { if url == "" || hash == "" { return "" } + if colon := strings.IndexByte(url, ':'); colon != -1 && strings.HasPrefix(url, "git@") { + url = "https://" + url[4:colon] + "/" + url[colon+1:] + } switch url { case "https://fuchsia.googlesource.com": // We collect hashes from the fuchsia repo. diff --git a/pkg/vcs/vcs_test.go b/pkg/vcs/vcs_test.go index 01e1fe7f5..7abeba55b 100644 --- a/pkg/vcs/vcs_test.go +++ b/pkg/vcs/vcs_test.go @@ -183,6 +183,11 @@ func TestCommitLink(t *testing.T) { "06690d5c6466b604f674477b522a809673c17eff", "https://git.breakpoint.cc/cgit/fw/net-next.git/commit/?id=06690d5c6466b604f674477b522a809673c17eff", }, + { + "git@github.com:torvalds/linux.git", + "ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1", + "https://github.com/torvalds/linux/commit/ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1", + }, } for _, test := range tests { link := CommitLink(test.URL, test.Hash) @@ -222,6 +227,13 @@ func TestFileLink(t *testing.T) { 42, "https://android.googlesource.com/kernel/common/+/d0c3914ffbe4c00f0a131bae83f811d5606699bc/Makefile#42", }, + { + "git@github.com:torvalds/linux.git", + "ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1", + "Makefile", + 42, + "https://github.com/torvalds/linux/blob/ccd1cdca5cd433c8a5dff78b69a79b31d9b77ee1/Makefile#L42", + }, } for _, test := range tests { link := FileLink(test.URL, test.Hash, test.File, test.Line) |
