Skip to content

Commit b861259

Browse files
[Build] Locked Version Tag Reference
To get a unique version for every commit on Master, git describe is used. This produces a unique (monotonically increasing) string by getting the number of commits since a tag. We originally let git decide which tag to use, which I assumed was the most recent tag; however, some users have been noticing that the version has been relative to different tags (like v9.0.0-candidate). In the future, we may want to also control when we want to move the tag this version is relative to manually, instead of letting Git decide. To make this more robust and controllable, forced the git describe to be relative to a specific tag which is set in VTR's CMake (similar to the major version number).
1 parent a8e0002 commit b861259

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ set(VTR_VERSION_MAJOR 9)
6262
set(VTR_VERSION_MINOR 0)
6363
set(VTR_VERSION_PATCH 0)
6464
set(VTR_VERSION_PRERELEASE "dev")
65+
# Git describe is used to get the detailed version of VTR. Git describe returns
66+
# a string which is of the form <tag>-<num_commmits_since_tag>-<commit-hash>.
67+
# The number of commits since the tag is used to make the version unique and
68+
# should guarantee a unique version for each commit on the head of master.
69+
# This variable sets the tag that the version should be relative to. This should
70+
# always be of the form v9.0.0, v10.1.2, etc.
71+
set(VTR_VERSION_TAG_REF "v9.0.0")
6572

6673
include(FilesToDirs)
6774

libs/libvtrutil/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ if(NOT DEFINED VTR_VERSION_PATCH)
2222
set(VTR_VERSION_PATCH 0)
2323
endif()
2424

25+
if(NOT DEFINED VTR_VERSION_TAG_REF)
26+
set(VTR_VERSION_TAG_REF "*")
27+
endif()
28+
2529
set(VTR_BUILD_INFO "${CMAKE_BUILD_TYPE}")
2630
if (CMAKE_INTERPROCEDURAL_OPTIMIZATION)
2731
set(VTR_BUILD_INFO "${VTR_BUILD_INFO} IPO")
@@ -54,7 +58,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
5458
include(GetGitRevisionDescription)
5559

5660
# Get the VCS revision.
57-
git_describe_working_tree(VTR_VCS_REVISION --tags --always --long)
61+
git_describe_working_tree(VTR_VCS_REVISION --match=${VTR_VERSION_TAG_REF} --tags --always --long)
5862
string(FIND ${VTR_VCS_REVISION} "NOTFOUND" GIT_DESCRIBE_VTR_REVISION_NOTFOUND)
5963
if (NOT ${GIT_DESCRIBE_VTR_REVISION_NOTFOUND} EQUAL -1)
6064
# Git describe failed, usually this means we
@@ -64,7 +68,7 @@ if (NOT ${GIT_DESCRIBE_VTR_REVISION_NOTFOUND} EQUAL -1)
6468
endif()
6569

6670
# Get the short VCS revision
67-
git_describe_working_tree(VTR_VCS_REVISION_SHORT --tags --always --long --exclude '*')
71+
git_describe_working_tree(VTR_VCS_REVISION_SHORT --match=${VTR_VERSION_TAG_REF} --tags --always --long --exclude '*')
6872
string(FIND "${VTR_VCS_REVISION_SHORT}" "NOTFOUND" GIT_DESCRIBE_VTR_REVISION_SHORT_NOTFOUND)
6973
if (NOT ${GIT_DESCRIBE_VTR_REVISION_SHORT_NOTFOUND} EQUAL -1)
7074
# Git describe failed, usually this means we

0 commit comments

Comments
 (0)