+33
-29
lines changedFilter options
+33
-29
lines changed Original file line number Diff line number Diff line change
@@ -1063,7 +1063,6 @@ func TestImportCommentConflict(t *testing.T) {
1063
1063
// cmd/go: custom import path checking should not apply to github.com/xxx/yyy.
1064
1064
func TestIssue10952(t *testing.T) {
1065
1065
testenv.MustHaveExternalNetwork(t)
1066
-
1067
1066
if _, err := exec.LookPath("git"); err != nil {
1068
1067
t.Skip("skipping because git binary not found")
1069
1068
}
@@ -1081,6 +1080,34 @@ func TestIssue10952(t *testing.T) {
1081
1080
tg.run("get", "-d", "-u", importPath)
1082
1081
}
1083
1082
1083
+
func TestGetGitDefaultBranch(t *testing.T) {
1084
+
testenv.MustHaveExternalNetwork(t)
1085
+
if _, err := exec.LookPath("git"); err != nil {
1086
+
t.Skip("skipping because git binary not found")
1087
+
}
1088
+
1089
+
tg := testgo(t)
1090
+
defer tg.cleanup()
1091
+
tg.parallel()
1092
+
tg.tempDir("src")
1093
+
tg.setenv("GOPATH", tg.path("."))
1094
+
1095
+
// This repo has two branches, master and another-branch.
1096
+
// The another-branch is the default that you get from 'git clone'.
1097
+
// The go get command variants should not override this.
1098
+
const importPath = "github.com/rsc/go-get-default-branch"
1099
+
1100
+
tg.run("get", "-d", importPath)
1101
+
repoDir := tg.path("src/" + importPath)
1102
+
defer tg.resetReadOnlyFlagAll(repoDir)
1103
+
tg.runGit(repoDir, "branch", "--contains", "HEAD")
1104
+
tg.grepStdout(`\* another-branch`, "not on correct default branch")
1105
+
1106
+
tg.run("get", "-d", "-u", importPath)
1107
+
tg.runGit(repoDir, "branch", "--contains", "HEAD")
1108
+
tg.grepStdout(`\* another-branch`, "not on correct default branch")
1109
+
}
1110
+
1084
1111
func TestDisallowedCSourceFiles(t *testing.T) {
1085
1112
tg := testgo(t)
1086
1113
defer tg.cleanup()
@@ -2219,6 +2246,9 @@ func TestGoGetInsecureCustomDomain(t *testing.T) {
2219
2246
2220
2247
func TestIssue10193(t *testing.T) {
2221
2248
testenv.MustHaveExternalNetwork(t)
2249
+
if _, err := exec.LookPath("hg"); err != nil {
2250
+
t.Skip("skipping because hg binary not found")
2251
+
}
2222
2252
2223
2253
tg := testgo(t)
2224
2254
defer tg.cleanup()
Original file line number Diff line number Diff line change
@@ -137,8 +137,9 @@ var vcsGit = &vcsCmd{
137
137
// both createCmd and downloadCmd update the working dir.
138
138
// No need to do more here. We used to 'checkout master'
139
139
// but that doesn't work if the default branch is not named master.
140
+
// DO NOT add 'checkout master' here.
140
141
// See golang.org/issue/9032.
141
-
tagSyncDefault: []string{"checkout master", "submodule update --init --recursive"},
142
+
tagSyncDefault: []string{"submodule update --init --recursive"},
142
143
143
144
scheme: []string{"git", "https", "http", "git+ssh", "ssh"},
144
145
pingCmd: "ls-remote {scheme}://{repo}",
@@ -385,9 +386,6 @@ func (v *vcsCmd) create(dir, repo string) error {
385
386
386
387
// download downloads any new changes for the repo in dir.
387
388
func (v *vcsCmd) download(dir string) error {
388
-
if err := v.fixDetachedHead(dir); err != nil {
389
-
return err
390
-
}
391
389
for _, cmd := range v.downloadCmd {
392
390
if !go15VendorExperiment && strings.Contains(cmd, "submodule") {
393
391
continue
@@ -399,30 +397,6 @@ func (v *vcsCmd) download(dir string) error {
399
397
return nil
400
398
}
401
399
402
-
// fixDetachedHead switches a Git repository in dir from a detached head to the master branch.
403
-
// Go versions before 1.2 downloaded Git repositories in an unfortunate way
404
-
// that resulted in the working tree state being on a detached head.
405
-
// That meant the repository was not usable for normal Git operations.
406
-
// Go 1.2 fixed that, but we can't pull into a detached head, so if this is
407
-
// a Git repository we check for being on a detached head and switch to the
408
-
// real branch, almost always called "master".
409
-
// TODO(dsymonds): Consider removing this for Go 1.3.
410
-
func (v *vcsCmd) fixDetachedHead(dir string) error {
411
-
if v != vcsGit {
412
-
return nil
413
-
}
414
-
415
-
// "git symbolic-ref HEAD" succeeds iff we are not on a detached head.
416
-
if err := v.runVerboseOnly(dir, "symbolic-ref HEAD"); err == nil {
417
-
// not on a detached head
418
-
return nil
419
-
}
420
-
if buildV {
421
-
log.Printf("%s on detached head; repairing", dir)
422
-
}
423
-
return v.run(dir, "checkout master")
424
-
}
425
-
426
400
// tags returns the list of available tags for the repo in dir.
427
401
func (v *vcsCmd) tags(dir string) ([]string, error) {
428
402
var tags []string
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4