chore: use git checkout --detach when checking out a commit hash#35
chore: use git checkout --detach when checking out a commit hash#35Vierkantor wants to merge 1 commit intomasterfrom
git checkout --detach when checking out a commit hash#35Conversation
The technical debt metrics seem to have broken recently, and in the CI log there is a fatal Git error about not detaching `HEAD`. The log does not show which command precisely failed. Looking at the set of error messages that Git produces, this can be traced to `git checkout`. So adding `--detach` to the checkout command should hopefully fix the issue. Example of broken tech debt reports: * https://github.com/leanprover-community/mathlib4/actions/runs/25331716666/job/74266774924 Interestingly `git checkout` in the transitive imports script does not seem to break anything. My suspicion is the `git checkout -q` switch turns the advice message into a fatal error? I'd have to look at the Git source code in more detail since the man page is not very clear. In any case, let's just add `--detach` there too to silence the advice.
|
Did you mean to link to another run? The one you linked is one for the PR summary comment and I don't see an error in it. |
|
Oops, it lost the anchor to the right line. ("Post or update summary content", line 132.) There are fatal git errors but for some reason the script does not report an error. Even though |
| } | ||
|
|
||
| git checkout "${commit1}" | ||
| git checkout --detach "${commit1}" |
There was a problem hiding this comment.
| git checkout --detach "${commit1}" | |
| git switch --detach "${commit1}" |
and everywhere else, checkout is pretty much deprecated.
switch required --detach for years, not sure why they "backported" it to checkout now, but using the recommended command would've saved this breakage.
|
🤖 reviewed by Claude I don't think this fix addresses the actual bug. The fatal error in the cited log — — is
A real fix would be either |
The technical debt metrics seem to have broken recently, and in the CI log there is a fatal Git error about not detaching
HEAD. The log does not show which command precisely failed. Looking at the set of error messages that Git produces, this can be traced togit checkout. So adding--detachto the checkout command should hopefully fix the issue.Example of broken tech debt reports:
Interestingly
git checkoutin the transitive imports script does not seem to break anything. My suspicion is thegit checkout -qswitch turns the advice message into a fatal error? I'd have to look at the Git source code in more detail since the man page is not very clear. In any case, let's just add--detachthere too to silence the advice.