Skip to content

Commit 8c0a543

Browse files
authored
Merge pull request #10 from t6/patch-mvdan.cc
Add mvdan.cc mirror
2 parents 5ae4318 + 090c745 commit 8c0a543

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tuple/vanity.go

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var vanity = map[string]vanityParser{
1212
"golang.org": golangOrgParser,
1313
"gopkg.in": gopkgInParser,
1414
"k8s.io": k8sIoParser,
15+
"mvdan.cc": mvdanCcParser,
1516
}
1617

1718
func tryVanity(pkg, packagePrefix string) (*Tuple, error) {
@@ -124,3 +125,17 @@ func k8sIoParser(pkg, packagePrefix string) *Tuple {
124125
}
125126
return newTuple(GH{}, pkg, "kubernetes", sm[0][1], packagePrefix)
126127
}
128+
129+
// mvdan.cc/editorconfig -> github.com/mvdan/editconfig
130+
var mvdanCcRe = regexp.MustCompile(`\Amvdan\.cc/([0-9A-Za-z][-0-9A-Za-z]+)\z`)
131+
132+
func mvdanCcParser(pkg, packagePrefix string) *Tuple {
133+
if !mvdanCcRe.MatchString(pkg) {
134+
return nil
135+
}
136+
sm := mvdanCcRe.FindAllStringSubmatch(pkg, -1)
137+
if len(sm) == 0 {
138+
return nil
139+
}
140+
return newTuple(GH{}, pkg, "mvdan", sm[0][1], packagePrefix)
141+
}

tuple/vanity_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,11 @@ func TestParseGoMozillaOrgName(t *testing.T) {
7676
}
7777
testExamples(t, "goMozillaOrgParser", goMozillaOrgParser, examples)
7878
}
79+
80+
func TestParseMvdanCcName(t *testing.T) {
81+
examples := [][]string{
82+
// name, expected account, expected project
83+
{"mvdan.cc/editorconfig", "mvdan", "editorconfig"},
84+
}
85+
testExamples(t, "mvdanCcParser", mvdanCcParser, examples)
86+
}

0 commit comments

Comments
 (0)