| 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 |
|
| 7 |
env GIT_AUTHOR_NAME='Go Gopher' |
| 8 |
env GIT_AUTHOR_EMAIL='[email protected]' |
| 9 |
env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME |
| 10 |
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL |
| 11 |
|
| 12 |
# Create 2 commit |
| 13 |
env GIT_COMMITTER_DATE=2024-01-30T10:52:00+08:00 |
| 14 |
env GIT_AUTHOR_DATE=2024-01-30T10:52:00+08:00 |
| 15 |
|
| 16 |
cd $WORK/repo |
| 17 |
exec git init |
| 18 |
exec git add go.mod main.go |
| 19 |
exec git commit -m 'initial commit' |
| 20 |
|
| 21 |
env GIT_COMMITTER_DATE=2024-01-30T10:53:00+08:00 |
| 22 |
env GIT_AUTHOR_DATE=2024-01-30T10:53:00+08:00 |
| 23 |
exec git add extra.go |
| 24 |
exec git commit -m 'add extra.go' |
| 25 |
|
| 26 |
# Assume the tree object from initial commit is not available (e.g. partial clone) |
| 27 |
exec git log --pretty=%T |
| 28 |
cmp stdout $WORK/.git-trees |
| 29 |
|
| 30 |
rm .git/objects/66/400c89b45cc96da36d232844dbf9ea5daa6bcf |
| 31 |
|
| 32 |
# Build the module, which should succeed |
| 33 |
go build -v -buildvcs=true -o test |
| 34 |
go version -m test |
| 35 |
stdout '^\tbuild\tvcs.revision=fe3c8204d2332a731166269932dd23760c1b576a$' |
| 36 |
|
| 37 |
-- $WORK/repo/go.mod -- |
| 38 |
module github.com/golang/issue65339 |
| 39 |
|
| 40 |
go 1.20 |
| 41 |
-- $WORK/repo/main.go -- |
| 42 |
package main |
| 43 |
|
| 44 |
func main() { |
| 45 |
println("hello, world") |
| 46 |
} |
| 47 |
-- $WORK/repo/extra.go -- |
| 48 |
package main |
| 49 |
-- $WORK/.git-trees -- |
| 50 |
ac724c6e5e3f86815e057ff58a639cab613abf28 |
| 51 |
66400c89b45cc96da36d232844dbf9ea5daa6bcf |