Skip to content

Use DEFAULT_VERSION in get_git_version()#74

Merged
rbx merged 1 commit into
FairRootGroup:devfrom
olantwin:fix/default-version
Jun 1, 2026
Merged

Use DEFAULT_VERSION in get_git_version()#74
rbx merged 1 commit into
FairRootGroup:devfrom
olantwin:fix/default-version

Conversation

@olantwin
Copy link
Copy Markdown

@olantwin olantwin commented Jun 1, 2026

When creating a conda package for FairLogger (as part of investigating moving SHiP software to conda), I noticed that correct versioning relied on being in a git repository of FairLogger. For conda, it is conventional to build from a source tarball.

This PR upstreams a patch I made for conda that allows setting the version via -DPROJECT_VERSION as default. When in a git repo, PROJECT_VERSION will then be overridden by the information gotten from git. This makes use of the existing DEFAULT_VERSION functionality of get_git_version.

When building from a source tarball (no .git directory), the version
cannot be determined from git tags. Pass DEFAULT_VERSION so that the
version can be set via -DPROJECT_VERSION on the CMake command line.

The get_git_version() function already supports this parameter; this
change simply makes use of it.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad7fc2c0-1fb5-440e-8eb2-e3cea05351ae

📥 Commits

Reviewing files that changed from the base of the PR and between 5aee797 and ba1c329.

📒 Files selected for processing (1)
  • CMakeLists.txt

📝 Walkthrough

Walkthrough

The CMakeLists.txt build configuration now passes DEFAULT_VERSION ${PROJECT_VERSION} to the get_git_version function, ensuring that when Git version information is unavailable, the project falls back to the explicitly defined PROJECT_VERSION instead of an empty value.

Changes

Version initialization

Layer / File(s) Summary
Git version fallback parameter
CMakeLists.txt
get_git_version CMake invocation now supplies DEFAULT_VERSION ${PROJECT_VERSION} to set a fallback value for PROJECT_GIT_VERSION when Git metadata is unavailable.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: passing DEFAULT_VERSION to get_git_version() to enable version configuration via CMake parameters.
Description check ✅ Passed The description clearly explains the motivation (conda packaging requires non-git builds), the solution (use DEFAULT_VERSION parameter), and how it works with existing git repository detection.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

rbx
rbx previously approved these changes Jun 1, 2026
@rbx
Copy link
Copy Markdown
Member

rbx commented Jun 1, 2026

Sounds good, thank you.

Do you need a tag with this?

@rbx rbx changed the base branch from master to dev June 1, 2026 09:59
@rbx rbx dismissed their stale review June 1, 2026 09:59

The base branch was changed.

@rbx rbx merged commit 5444de4 into FairRootGroup:dev Jun 1, 2026
10 checks passed
@olantwin olantwin deleted the fix/default-version branch June 1, 2026 11:04
@olantwin
Copy link
Copy Markdown
Author

olantwin commented Jun 1, 2026

No tag needed, I'll drop my patch when the next release is tagged.

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.

2 participants