pub fn check_git_version(reported: &str) -> Result<(), CommandError>Expand description
Validates git version against the REQUIRED_GIT floor.
reported is the raw git --version output (e.g. "git version 2.39.5",
"git version 2.39.5.windows.1" on Git for Windows, which appends a
non-semver .windows.N suffix onto the real version, or
"git version 2.39.5-rc1" for a pre-release build). Only the leading
major.minor.patch triple is parsed, each component truncated to its own
leading digit run (discarding anything past the first non-digit
character, e.g. 5-rc1 -> 5) before being handed to semver: passing
a hyphenated suffix through unstripped would make semver::VersionReq
exclude it from the >=2.20 floor entirely, since semver requirements
never match a pre-release version unless the requirement’s own comparator
carries a matching pre-release tag – a real git build tag has nothing to
do with that semantics and must not affect whether the floor is met. Any
dot-separated components after the third (like .windows.1) are ignored,
and a missing minor/patch is treated as 0, matching how git itself
never omits them in practice but keeping this tolerant of a truncated
report.
The actual comparison is delegated to semver::VersionReq parsing
REQUIRED_GIT, so the floor is defined in exactly one place instead of
a separately hand-maintained numeric comparison that could silently drift
from the constant used in the error message.