Text file
src/cmd/go/testdata/script/version_buildvcs_git_worktree.txt
1 # Test that 'go build' stamps VCS information when building from a git worktree.
2 # See https://go.dev/issue/58218.
3
4 [!git] skip
5 [short] skip
6
7 # Create repo with a commit.
8 cd repo
9 exec git init
10 exec git config user.email g.o.p.h.e.r@go.dev
11 exec git config user.name Gopher
12 exec git add -A
13 exec git commit -m 'initial commit'
14
15 # Sanity check: building from main repo includes VCS info.
16 go build -o main.exe .
17 go version -m main.exe
18 stdout '^\tbuild\tvcs=git$'
19 stdout '^\tbuild\tvcs.modified=false$'
20
21 # Create a worktree and build from it.
22 exec git worktree add ../worktree HEAD
23 cd ../worktree
24 go build -o worktree.exe .
25 go version -m worktree.exe
26 stdout '^\tbuild\tvcs=git$'
27 stdout '^\tbuild\tvcs.modified=false$'
28
29 # Verify that vcs.modified is detected in the worktree.
30 cp ../changed.go a.go
31 go build -o modified.exe .
32 go version -m modified.exe
33 stdout '^\tbuild\tvcs.modified=true$'
34
35 -- repo/go.mod --
36 module example.com/worktree
37
38 go 1.18
39 -- repo/a.go --
40 package main
41
42 func main() {}
43 -- changed.go --
44 package main
45
46 func main() { _ = 1 }
47
View as plain text