Skip to content

Commit 4120904

Browse files
xiaoliwangpull[bot]
authored andcommitted
cmd/go/internal/vcs: replace [A-Za-z0-9_] with \w in regexps
Change-Id: Ibcc7dbb528585b019ff1b743792a52f43a4c2233 GitHub-Last-Rev: e907fb0 GitHub-Pull-Request: #54882 Reviewed-on: https://go-review.googlesource.com/c/go/+/428535 Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent f8ba6aa commit 4120904

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/cmd/go/internal/vcs/vcs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ var vcsGit = &Cmd{
253253

254254
// scpSyntaxRe matches the SCP-like addresses used by Git to access
255255
// repositories by SSH.
256-
var scpSyntaxRe = lazyregexp.New(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
256+
var scpSyntaxRe = lazyregexp.New(`^(\w+)@([\w.-]+):(.*)$`)
257257

258258
func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) {
259259
cmd := "config remote.origin.url"
@@ -1438,7 +1438,7 @@ var vcsPaths = []*vcsPath{
14381438
// GitHub
14391439
{
14401440
pathPrefix: "github.com",
1441-
regexp: lazyregexp.New(`^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`),
1441+
regexp: lazyregexp.New(`^(?P<root>github\.com/[\w.\-]+/[\w.\-]+)(/[\w.\-]+)*$`),
14421442
vcs: "git",
14431443
repo: "https://{root}",
14441444
check: noVCSSuffix,
@@ -1447,7 +1447,7 @@ var vcsPaths = []*vcsPath{
14471447
// Bitbucket
14481448
{
14491449
pathPrefix: "bitbucket.org",
1450-
regexp: lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
1450+
regexp: lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[\w.\-]+/[\w.\-]+))(/[\w.\-]+)*$`),
14511451
vcs: "git",
14521452
repo: "https://{root}",
14531453
check: noVCSSuffix,
@@ -1456,7 +1456,7 @@ var vcsPaths = []*vcsPath{
14561456
// IBM DevOps Services (JazzHub)
14571457
{
14581458
pathPrefix: "hub.jazz.net/git",
1459-
regexp: lazyregexp.New(`^(?P<root>hub\.jazz\.net/git/[a-z0-9]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`),
1459+
regexp: lazyregexp.New(`^(?P<root>hub\.jazz\.net/git/[a-z0-9]+/[\w.\-]+)(/[\w.\-]+)*$`),
14601460
vcs: "git",
14611461
repo: "https://{root}",
14621462
check: noVCSSuffix,
@@ -1465,31 +1465,31 @@ var vcsPaths = []*vcsPath{
14651465
// Git at Apache
14661466
{
14671467
pathPrefix: "git.apache.org",
1468-
regexp: lazyregexp.New(`^(?P<root>git\.apache\.org/[a-z0-9_.\-]+\.git)(/[A-Za-z0-9_.\-]+)*$`),
1468+
regexp: lazyregexp.New(`^(?P<root>git\.apache\.org/[a-z0-9_.\-]+\.git)(/[\w.\-]+)*$`),
14691469
vcs: "git",
14701470
repo: "https://{root}",
14711471
},
14721472

14731473
// Git at OpenStack
14741474
{
14751475
pathPrefix: "git.openstack.org",
1476-
regexp: lazyregexp.New(`^(?P<root>git\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/[A-Za-z0-9_.\-]+)*$`),
1476+
regexp: lazyregexp.New(`^(?P<root>git\.openstack\.org/[\w.\-]+/[\w.\-]+)(\.git)?(/[\w.\-]+)*$`),
14771477
vcs: "git",
14781478
repo: "https://{root}",
14791479
},
14801480

14811481
// chiselapp.com for fossil
14821482
{
14831483
pathPrefix: "chiselapp.com",
1484-
regexp: lazyregexp.New(`^(?P<root>chiselapp\.com/user/[A-Za-z0-9]+/repository/[A-Za-z0-9_.\-]+)$`),
1484+
regexp: lazyregexp.New(`^(?P<root>chiselapp\.com/user/[A-Za-z0-9]+/repository/[\w.\-]+)$`),
14851485
vcs: "fossil",
14861486
repo: "https://{root}",
14871487
},
14881488

14891489
// General syntax for any server.
14901490
// Must be last.
14911491
{
1492-
regexp: lazyregexp.New(`(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\-]+)+?)\.(?P<vcs>bzr|fossil|git|hg|svn))(/~?[A-Za-z0-9_.\-]+)*$`),
1492+
regexp: lazyregexp.New(`(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[\w.\-]+)+?)\.(?P<vcs>bzr|fossil|git|hg|svn))(/~?[\w.\-]+)*$`),
14931493
schemelessRepo: true,
14941494
},
14951495
}
@@ -1502,7 +1502,7 @@ var vcsPathsAfterDynamic = []*vcsPath{
15021502
// Launchpad. See golang.org/issue/11436.
15031503
{
15041504
pathPrefix: "launchpad.net",
1505-
regexp: lazyregexp.New(`^(?P<root>launchpad\.net/((?P<project>[A-Za-z0-9_.\-]+)(?P<series>/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
1505+
regexp: lazyregexp.New(`^(?P<root>launchpad\.net/((?P<project>[\w.\-]+)(?P<series>/[\w.\-]+)?|~[\w.\-]+/(\+junk|[\w.\-]+)/[\w.\-]+))(/[\w.\-]+)*$`),
15061506
vcs: "bzr",
15071507
repo: "https://{root}",
15081508
check: launchpadVCS,

0 commit comments

Comments
 (0)