[short] skip
[!exec:hg] skip

env GO111MODULE=on
env GOPROXY=direct
env GOSUMDB=off
env GOMODCACHE=$WORK/modcache

# go list on repo with tags
go clean -modcache
go list -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
cp stdout taglist.json
stderr 'hg( .*)* pull'
stdout '"Versions":'
stdout '"v0.2.1"'
stdout '"v0.2.2"'
stdout '"Version": "v0.2.2"'
stdout '"VCS": "hg"'
stdout '"URL": ".*/hg/tagtests"'
stdout '"Ref": "v0.2.2"'
stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'

# reuse go list on repo with tags
go clean -modcache
go list -reuse=taglist.json -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
! stderr 'hg( .*)* pull'
stdout '"Reuse": true'
stdout '"Versions":'
stdout '"v0.2.1"'
stdout '"v0.2.2"'
stdout '"Version": "v0.2.2"'
stdout '"VCS": "hg"'
stdout '"URL": ".*/hg/tagtests"'
stdout '"Ref": "v0.2.2"'
stdout '"Hash": "1e531550e864b16f25013cfbbf2d8e7cf07a0374"'
stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'

# reuse with stale list
go clean -modcache
cp taglist.json taglistbad.json
replace '8dnv906' 'ZZZ' taglistbad.json
go list -reuse=taglistbad.json -x -json -m -retracted -versions vcs-test.golang.org/hg/tagtests.hg@latest
stderr 'hg( .*)* pull'
! stdout '"Reuse": true'
stdout '"RepoSum": "r1:8dnv906Aq1vb9YpNl9pslfva0VfG9enKb6O6NWs0xF0="'