From: Russ Cox Date: Wed, 16 Aug 2023 14:39:34 +0000 (-0400) Subject: cmd/go: clean internal/vcs slightly X-Git-Tag: go1.22rc1~1271 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d7549821a0136593e9872e9c50c45c8ce038704b;p=gostls13.git cmd/go: clean internal/vcs slightly Delete CheckNested, which was for GOPATH get. Unexport CheckGOVCS, which was only exported for GOPATH get. Change-Id: I6d3f772bfea70f4a3ec197d48b74c3d6d58bcdce Reviewed-on: https://go-review.googlesource.com/c/go/+/520037 Reviewed-by: Michael Matloob Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Auto-Submit: Russ Cox --- diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index c65dd0f624..26a8f4b370 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -1015,11 +1015,11 @@ var defaultGOVCS = govcsConfig{ {"public", []string{"git", "hg"}}, } -// CheckGOVCS checks whether the policy defined by the environment variable +// checkGOVCS checks whether the policy defined by the environment variable // GOVCS allows the given vcs command to be used with the given repository // root path. Note that root may not be a real package or module path; it's // the same as the root path in the go-import meta tag. -func CheckGOVCS(vcs *Cmd, root string) error { +func checkGOVCS(vcs *Cmd, root string) error { if vcs == vcsMod { // Direct module (proxy protocol) fetches don't // involve an external version control system @@ -1047,37 +1047,6 @@ func CheckGOVCS(vcs *Cmd, root string) error { return nil } -// CheckNested checks for an incorrectly-nested VCS-inside-VCS -// situation for dir, checking parents up until srcRoot. -func CheckNested(vcs *Cmd, dir, srcRoot string) error { - if len(dir) <= len(srcRoot) || dir[len(srcRoot)] != filepath.Separator { - return fmt.Errorf("directory %q is outside source root %q", dir, srcRoot) - } - - otherDir := dir - for len(otherDir) > len(srcRoot) { - for _, otherVCS := range vcsList { - if isVCSRoot(otherDir, otherVCS.RootNames) { - // Allow expected vcs in original dir. - if otherDir == dir && otherVCS == vcs { - continue - } - // Otherwise, we have one VCS inside a different VCS. - return fmt.Errorf("directory %q uses %s, but parent %q uses %s", dir, vcs.Cmd, otherDir, otherVCS.Cmd) - } - } - // Move to parent. - newDir := filepath.Dir(otherDir) - if len(newDir) >= len(otherDir) { - // Shouldn't happen, but just in case, stop. - break - } - otherDir = newDir - } - - return nil -} - // RepoRoot describes the repository root for a tree of source code. type RepoRoot struct { Repo string // repository URL, including scheme @@ -1193,7 +1162,7 @@ func repoRootFromVCSPaths(importPath string, security web.SecurityMode, vcsPaths if vcs == nil { return nil, fmt.Errorf("unknown version control system %q", match["vcs"]) } - if err := CheckGOVCS(vcs, match["root"]); err != nil { + if err := checkGOVCS(vcs, match["root"]); err != nil { return nil, err } var repoURL string @@ -1369,7 +1338,7 @@ func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.Se } } - if err := CheckGOVCS(vcs, mmi.Prefix); err != nil { + if err := checkGOVCS(vcs, mmi.Prefix); err != nil { return nil, err }