-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go: ignore retracted versions when converting revisions to versions
When a module author retracts a version, the go command should act as if it doesn't exist unless it's specifically requested. When converting a revision to a version, we should ignore tags for retracted versions. For example, if the tag v1.0.0 is retracted, and branch B points to the same revision, we should convert B to a pseudo-version, not v1.0.0. Similarly, if B points to a commit after v1.0.0, we should not use v1.0.0 as the base; we can use an earlier non-retracted tag or no base. Fixes #41700 Change-Id: Ia596b05b0780e5acfe6616a04e94d24bd342fbae Reviewed-on: https://go-review.googlesource.com/c/go/+/261079 Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jay Conrod <jayconrod@google.com>
- Loading branch information
Jay Conrod
committed
Oct 9, 2020
1 parent
d4a5797
commit 712cba3
Showing
5 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# When converting a commit to a pseudo-version, don't use a retracted version | ||
# as the base. | ||
# Verifies golang.org/issue/41700. | ||
|
||
[!net] skip | ||
[!exec:git] skip | ||
env GOPROXY=direct | ||
env GOSUMDB=off | ||
go mod init m | ||
|
||
# Control: check that v1.0.0 is the only version and is retracted. | ||
go list -m -versions vcs-test.golang.org/git/retract-pseudo.git | ||
stdout '^vcs-test.golang.org/git/retract-pseudo.git$' | ||
go list -m -versions -retracted vcs-test.golang.org/git/retract-pseudo.git | ||
stdout '^vcs-test.golang.org/git/retract-pseudo.git v1.0.0$' | ||
|
||
# 713affd19d7b is a commit after v1.0.0. Don't use v1.0.0 as the base. | ||
go list -m vcs-test.golang.org/git/retract-pseudo.git@713affd19d7b | ||
stdout '^vcs-test.golang.org/git/retract-pseudo.git v0.0.0-20201009173747-713affd19d7b$' | ||
|
||
# 64c061ed4371 is the commit v1.0.0 refers to. Don't convert to v1.0.0. | ||
go list -m vcs-test.golang.org/git/retract-pseudo.git@64c061ed4371 | ||
stdout '^vcs-test.golang.org/git/retract-pseudo.git v0.0.0-20201009173747-64c061ed4371' | ||
|
||
# A retracted version is a valid base. Retraction should not validate existing | ||
# pseudo-versions, nor should it turn invalid pseudo-versions valid. | ||
go get -d vcs-test.golang.org/git/retract-pseudo.git@v1.0.1-0.20201009173747-713affd19d7b | ||
go list -m vcs-test.golang.org/git/retract-pseudo.git | ||
stdout '^vcs-test.golang.org/git/retract-pseudo.git v1.0.1-0.20201009173747-713affd19d7b$' | ||
|
||
! go get -d vcs-test.golang.org/git/retract-pseudo.git@v1.0.1-0.20201009173747-64c061ed4371 | ||
stderr '^go get vcs-test.golang.org/git/retract-pseudo.git@v1.0.1-0.20201009173747-64c061ed4371: vcs-test.golang.org/git/retract-pseudo.git@v1.0.1-0.20201009173747-64c061ed4371: invalid pseudo-version: tag \(v1.0.0\) found on revision 64c061ed4371 is already canonical, so should not be replaced with a pseudo-version derived from that tag$' | ||
|
||
-- retract-pseudo.sh -- | ||
#!/bin/bash | ||
|
||
# This is not part of the test. | ||
# Run this to generate and update the repository on vcs-test.golang.org. | ||
|
||
set -euo pipefail | ||
|
||
rm -rf retract-pseudo | ||
mkdir retract-pseudo | ||
cd retract-pseudo | ||
git init | ||
|
||
# Create the module. | ||
# Retract v1.0.0 and tag v1.0.0 at the same commit. | ||
# The module has no unretracted release versions. | ||
go mod init vcs-test.golang.org/git/retract-pseudo.git | ||
go mod edit -retract v1.0.0 | ||
echo 'package p' >p.go | ||
git add -A | ||
git commit -m 'create module retract-pseudo' | ||
git tag v1.0.0 | ||
|
||
# Commit a trivial change so the default branch does not point to v1.0.0. | ||
git mv p.go q.go | ||
git commit -m 'trivial change' | ||
|
||
zip -r ../retract-pseudo.zip . | ||
gsutil cp ../retract-pseudo.zip gs://vcs-test/git/retract-pseudo.zip |