Skip to content

Commit 5ae4318

Browse files
committed
add code.cloudfoundry.org, go.etcd.io and layeh.com/radius mirrors
1 parent 8e81ec5 commit 5ae4318

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

tuple/mirrors.go

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var mirrors = map[string]struct {
2323
"gopkg.in/fsnotify.v1": {source: GH{}, account: "fsnotify", project: "fsnotify"}, // fsnotify is a special case in gopkg.in
2424
"gotest.tools": {source: GH{}, account: "gotestyourself", project: "gotest.tools"},
2525
"howett.net/plist": {source: GL{"https://gitlab.howett.net"}, account: "go", project: "plist"},
26+
"layeh.com/radius": {source: GH{}, account: "layeh", project: "radius"},
2627
"sigs.k8s.io/yaml": {source: GH{}, account: "kubernetes-sigs", project: "yaml"},
2728
}
2829

tuple/vanity.go

+35-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import "regexp"
55
type vanityParser func(string, string) *Tuple
66

77
var vanity = map[string]vanityParser{
8-
"go.mozilla.org": goMozillaOrgParser,
9-
"go.uber.org": goUberOrgParser,
10-
"golang.org": golangOrgParser,
11-
"gopkg.in": gopkgInParser,
12-
"k8s.io": k8sIoParser,
8+
"code.cloudfoundry.org": codeCloudfoundryOrgParser,
9+
"go.etcd.io": goEtcdIoParser,
10+
"go.mozilla.org": goMozillaOrgParser,
11+
"go.uber.org": goUberOrgParser,
12+
"golang.org": golangOrgParser,
13+
"gopkg.in": gopkgInParser,
14+
"k8s.io": k8sIoParser,
1315
}
1416

1517
func tryVanity(pkg, packagePrefix string) (*Tuple, error) {
@@ -21,6 +23,34 @@ func tryVanity(pkg, packagePrefix string) (*Tuple, error) {
2123
return nil, nil
2224
}
2325

26+
// code.cloudfoundry.org/gofileutils -> github.com/cloudfoundry/gofileutils
27+
var codeCloudfoundryOrgRe = regexp.MustCompile(`\Acode\.cloudfoundry\.org/([0-9A-Za-z][-0-9A-Za-z]+)\z`)
28+
29+
func codeCloudfoundryOrgParser(pkg, packagePrefix string) *Tuple {
30+
if !codeCloudfoundryOrgRe.MatchString(pkg) {
31+
return nil
32+
}
33+
sm := codeCloudfoundryOrgRe.FindAllStringSubmatch(pkg, -1)
34+
if len(sm) == 0 {
35+
return nil
36+
}
37+
return newTuple(GH{}, pkg, "cloudfoundry", sm[0][1], packagePrefix)
38+
}
39+
40+
// go.etcd.io/etcd -> github.com/etcd-io/etcd
41+
var goEtcdIoRe = regexp.MustCompile(`\Ago\.etcd\.io/([0-9A-Za-z][-0-9A-Za-z]+)\z`)
42+
43+
func goEtcdIoParser(pkg, packagePrefix string) *Tuple {
44+
if !goEtcdIoRe.MatchString(pkg) {
45+
return nil
46+
}
47+
sm := goEtcdIoRe.FindAllStringSubmatch(pkg, -1)
48+
if len(sm) == 0 {
49+
return nil
50+
}
51+
return newTuple(GH{}, pkg, "etcd-io", sm[0][1], packagePrefix)
52+
}
53+
2454
// go.mozilla.org/gopgagent -> github.com/mozilla-services/gopgagent
2555
var goMozillaOrgRe = regexp.MustCompile(`\Ago\.mozilla\.org/([0-9A-Za-z][-0-9A-Za-z]+)\z`)
2656

tuple/vanity_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ func testExamples(t *testing.T, name string, fn vanityParser, examples [][]strin
1717
}
1818
}
1919

20+
func TestParseCodeCloudfoundryOrg(t *testing.T) {
21+
examples := [][]string{
22+
// name, expected account, expected project
23+
{"code.cloudfoundry.org/gofileutils", "cloudfoundry", "gofileutils"},
24+
}
25+
testExamples(t, "codeCloudfoundryOrgParser", codeCloudfoundryOrgParser, examples)
26+
}
27+
28+
func TestParseGoEtcdIoParser(t *testing.T) {
29+
examples := [][]string{
30+
// name, expected account, expected project
31+
{"go.etcd.io/bbolt", "etcd-io", "bbolt"},
32+
}
33+
testExamples(t, "goEtcdIoParser", goEtcdIoParser, examples)
34+
}
35+
2036
func TestParseGopkgInName(t *testing.T) {
2137
examples := [][]string{
2238
// pkg, expected account, expected project

0 commit comments

Comments
 (0)