Skip to content

Read the patch number before Apple's build note in git --version [patch] - #201

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/158-apple-git-version
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/158-apple-git-version

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #158

What changed

On macOS, GetVersionAsync reported Apple's git (git version 2.39.3 (Apple Git-145)) as 2.39.0. Splitting on . made the third component "3 (Apple Git-145)". That string doesn't parse as a whole integer, so ReadComponent fell back to 0.

GitVersionParser.ReadComponent now parses each component's leading digits:

  • "3 (Apple Git-145)" reads as 3.
  • An rc build's "1-rc0" reads as 1. Before, it also fell back to 0, which only gave the right answer when the patch happened to be 0.
  • A component with no leading digit, such as "windows", still reads as 0.

Raw is unchanged. The major component is still parsed strictly and still throws when it isn't a number.

Tests (GitVersionParserTests)

  • ParsesApplesBuildNoteAfterThePatchComponent: 2.39.3 (Apple Git-145) parses as 2.39.3, and Raw keeps the note.
  • ParsesAReleaseCandidateSuffixOnThePatchComponent: 2.41.1-rc0 parses as 2.41.1.

With the parser change reverted, both tests fail and the five existing cases still pass. With the change, the full suite passes (776/776).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rt1SUkG3bsTZEWbmGirSx3


Generated by Claude Code

"git version 2.39.3 (Apple Git-145)" split into a third component of "3 (Apple Git-145)", which
failed to parse whole and fell back to 0, so GetVersionAsync reported 2.39.0 on macOS. Each
component now reads its leading digits, which also keeps the patch of an rc build ("1-rc0").

Fixes #158

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Rt1SUkG3bsTZEWbmGirSx3
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit b3b8a61 into main Oct 9, 2026
16 checks passed
@matt-edmondson
matt-edmondson deleted the fix/158-apple-git-version branch October 9, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetVersionAsync reports 2.39.0 for Apple's git ("git version 2.39.3 (Apple Git-145)"): the patch component is parsed as 0

2 participants