Skip to content

fix(version): preserve unspecified commit placeholder#1934

Open
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:fix-version-unspecified-commit
Open

fix(version): preserve unspecified commit placeholder#1934
stephenlclarke wants to merge 1 commit into
apple:mainfrom
stephenlclarke:fix-version-unspecified-commit

Conversation

@stephenlclarke

Copy link
Copy Markdown

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Supersedes #1831, whose deleted fork head cannot be reattached to the closed review.

When container is built without a GIT_COMMIT value, the C version shim returns unspecified. ReleaseVersion.singleLine(appName:) currently shortens every non-nil commit string to seven characters, so the version banner reports commit: unspeci.

The change preserves missing, empty, and unspecified commit values as the full placeholder while retaining the seven-character display for real commit hashes.

What Changed

  • Centralizes commit display formatting in ReleaseVersion.displayCommit(_:).
  • Preserves the complete unspecified placeholder.
  • Keeps seven-character short hashes for real commits.
  • Adds focused tests for nil, empty, placeholder, and real-hash values.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Validation:

  • make swift-fmt-check
  • make test: 94 XCTest cases and 560 Swift Testing cases passed
  • swift test --disable-automatic-resolution --enable-code-coverage --filter ReleaseVersionTests
  • env -u GIT_COMMIT swift build --disable-automatic-resolution --product container
  • env -u GIT_COMMIT .build/debug/container --version
  • git diff --check origin/main..HEAD

The version smoke check reports:

container CLI version 0.0.0 (build: debug, commit: unspecified)

The coverage run executes every branch and return path added by displayCommit(_:).

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.

1 participant