ci: fix git version detection in the MSYS2 Windows job - #552
Merged
Conversation
The Windows build has been reporting 0.0.0-unknown, for two independent reasons. Both are verified on a real Windows 11 + MSYS2 MINGW64 box. 1. The MSYS2 shell has no git at all. It is not part of base-devel, and the shell does not inherit Git for Windows from the runner PATH (confirmed: no "/Program Files/Git" entry in the MINGW64 PATH). So every git call in CMakeLists.txt failed. Fixed by installing the git package alongside the toolchain. 2. Once git is available, the --show-toplevel guard added in #551 would still reject every Windows build, permanently pinning it to 0.0.0-unknown. MSYS2 git reports POSIX paths while CMake reports Windows ones, and get_filename_component(REALPATH) does not reconcile them: PROJECT_SOURCE_DIR = C:/Users/Denis/hc-vtest/probe/sub git --show-toplevel = /c/Users/Denis/hc-vtest/probe/sub so the STREQUAL can never match. Replaced with --show-prefix, which is empty exactly when the source dir is the root of a work tree. That is a plain string test needing no path normalisation, and it drops both REALPATH calls. Measured on Windows with the same package set as CI: the old guard yields 0.0.0-unknown, the new one yields 4.0.0-11-g00ca695, a vendored copy correctly falls back to 0.0.0-unknown, and build + ctest pass. Both reject paths now explain themselves and point at -DHEADSETCONTROL_VERSION. Also renames the reused GIT_RESULT to GIT_DESCRIBE_RESULT.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Windows build has been reporting 0.0.0-unknown, for two independent reasons. Both are verified on a real Windows 11 + MSYS2 MINGW64 box.
The MSYS2 shell has no git at all. It is not part of base-devel, and the shell does not inherit Git for Windows from the runner PATH (confirmed: no "/Program Files/Git" entry in the MINGW64 PATH). So every git call in CMakeLists.txt failed. Fixed by installing the git package alongside the toolchain.
Once git is available, the --show-toplevel guard added in Fix Git version detection when embedded #551 would still reject every Windows build, permanently pinning it to 0.0.0-unknown. MSYS2 git reports POSIX paths while CMake reports Windows ones, and get_filename_component(REALPATH) does not reconcile them:
PROJECT_SOURCE_DIR = C:/Users/Denis/hc-vtest/probe/sub
git --show-toplevel = /c/Users/Denis/hc-vtest/probe/sub
so the STREQUAL can never match. Replaced with --show-prefix, which is empty exactly when the source dir is the root of a work tree. That is a plain string test needing no path normalisation, and it drops both REALPATH calls.
Measured on Windows with the same package set as CI: the old guard yields 0.0.0-unknown, the new one yields 4.0.0-11-g00ca695, a vendored copy correctly falls back to 0.0.0-unknown, and build + ctest pass.
Both reject paths now explain themselves and point at -DHEADSETCONTROL_VERSION. Also renames the reused GIT_RESULT to GIT_DESCRIBE_RESULT.