...
1# Regression test for https://go.dev/issue/65339.
2# Unnecessary git tree object required
3
4[short] skip 'constructs a local git repo'
5[!git] skip
6
7env GIT_AUTHOR_NAME='Go Gopher'
8env GIT_AUTHOR_EMAIL='gopher@golang.org'
9env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
10env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
11
12# Create 2 commit
13env GIT_COMMITTER_DATE=2024-01-30T10:52:00+08:00
14env GIT_AUTHOR_DATE=2024-01-30T10:52:00+08:00
15
16cd $WORK/repo
17exec git init
18exec git add go.mod main.go
19exec git commit -m 'initial commit'
20
21env GIT_COMMITTER_DATE=2024-01-30T10:53:00+08:00
22env GIT_AUTHOR_DATE=2024-01-30T10:53:00+08:00
23exec git add extra.go
24exec git commit -m 'add extra.go'
25
26# Assume the tree object from initial commit is not available (e.g. partial clone)
27exec git log --pretty=%T
28cmp stdout $WORK/.git-trees
29
30rm .git/objects/66/400c89b45cc96da36d232844dbf9ea5daa6bcf
31
32# Build the module, which should succeed
33go build -v -buildvcs=true -o test
34go version -m test
35stdout '^\tbuild\tvcs.revision=fe3c8204d2332a731166269932dd23760c1b576a$'
36
37-- $WORK/repo/go.mod --
38module github.com/golang/issue65339
39
40go 1.20
41-- $WORK/repo/main.go --
42package main
43
44func main() {
45 println("hello, world")
46}
47-- $WORK/repo/extra.go --
48package main
49-- $WORK/.git-trees --
50ac724c6e5e3f86815e057ff58a639cab613abf28
5166400c89b45cc96da36d232844dbf9ea5daa6bcf
View as plain text