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