...
1# Regression test for https://go.dev/issue/53955.
2# New remote tags were erroneously added to the local clone of a repo
3# only *after* extracting version information for a locally-cached commit,
4# causing the version information to have incomplete Tags and Version fields.
5
6[short] skip 'constructs a local git repo'
7[!git] skip
8
9# Redirect git to a test-specific .gitconfig.
10# GIT_CONFIG_GLOBAL suffices for git 2.32.0 and newer.
11# For older git versions we also set $HOME.
12env GIT_CONFIG_GLOBAL=$WORK${/}home${/}gopher${/}.gitconfig
13env HOME=$WORK${/}home${/}gopher
14exec git config --global --show-origin user.name
15stdout 'Go Gopher'
16
17# Inject a local repo in place of a remote one, so that we can
18# add commits to the repo partway through the test.
19env GIT_ALLOW_PROTOCOL=file
20env GOPRIVATE=github.com/golang/issue53955
21
22[!GOOS:windows] exec git config --global 'url.file://'$WORK'/repo.insteadOf' 'https://github.com/golang/issue53955'
23[GOOS:windows] exec git config --global 'url.file:///'$WORK'/repo.insteadOf' 'https://github.com/golang/issue53955'
24
25cd $WORK/repo
26
27env GIT_AUTHOR_NAME='Go Gopher'
28env GIT_AUTHOR_EMAIL='gopher@golang.org'
29env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
30env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
31
32exec git init
33
34env GIT_COMMITTER_DATE=2022-07-19T11:07:00-04:00
35env GIT_AUTHOR_DATE=2022-07-19T11:07:00-04:00
36exec git add go.mod issue53955.go
37exec git commit -m 'initial commit'
38exec git branch -m main
39exec git tag v1.0.9
40
41env GIT_COMMITTER_DATE=2022-07-19T11:07:01-04:00
42env GIT_AUTHOR_DATE=2022-07-19T11:07:01-04:00
43exec git add extra.go
44exec git commit -m 'next commit'
45exec git show-ref --tags --heads
46cmp stdout $WORK/.git-refs-1
47
48cd $WORK/m
49go get -x github.com/golang/issue53955@2cb3d49f
50stderr '^go: added github.com/golang/issue53955 v1.0.10-0.20220719150701-2cb3d49f8874$'
51
52cd $WORK/repo
53exec git tag v1.0.10
54
55cd $WORK/m
56go get -x github.com/golang/issue53955@v1.0.10
57! stderr 'v1\.0\.10 is not a tag'
58stderr '^go: upgraded github.com/golang/issue53955 v.* => v1\.0\.10$'
59
60-- $WORK/repo/go.mod --
61module github.com/golang/issue53955
62
63go 1.18
64-- $WORK/repo/issue53955.go --
65package issue53955
66-- $WORK/repo/extra.go --
67package issue53955
68-- $WORK/.git-refs-1 --
692cb3d49f8874b9362ed0ddd2a6512e4108bbf6b1 refs/heads/main
70050526ebf5883191e990529eb3cc9345abaf838c refs/tags/v1.0.9
71-- $WORK/m/go.mod --
72module m
73
74go 1.18
75-- $WORK/home/gopher/.gitconfig --
76[user]
77 name = Go Gopher
78 email = gopher@golang.org
View as plain text