Skip to content

Commit

Permalink
internal/source: add sourcehut templates
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jba committed Jul 28, 2020
1 parent 12d438f commit d76e025
Show file tree
Hide file tree
Showing 3 changed files with 1,402 additions and 864 deletions.
9 changes: 9 additions & 0 deletions internal/source/source.go
Expand Up @@ -449,6 +449,15 @@ var patterns = []struct {
regexp.MustCompile(`^(?P<repo>gitee\.com/[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)(\.git|$)`),
githubURLTemplates,
},
{
regexp.MustCompile(`^(?P<repo>git\.sr\.ht/~[a-z0-9A-Z_.\-]+/[a-z0-9A-Z_.\-]+)`),
urlTemplates{
Directory: "{repo}/tree/{commit}/{dir}",
File: "{repo}/tree/{commit}/{file}",
Line: "{repo}/tree/{commit}/{file}#L{line}",
Raw: "{repo}/blob/{commit}/{file}",
},
},
// Patterns that match the general go command pattern, where they must have
// a ".git" repo suffix in an import path. If matching a repo URL from a meta tag,
// there is no ".git".
Expand Down
20 changes: 20 additions & 0 deletions internal/source/source_test.go
Expand Up @@ -213,6 +213,26 @@ func TestModuleInfo(t *testing.T) {
"https://gitee.com/Billcoding/gotypes/blob/v0.1.0/type.go#L1",
"https://gitee.com/Billcoding/gotypes/raw/v0.1.0/type.go",
},
{
"sourcehut",
"gioui.org", "v0.0.0-20200726090130-3b95e2918359", "op/op.go",

"https://git.sr.ht/~eliasnaur/gio",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/op/op.go",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/op/op.go#L1",
"https://git.sr.ht/~eliasnaur/gio/blob/3b95e2918359/op/op.go",
},
{
"sourcehut nested",
"gioui.org/app", "v0.0.0-20200726090130-3b95e2918359", "app.go",

"https://git.sr.ht/~eliasnaur/gio",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app/app.go",
"https://git.sr.ht/~eliasnaur/gio/tree/3b95e2918359/app/app.go#L1",
"https://git.sr.ht/~eliasnaur/gio/blob/3b95e2918359/app/app.go",
},
{
"v2 as a branch",
"github.com/jrick/wsrpc/v2", "v2.1.1", "rpc.go",
Expand Down

0 comments on commit d76e025

Please sign in to comment.