cmd/go: make vcstest repo scripts compatible with old Git versions

The scripts added in CL 421455 passed on the TryBots, but failed on a
subset of the builders that have older 'git' binaries installed.

Notably, the older versions of git do not support:
- 'git branch -m' before the current branch has a commit
- 'init.defaultBranch' in the '.gitconfig' file, and
- 'git branch -c'.

We address those by, respectively:
- waiting to run 'git branch -m' until after the first commit
- always running 'git branch -m' explicitly to set the branch name, and
- using 'git checkout' instead of 'git branch -c' to set branch parents.

Updates #27494.

Change-Id: I42f012f5add8f31e41d077d752d8268aacbce8a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/445355
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2022-10-25 10:28:50 -04:00 committed by Gopher Robot
parent f9bd1d0f11
commit 2d63305b84
24 changed files with 41 additions and 35 deletions

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-07-15T17:16:47-04:00
git add go.mod main.go
git commit -m 'all: add go.mod and main.go'
git branch -m master
git tag v1.0.0
at 2019-07-15T17:17:27-04:00

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-10-07T14:15:32-04:00
git add go.mod
git commit -m 'add go.mod file without go source files'
git branch -m master
git tag v2.0.0
git log --oneline --decorate=short

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-07-03T22:35:49-04:00
git add go.mod
git commit -m 'initial'
git branch -m master
git log --oneline
cmp stdout .git-log

View File

@ -6,17 +6,17 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-04-17T15:43:22-04:00
unquote ''
cp stdout README
git add README
git commit -a -m 'empty README'
git branch -m master
git tag v1.2.3
at 2018-04-17T15:45:48-04:00
git branch -c v2
git branch v2
git checkout v2
echo 'v2'
cp stdout v2
@ -24,7 +24,7 @@ git add v2
git commit -a -m 'v2'
git tag v2.3
git tag v2.0.1
git branch -c v2.3.4
git branch v2.3.4
at 2018-04-17T16:00:19-04:00
echo 'intermediate'
@ -40,7 +40,8 @@ git commit -a -m 'another'
git tag v2.0.2
at 2018-04-17T16:16:52-04:00
git branch -c master v3
git checkout master
git branch v3
git checkout v3
mkdir v3/sub/dir
echo 'v3/sub/dir/file'

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME='Russ Cox'
env GIT_COMMITTER_EMAIL='rsc@golang.org'
git init
git branch -m master
at 2017-09-21T21:05:58-04:00
git add hello.go
git commit -a -m 'hello'
git branch -m master
git log --oneline --decorate=short
cmp stdout .git-log

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-04-03T13:30:35-04:00
git add go.mod
git commit -m 'all: initialize module'
git branch -m master
at 2019-09-04T14:39:48-04:00
git add main.go

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-09-05T14:07:43-04:00
git add main.go
git commit -a -m 'add main.go'
git branch -m master
git log --oneline --decorate=short
cmp stdout .git-log

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-04-25T11:00:57-04:00
git add go.mod new.go p1 p2
git commit -m 'initial commit'
git branch -m master
git log --oneline --decorate=short
cmp stdout .git-log

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-04-25T10:59:24-04:00
git add p1 p2
git commit -m 'initial commit'
git branch -m master
git log --oneline --decorate=short
cmp stdout .git-log

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-07-15T17:20:47-04:00
git add go.mod main.go
git commit -m 'all: add go.mod and main.go'
git branch -m master
git log --oneline --decorate=short
cmp stdout .git-log

View File

@ -10,6 +10,7 @@ git init
at 2022-02-23T13:48:02-05:00
git add README.txt
git commit -m 'initial state'
git branch -m main
git tag 'v2.0.0+incompatible'
at 2022-02-23T13:48:35-05:00
@ -19,7 +20,7 @@ git commit -m 'migrate to Go modules'
git tag 'v0.1.0+build-metadata'
at 2022-02-23T14:41:55-05:00
git branch -c v3-dev
git branch v3-dev
git checkout v3-dev
cp v3/go.mod go.mod
git commit go.mod -m 'update to /v3'

View File

@ -8,10 +8,10 @@ env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
at 2019-05-09T18:35:00-04:00
git init
git branch -m master
git add sub
git commit -m 'create module sub'
git branch -m master
echo 'v0.1.0'
cp stdout status

View File

@ -6,14 +6,14 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-07-03T22:31:01-04:00
git add go.mod
git commit -a -m 'v1'
git branch -m master
git tag start
git branch -c v2
git branch v2
at 2018-07-03T22:33:47-04:00
echo 'before v0.0.0-pre1'

View File

@ -11,6 +11,7 @@ git init
git add go.mod p.go
git commit -m 'create module retract-pseudo'
git branch -m main
git tag v1.0.0
git mv p.go q.go

View File

@ -10,17 +10,18 @@ git init
at 2022-02-02T14:15:21-05:00
git add pkg go.mod
git commit -a -m 'pkg: add empty package'
git branch -m main
git tag 'v0.1.0'
at 2022-02-02T14:19:44-05:00
git branch -c 'v1.0.0'
git branch -c 'v2.0.0'
git branch 'v1.0.0'
git branch 'v2.0.0'
git checkout 'v1.0.0'
cp v1/pkg/pkg.go pkg/pkg.go
git commit -a -m 'pkg: start developing toward v1.0.0'
at 2022-02-03T10:53:13-05:00
git branch -c 'v3.0.0-devel'
git branch 'v3.0.0-devel'
git checkout 'v3.0.0-devel'
git checkout v0.1.0 pkg/pkg.go
git commit -a -m 'pkg: remove panic'

View File

@ -8,11 +8,11 @@ env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
at 2019-05-09T18:56:25-04:00
git init
git branch -m master
git add go.mod tagtests.go
git commit -m 'create module tagtests'
git branch -c b
git branch -m master
git branch b
git add v0.2.1
git commit -m 'v0.2.1'

View File

@ -6,12 +6,12 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-04-03T11:52:15-04:00
env GIT_AUTHOR_DATE=2019-04-03T11:44:11-04:00
git add go.mod
git commit -m 'all: add go.mod'
git branch -m master
git tag 'v2.0.0'
git show-ref --tags --heads

View File

@ -10,6 +10,7 @@ git init
at 2022-02-22T15:53:33-05:00
git add v2sub.go v2
git commit -m 'all: add package v2sub and v2sub/v2'
git branch -m main
git tag v2.0.0
at 2022-02-22T15:55:07-05:00

View File

@ -6,12 +6,12 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2019-07-15T14:01:24-04:00
env GIT_AUTHOR_DATE=2019-07-15T13:59:34-04:00
git add go.mod v3pkg.go
git commit -a -m 'all: add go.mod with v3 path'
git branch -m master
git tag 'v3.0.0'
git show-ref --tags --heads

View File

@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-02-19T17:21:09-05:00
git add LICENSE README.md
git commit -m 'initial commit'
git branch -m master
git checkout --detach HEAD

View File

@ -9,17 +9,17 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
at 2018-04-17T15:43:22-04:00
unquote ''
cp stdout README
git add README
git commit -a -m 'empty README'
git branch -m master
git tag v1.2.3
at 2018-04-17T15:45:48-04:00
git branch -c v2
git branch v2
git checkout v2
echo 'v2'
cp stdout v2
@ -27,7 +27,7 @@ git add v2
git commit -a -m 'v2'
git tag v2.3
git tag v2.0.1
git branch -c v2.3.4
git branch v2.3.4
git tag branch-v2.3.4
at 2018-04-17T16:00:19-04:00
@ -45,7 +45,8 @@ git tag v2.0.2
git tag branch-v2
at 2018-04-17T16:16:52-04:00
git branch -c master v3
git checkout master
git branch v3
git checkout v3
mkdir v3/sub/dir
echo 'v3/sub/dir/file'

View File

@ -8,15 +8,15 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
git init
git branch -m master
# 0
at 2018-02-19T17:21:09-05:00
git add LICENSE README.md
git commit -m 'initial commit'
git branch -m master
# 1
git branch -c mybranch
git branch mybranch
git checkout mybranch
at 2018-02-19T18:10:06-05:00
@ -30,8 +30,8 @@ git tag v1.0.0
git tag v2.0.0
git tag mytag
git branch -c v1
git branch -c v2
git branch v1
git branch v2
git checkout v2
# 2

View File

@ -28,10 +28,10 @@ git init
git config --add core.ignorecase true
git config --add core.precomposeunicode true
git branch -m master
git add README
at 2017-09-22T11:39:03-04:00
git commit -a -m 'README'
git branch -m master
git rev-parse HEAD
stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'

View File

@ -27,10 +27,10 @@ git init
git config --add core.ignorecase true
git config --add core.precomposeunicode true
git branch -m master
git add README
at 2017-09-22T11:39:03-04:00
git commit -a -m 'README'
git branch -m master
git rev-parse HEAD
stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'