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.
12 env GIT_CONFIG_GLOBAL=$WORK${/}home${/}gopher${/}.gitconfig
13 env HOME=$WORK${/}home${/}gopher
14 exec git config --global --show-origin user.name
15 stdout '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.
19 env GIT_ALLOW_PROTOCOL=file
20 env 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
25 cd $WORK/repo
26
27 env GIT_AUTHOR_NAME='Go Gopher'
28 env GIT_AUTHOR_EMAIL='gopher@golang.org'
29 env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
30 env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
31
32 exec git init
33
34 env GIT_COMMITTER_DATE=2022-07-19T11:07:00-04:00
35 env GIT_AUTHOR_DATE=2022-07-19T11:07:00-04:00
36 exec git add go.mod issue53955.go
37 exec git commit -m 'initial commit'
38 exec git branch -m main
39 exec git tag v1.0.9
40
41 env GIT_COMMITTER_DATE=2022-07-19T11:07:01-04:00
42 env GIT_AUTHOR_DATE=2022-07-19T11:07:01-04:00
43 exec git add extra.go
44 exec git commit -m 'next commit'
45 exec git show-ref --tags --heads
46 cmp stdout $WORK/.git-refs-1
47
48 cd $WORK/m
49 go get -x github.com/golang/issue53955@2cb3d49f
50 stderr '^go: added github.com/golang/issue53955 v1.0.10-0.20220719150701-2cb3d49f8874$'
51
52 cd $WORK/repo
53 exec git tag v1.0.10
54
55 cd $WORK/m
56 go get -x github.com/golang/issue53955@v1.0.10
57 ! stderr 'v1\.0\.10 is not a tag'
58 stderr '^go: upgraded github.com/golang/issue53955 v.* => v1\.0\.10$'
59
60 -- $WORK/repo/go.mod --
61 module github.com/golang/issue53955
62
63 go 1.18
64 -- $WORK/repo/issue53955.go --
65 package issue53955
66 -- $WORK/repo/extra.go --
67 package issue53955
68 -- $WORK/.git-refs-1 --
69 2cb3d49f8874b9362ed0ddd2a6512e4108bbf6b1 refs/heads/main
70 050526ebf5883191e990529eb3cc9345abaf838c refs/tags/v1.0.9
71 -- $WORK/m/go.mod --
72 module m
73
74 go 1.18
75 -- $WORK/home/gopher/.gitconfig --
76 [user]
77 name = Go Gopher
78 email = gopher@golang.org
79
View as plain text