mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Handle Missing Tags in Versioning by Setting Default to 0 (#3359)
Co-authored-by: Micah Gale <mgale@fastmail.com> Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
This commit is contained in:
parent
277390b220
commit
3f3649da08
2 changed files with 32 additions and 2 deletions
|
|
@ -37,11 +37,17 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND GIT_FOUND)
|
|||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE VERSION_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# If no tags are found, instruct user to fetch them
|
||||
# If no tags are found, set version to 0 and show a warning
|
||||
if(VERSION_STRING STREQUAL "")
|
||||
message(FATAL_ERROR "No git tags found. Run 'git fetch --tags' and try again.")
|
||||
set(VERSION_STRING "0.0.0")
|
||||
message(WARNING
|
||||
"No git tags found. Version set to 0.0.0.\n"
|
||||
"Run 'git fetch --tags' to ensure proper versioning.\n"
|
||||
"For more information, see OpenMC developer documentation."
|
||||
)
|
||||
endif()
|
||||
|
||||
# Extract the commit hash
|
||||
|
|
|
|||
|
|
@ -91,6 +91,30 @@ features and bug fixes. The general steps for contributing are as follows:
|
|||
6. After the pull request has been thoroughly vetted, it is merged back into the
|
||||
*develop* branch of openmc-dev/openmc.
|
||||
|
||||
Setting Up Upstream Tracking (Required for Versioning)
|
||||
------------------------------------------------------
|
||||
|
||||
By default, your fork **does not** include tags from the upstream OpenMC repository.
|
||||
OpenMC relies on `git describe --tags` for versioning in source builds, and missing tags can lead
|
||||
to incorrect version detection (i.e., ``0.0.0``). To ensure proper versioning, follow these steps:
|
||||
|
||||
1. **Add the Upstream Repository**
|
||||
This allows you to fetch updates from the main OpenMC repository.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
git remote add upstream https://github.com/openmc-dev/openmc.git
|
||||
|
||||
2. **Fetch and Push Tags**
|
||||
Retrieve tags from the upstream repository and update your fork:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
git fetch --tags upstream
|
||||
git push --tags origin
|
||||
|
||||
This ensures that both your **local** and **remote** fork have the correct versioning information.
|
||||
|
||||
Private Development
|
||||
-------------------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue