Skip to main content

check_git_version

Function check_git_version 

Source
pub fn check_git_version(reported: &str) -> Result<(), CommandError>
Expand description

Validates git version against the REQUIRED_GIT floor.

reported is raw git --version output (e.g. "git version 2.39.5", "...2.39.5.windows.1" on Windows, "...2.39.5-rc1" for a pre-release). Only the leading major.minor.patch triple is parsed, each component truncated at its first non-digit char (5-rc1 -> 5) before reaching semver: an unstripped hyphenated suffix would make semver::VersionReq exclude it from the >=2.20 floor entirely, since semver reqs never match a pre-release unless the requirement itself carries a matching tag – irrelevant to a real git build tag. Extra dot-separated components (.windows.1) are ignored; a missing minor/patch defaults to 0.

Comparison itself is delegated to semver::VersionReq parsing REQUIRED_GIT, so the floor lives in one place, not a hand-maintained duplicate that could drift from the error message’s constant.