// cmd/go: custom import path checking should not apply to github.com/xxx/yyy.
func TestIssue10952(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
-
if _, err := exec.LookPath("git"); err != nil {
t.Skip("skipping because git binary not found")
}
tg.run("get", "-d", "-u", importPath)
}
+func TestGetGitDefaultBranch(t *testing.T) {
+ testenv.MustHaveExternalNetwork(t)
+ if _, err := exec.LookPath("git"); err != nil {
+ t.Skip("skipping because git binary not found")
+ }
+
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempDir("src")
+ tg.setenv("GOPATH", tg.path("."))
+
+ // This repo has two branches, master and another-branch.
+ // The another-branch is the default that you get from 'git clone'.
+ // The go get command variants should not override this.
+ const importPath = "github.com/rsc/go-get-default-branch"
+
+ tg.run("get", "-d", importPath)
+ repoDir := tg.path("src/" + importPath)
+ defer tg.resetReadOnlyFlagAll(repoDir)
+ tg.runGit(repoDir, "branch", "--contains", "HEAD")
+ tg.grepStdout(`\* another-branch`, "not on correct default branch")
+
+ tg.run("get", "-d", "-u", importPath)
+ tg.runGit(repoDir, "branch", "--contains", "HEAD")
+ tg.grepStdout(`\* another-branch`, "not on correct default branch")
+}
+
func TestDisallowedCSourceFiles(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
func TestIssue10193(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
+ if _, err := exec.LookPath("hg"); err != nil {
+ t.Skip("skipping because hg binary not found")
+ }
tg := testgo(t)
defer tg.cleanup()
// both createCmd and downloadCmd update the working dir.
// No need to do more here. We used to 'checkout master'
// but that doesn't work if the default branch is not named master.
+ // DO NOT add 'checkout master' here.
// See golang.org/issue/9032.
- tagSyncDefault: []string{"checkout master", "submodule update --init --recursive"},
+ tagSyncDefault: []string{"submodule update --init --recursive"},
scheme: []string{"git", "https", "http", "git+ssh", "ssh"},
pingCmd: "ls-remote {scheme}://{repo}",
// download downloads any new changes for the repo in dir.
func (v *vcsCmd) download(dir string) error {
- if err := v.fixDetachedHead(dir); err != nil {
- return err
- }
for _, cmd := range v.downloadCmd {
if !go15VendorExperiment && strings.Contains(cmd, "submodule") {
continue
return nil
}
-// fixDetachedHead switches a Git repository in dir from a detached head to the master branch.
-// Go versions before 1.2 downloaded Git repositories in an unfortunate way
-// that resulted in the working tree state being on a detached head.
-// That meant the repository was not usable for normal Git operations.
-// Go 1.2 fixed that, but we can't pull into a detached head, so if this is
-// a Git repository we check for being on a detached head and switch to the
-// real branch, almost always called "master".
-// TODO(dsymonds): Consider removing this for Go 1.3.
-func (v *vcsCmd) fixDetachedHead(dir string) error {
- if v != vcsGit {
- return nil
- }
-
- // "git symbolic-ref HEAD" succeeds iff we are not on a detached head.
- if err := v.runVerboseOnly(dir, "symbolic-ref HEAD"); err == nil {
- // not on a detached head
- return nil
- }
- if buildV {
- log.Printf("%s on detached head; repairing", dir)
- }
- return v.run(dir, "checkout master")
-}
-
// tags returns the list of available tags for the repo in dir.
func (v *vcsCmd) tags(dir string) ([]string, error) {
var tags []string