]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/get: allow go get on github.com/ import paths with Unicode letters
authorDmitri Shuralyov <shurcooL@gmail.com>
Wed, 26 Apr 2017 23:07:15 +0000 (19:07 -0400)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 28 Apr 2017 15:32:18 +0000 (15:32 +0000)
More specifically, allow Unicode letters in the directories of GitHub
repositories, which can occur and don't have a valid reason to be
disallowed by go get.

Do so by using a predefined character class, the Unicode character
property class \p{L} that describes the Unicode characters that are
letters:

http://www.regular-expressions.info/unicode.html#category

Since it's not possible to create GitHub usernames or repositories
containing Unicode letters at this time, those parts of the import path
are still restricted to ASCII letters only.

Fix name of tested func in t.Errorf messages.

Fixes #18660.

Change-Id: Ia0ef4742bfd8317d989ef1eb1d7065e382852fe2
Reviewed-on: https://go-review.googlesource.com/41822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/get/vcs.go
src/cmd/go/internal/get/vcs_test.go

index 7439cc8649aea667e0d91990973b46c3e1d2b501..c72d52bc1b3f82e2c1e0ee7d99954a84f67b5efe 100644 (file)
@@ -851,7 +851,7 @@ var vcsPaths = []*vcsPath{
        // Github
        {
                prefix: "github.com/",
-               re:     `^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`,
+               re:     `^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`,
                vcs:    "git",
                repo:   "https://{root}",
                check:  noVCSSuffix,
index f858ee9ddc6f1c56f34a986b26b0f65e4b380839..62d352ae575eef8bb01f12d5184e8a2377694205 100644 (file)
@@ -32,6 +32,14 @@ func TestRepoRootForImportPath(t *testing.T) {
                                repo: "https://github.com/golang/groupcache",
                        },
                },
+               // Unicode letters in directories (issue 18660).
+               {
+                       "github.com/user/unicode/испытание",
+                       &repoRoot{
+                               vcs:  vcsGit,
+                               repo: "https://github.com/user/unicode",
+                       },
+               },
                // IBM DevOps Services tests
                {
                        "hub.jazz.net/git/user1/pkgname",
@@ -154,16 +162,16 @@ func TestRepoRootForImportPath(t *testing.T) {
 
                if want == nil {
                        if err == nil {
-                               t.Errorf("RepoRootForImport(%q): Error expected but not received", test.path)
+                               t.Errorf("repoRootForImportPath(%q): Error expected but not received", test.path)
                        }
                        continue
                }
                if err != nil {
-                       t.Errorf("RepoRootForImport(%q): %v", test.path, err)
+                       t.Errorf("repoRootForImportPath(%q): %v", test.path, err)
                        continue
                }
                if got.vcs.name != want.vcs.name || got.repo != want.repo {
-                       t.Errorf("RepoRootForImport(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.vcs, got.repo, want.vcs, want.repo)
+                       t.Errorf("repoRootForImportPath(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.vcs, got.repo, want.vcs, want.repo)
                }
        }
 }