]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: clean internal/vcs slightly
authorRuss Cox <rsc@golang.org>
Wed, 16 Aug 2023 14:39:34 +0000 (10:39 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 16 Aug 2023 16:01:58 +0000 (16:01 +0000)
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 <matloob@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

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

index c65dd0f624a1b65476899348f40e3cacf35c3a6c..26a8f4b370b612fb96f1c34c2a4f1e2a4813a167 100644 (file)
@@ -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
        }