-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: vcs.* info can be inaccurate for Mercurial #63532
Comments
@mharbison72, given that you seem to understand the problems here, would you like to send a fix? (I'm not sure that I have a solid enough understanding of the Mercurial command line to do it properly — especially to write a regression test that would correctly reproduce these bugs.) |
I'd be happy too, but I haven't contributed here before. I'm reading the contributing doc and need to get setup first. I'm not sure where you are in the release cycle- is there a particular branch I should target to get these fixes backported? Also, where are the tests I should add to? I see |
All fixes should land on the
They are run as subtests of
|
Thanks for the pointers @bcmills. I'm probably missing something obvious, but the tests seem to sail right over the changes I'm making to
Also, if I understand how the scripts work, they aren't currently testing the revision or time value at all, other than that it's present:
I can see why that was done- the current time and username are part of the commit hash, so they aren't fixed from run to run. They can be set to specific values in the test environment like in the Mercurial test setup if you want to go that far (and go.exe doesn't clear them somewhere), but I don't want to leave you with a bunch of complexity. Without it though, there's really no way to add regression tests for this. |
I figured out my problem- I was running the global LMK if the more elaborate revision matching in the tests is what you had in mind, or if you meant something else. |
… stamps Updates golang#63532 The previous code looked at the most recent commit, not the current checkout. Now there's not a special case for an empty repo, and there should always be output from the command.
Fixes golang#63532 I'm not bothering with a test for this, because there's a bit of setup and `-S` is simply an instruction to not stop at the subrepo boundary. The command is otherwise the same.
Change https://go.dev/cl/535377 mentions this issue: |
… stamps Updates golang#63532 The previous code looked at the most recent commit, not the current checkout. Now there's not a special case for an empty repo, and there should always be output from the command.
Fixes golang#63532 I'm not bothering with a test for this, because there's a bit of setup and `-S` is simply an instruction to not stop at the subrepo boundary. The command is otherwise the same.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I didn't try, but looking at the current code, yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran
go1.20.2.exe version -m
on my executable.What did you expect to see?
What did you see instead?
It looks like 76cef81 introduced a regression when it switched from
identify -i
(which produces information about the current checkout) tolog -l1
(which prints info about whatever the topmost commit is, and may be a totally different branch). [1] From the commit comment there, it sounds like this particular change was to get the full commit hash too. The fix here is to simply add a-r.
argument to thelog
command to look at the current commit, and that will fix bothvcs.time
andvcs.revision
.Typically, the topmost commit is whatever the developer is working on, but it won't be if updating to an old commit, or pulling changes from the server. While these might be edge cases, creating a tag creates a new commit, and CI typically updates to the commit that was tagged. That means this info will be wrong for any tagged builds (which is how I noticed this).
There are two other correctness issues here:
The
status
command should have a-S
argument, so that it recurses into any subrepos when checking for modified files.[2]HGPLAIN=1
should be set in the environment when executing any commands, to prevent unexpected command output changes.[3] For example, I haveui.tweakdefaults=True
in my configuration, so at the end ofhg status
listing any file changes, it can print info about the current state of the repo, like this:Given the current code of checking for any status output, that would incorrectly flag the build as modified.
[1] 76cef81#diff-50574a97a14d32e7cc56ad1ba6de8c554e491c48a3718e599cfc8cc0ab2858e4R166
[2] https://github.com/golang/go/blame/cc13161a0d62fc1deab019996c17a7da1ff6a7f1/src/cmd/go/internal/vcs/vcs.go#L211
[3] https://repo.mercurial-scm.org/hg/file/6.5.2/mercurial/helptext/scripting.txt#l45
The text was updated successfully, but these errors were encountered: