]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/vcs: replace [A-Za-z0-9_] with \w in regexps
authorjiepeng <jiepengthegreat@126.com>
Wed, 7 Sep 2022 02:59:46 +0000 (02:59 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 14 Sep 2022 11:32:35 +0000 (11:32 +0000)
Change-Id: Ibcc7dbb528585b019ff1b743792a52f43a4c2233
GitHub-Last-Rev: e907fb00e3202ce394750542084569058b7d960e
GitHub-Pull-Request: golang/go#54882
Reviewed-on: https://go-review.googlesource.com/c/go/+/428535
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

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

index 4f16bef90ce2fad21912198330b318c826badf3f..9ea8eb2bad4cfd8b9a96e2ece5fd6003764ff5fb 100644 (file)
@@ -253,7 +253,7 @@ var vcsGit = &Cmd{
 
 // scpSyntaxRe matches the SCP-like addresses used by Git to access
 // repositories by SSH.
-var scpSyntaxRe = lazyregexp.New(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
+var scpSyntaxRe = lazyregexp.New(`^(\w+)@([\w.-]+):(.*)$`)
 
 func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) {
        cmd := "config remote.origin.url"
@@ -1438,7 +1438,7 @@ var vcsPaths = []*vcsPath{
        // GitHub
        {
                pathPrefix: "github.com",
-               regexp:     lazyregexp.New(`^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>github\.com/[\w.\-]+/[\w.\-]+)(/[\w.\-]+)*$`),
                vcs:        "git",
                repo:       "https://{root}",
                check:      noVCSSuffix,
@@ -1447,7 +1447,7 @@ var vcsPaths = []*vcsPath{
        // Bitbucket
        {
                pathPrefix: "bitbucket.org",
-               regexp:     lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>bitbucket\.org/(?P<bitname>[\w.\-]+/[\w.\-]+))(/[\w.\-]+)*$`),
                vcs:        "git",
                repo:       "https://{root}",
                check:      noVCSSuffix,
@@ -1456,7 +1456,7 @@ var vcsPaths = []*vcsPath{
        // IBM DevOps Services (JazzHub)
        {
                pathPrefix: "hub.jazz.net/git",
-               regexp:     lazyregexp.New(`^(?P<root>hub\.jazz\.net/git/[a-z0-9]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>hub\.jazz\.net/git/[a-z0-9]+/[\w.\-]+)(/[\w.\-]+)*$`),
                vcs:        "git",
                repo:       "https://{root}",
                check:      noVCSSuffix,
@@ -1465,7 +1465,7 @@ var vcsPaths = []*vcsPath{
        // Git at Apache
        {
                pathPrefix: "git.apache.org",
-               regexp:     lazyregexp.New(`^(?P<root>git\.apache\.org/[a-z0-9_.\-]+\.git)(/[A-Za-z0-9_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>git\.apache\.org/[a-z0-9_.\-]+\.git)(/[\w.\-]+)*$`),
                vcs:        "git",
                repo:       "https://{root}",
        },
@@ -1473,7 +1473,7 @@ var vcsPaths = []*vcsPath{
        // Git at OpenStack
        {
                pathPrefix: "git.openstack.org",
-               regexp:     lazyregexp.New(`^(?P<root>git\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/[A-Za-z0-9_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>git\.openstack\.org/[\w.\-]+/[\w.\-]+)(\.git)?(/[\w.\-]+)*$`),
                vcs:        "git",
                repo:       "https://{root}",
        },
@@ -1481,7 +1481,7 @@ var vcsPaths = []*vcsPath{
        // chiselapp.com for fossil
        {
                pathPrefix: "chiselapp.com",
-               regexp:     lazyregexp.New(`^(?P<root>chiselapp\.com/user/[A-Za-z0-9]+/repository/[A-Za-z0-9_.\-]+)$`),
+               regexp:     lazyregexp.New(`^(?P<root>chiselapp\.com/user/[A-Za-z0-9]+/repository/[\w.\-]+)$`),
                vcs:        "fossil",
                repo:       "https://{root}",
        },
@@ -1489,7 +1489,7 @@ var vcsPaths = []*vcsPath{
        // General syntax for any server.
        // Must be last.
        {
-               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_.\-]+)*$`),
+               regexp:         lazyregexp.New(`(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[\w.\-]+)+?)\.(?P<vcs>bzr|fossil|git|hg|svn))(/~?[\w.\-]+)*$`),
                schemelessRepo: true,
        },
 }
@@ -1502,7 +1502,7 @@ var vcsPathsAfterDynamic = []*vcsPath{
        // Launchpad. See golang.org/issue/11436.
        {
                pathPrefix: "launchpad.net",
-               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_.\-]+)*$`),
+               regexp:     lazyregexp.New(`^(?P<root>launchpad\.net/((?P<project>[\w.\-]+)(?P<series>/[\w.\-]+)?|~[\w.\-]+/(\+junk|[\w.\-]+)/[\w.\-]+))(/[\w.\-]+)*$`),
                vcs:        "bzr",
                repo:       "https://{root}",
                check:      launchpadVCS,