From 2382e3994d48b1d22acc2c86bcad0a2aff028e32 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Thu, 27 Apr 2017 19:18:25 -0400 Subject: [PATCH] go/vcs: allow go get on github.com/ import paths with Unicode letters Manually apply same change as CL 41822 did for cmd/go/internal/get, but for golang.org/x/tools/go/vcs, to help keep them in sync. Updates golang/go#18660. Helps golang/go#11490. Change-Id: I6c7759c073583dea771bc438b70f8c2eb7b5ebfb Reviewed-on: https://go-review.googlesource.com/42017 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- go/vcs/vcs.go | 2 +- go/vcs/vcs_test.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go/vcs/vcs.go b/go/vcs/vcs.go index 7a113910..3c56a950 100644 --- a/go/vcs/vcs.go +++ b/go/vcs/vcs.go @@ -602,7 +602,7 @@ var vcsPaths = []*vcsPath{ // Github { prefix: "github.com/", - re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, + re: `^(?Pgithub\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`, vcs: "git", repo: "https://{root}", check: noVCSSuffix, diff --git a/go/vcs/vcs_test.go b/go/vcs/vcs_test.go index 5817ded1..8f36cac7 100644 --- a/go/vcs/vcs_test.go +++ b/go/vcs/vcs_test.go @@ -33,17 +33,25 @@ 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", + }, + }, } for _, test := range tests { got, err := RepoRootForImportPath(test.path, false) if err != nil { - t.Errorf("RepoRootForImport(%q): %v", test.path, err) + t.Errorf("RepoRootForImportPath(%q): %v", test.path, err) continue } want := test.want 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) } } }