Skip to content

Commit d76e025

Browse files
committedJul 28, 2020
internal/source: add sourcehut templates
Add source templates for the sourcehut git hosting site (git.sr.ht). Fixes golang/go#38986. Change-Id: I581389affe3c777828189d8aa35e3910ffe1d130 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/245039 Reviewed-by: Julie Qiu <julie@golang.org>
1 parent 12d438f commit d76e025

File tree

3 files changed

+1402
-864
lines changed

3 files changed

+1402
-864
lines changed
 

‎internal/source/source.go

+9
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,15 @@ var patterns = []struct {
449449
regexp.MustCompile(`^(?P<repo>gitee\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)(\.git|$)`),
450450
githubURLTemplates,
451451
},
452+
{
453+
regexp.MustCompile(`^(?P<repo>git\.sr\.ht/~[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)`),
454+
urlTemplates{
455+
Directory: "{repo}/tree/{commit}/{dir}",
456+
File: "{repo}/tree/{commit}/{file}",
457+
Line: "{repo}/tree/{commit}/{file}#L{line}",
458+
Raw: "{repo}/blob/{commit}/{file}",
459+
},
460+
},
452461
// Patterns that match the general go command pattern, where they must have
453462
// a ".git" repo suffix in an import path. If matching a repo URL from a meta tag,
454463
// there is no ".git".

‎internal/source/source_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ func TestModuleInfo(t *testing.T) {
213213
"https://gitee.com/Billcoding/gotypes/blob/v0.1.0/type.go#L1",
214214
"https://gitee.com/Billcoding/gotypes/raw/v0.1.0/type.go",
215215
},
216+
{
217+
"sourcehut",
218+
"gioui.org", "v0.0.0-20200726090130-3b95e2918359", "op/op.go",
219+
220+
"https://git.sr.ht/~eliasnaur/gio",
221+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359",
222+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/op/op.go",
223+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/op/op.go#L1",
224+
"https://git.sr.ht/~eliasnaur/gio/blob/3b95e2918359/op/op.go",
225+
},
226+
{
227+
"sourcehut nested",
228+
"gioui.org/app", "v0.0.0-20200726090130-3b95e2918359", "app.go",
229+
230+
"https://git.sr.ht/~eliasnaur/gio",
231+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app",
232+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app/app.go",
233+
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app/app.go#L1",
234+
"https://git.sr.ht/~eliasnaur/gio/blob/3b95e2918359/app/app.go",
235+
},
216236
{
217237
"v2 as a branch",
218238
"github.com/jrick/wsrpc/v2", "v2.1.1", "rpc.go",

‎internal/source/testdata/TestModuleInfo.replay

+1,373-864
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.