Skip to content

Commit ffd00f6

Browse files
Fix patch versioning to count the number of commits from last major minor (#484)
1 parent 0e12991 commit ffd00f6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

CMakeLists.txt.versioning

+15-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,21 @@ endfunction()
3939
if (GIT_VERSION AND NOT ${GIT_INFO} STREQUAL "")
4040
message("-- Using Git to calculate AWS IoT Device Client version information...")
4141

42-
# Get last tag from git - this only matches tags starting with v, so we ignore non-versioning tags
43-
execute_process(COMMAND ${GIT_EXECUTABLE} describe --abbrev=0 --tags --match "v[0-9]*"
42+
# Get first tag with major and minor of the latest tag.
43+
execute_process(
44+
COMMAND bash -c "
45+
read LATEST_MAJOR_VERSION LATEST_MINOR_VERSION < <(git describe --abbrev=0 --tags | awk -F. '
46+
{
47+
gsub(/^v/, \"\", \$0)
48+
49+
split(\$0, parts, \".\")
50+
LATEST_MAJOR_VERSION = parts[1]
51+
LATEST_MINOR_VERSION = parts[2]
52+
print LATEST_MAJOR_VERSION, LATEST_MINOR_VERSION
53+
54+
}')
55+
git tag --sort=creatordate | grep -E \"^v?\${LATEST_MAJOR_VERSION}\.\${LATEST_MINOR_VERSION}(\\.\[0-9]+)?\" | head -n 1
56+
"
4457
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
4558
OUTPUT_VARIABLE ${PROJECT_NAME}_VERSION_STRING
4659
OUTPUT_STRIP_TRAILING_WHITESPACE

0 commit comments

Comments
 (0)