Skip to content

Commit 3f3649d

Browse files
ahnaf-tahmid-chowdhuryMicahGalepshriwise
authored
Handle Missing Tags in Versioning by Setting Default to 0 (#3359)
Co-authored-by: Micah Gale <[email protected]> Co-authored-by: Patrick Shriwise <[email protected]>
1 parent 277390b commit 3f3649d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

Diff for: cmake/Modules/GetVersionFromGit.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND GIT_FOUND)
3737
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
3838
OUTPUT_VARIABLE VERSION_STRING
3939
OUTPUT_STRIP_TRAILING_WHITESPACE
40+
ERROR_QUIET
4041
)
4142

42-
# If no tags are found, instruct user to fetch them
43+
# If no tags are found, set version to 0 and show a warning
4344
if(VERSION_STRING STREQUAL "")
44-
message(FATAL_ERROR "No git tags found. Run 'git fetch --tags' and try again.")
45+
set(VERSION_STRING "0.0.0")
46+
message(WARNING
47+
"No git tags found. Version set to 0.0.0.\n"
48+
"Run 'git fetch --tags' to ensure proper versioning.\n"
49+
"For more information, see OpenMC developer documentation."
50+
)
4551
endif()
4652

4753
# Extract the commit hash

Diff for: docs/source/devguide/workflow.rst

+24
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ features and bug fixes. The general steps for contributing are as follows:
9191
6. After the pull request has been thoroughly vetted, it is merged back into the
9292
*develop* branch of openmc-dev/openmc.
9393

94+
Setting Up Upstream Tracking (Required for Versioning)
95+
------------------------------------------------------
96+
97+
By default, your fork **does not** include tags from the upstream OpenMC repository.
98+
OpenMC relies on `git describe --tags` for versioning in source builds, and missing tags can lead
99+
to incorrect version detection (i.e., ``0.0.0``). To ensure proper versioning, follow these steps:
100+
101+
1. **Add the Upstream Repository**
102+
This allows you to fetch updates from the main OpenMC repository.
103+
104+
.. code-block:: sh
105+
106+
git remote add upstream https://github.com/openmc-dev/openmc.git
107+
108+
2. **Fetch and Push Tags**
109+
Retrieve tags from the upstream repository and update your fork:
110+
111+
.. code-block:: sh
112+
113+
git fetch --tags upstream
114+
git push --tags origin
115+
116+
This ensures that both your **local** and **remote** fork have the correct versioning information.
117+
94118
Private Development
95119
-------------------
96120

0 commit comments

Comments
 (0)