Skip to content

Commit

Permalink
AutoRevision: Fail earlier when the version tag is wrong
Browse files Browse the repository at this point in the history
Start by checking that it matches the expected format and raise an error if it
doesn't. Don't replace all instances of "v" but just the first.
  • Loading branch information
lmoureaux committed Feb 25, 2023
1 parent 1fce01a commit 55b4aa5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmake/AutoRevision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,21 @@ endif()

# Manipulate the tag so we can turn it into a list for use later
string(STRIP "${FC21_REV_TAG}" FC21_REV_TAG)
string(REPLACE "v" "" FC21_REV_TAG "${FC21_REV_TAG}")

# Expected scheme:
# v3.0-dev
# v3.0-alpha.1
# v3.0-beta.1
# v3.0-rc.1
# v3.0
# v3.0.1
if (NOT "${FC21_REV_TAG}"
MATCHES "^v[0-9]+\.[0-9]+(\.[0-9]+)?(-((((alpha)|(beta)|(rc))\.[0-9]+)|(dev)))?$")
message(SEND_ERROR "The version tag '${FC21_REV_TAG}' does not follow the expected format.")
endif()

string(SUBSTRING "${FC21_REV_TAG}" 1 -1 FC21_REV_TAG) # Remove initial v
string(STRIP "${FC21_REV_TAG}" FC21_REV_TAG2)
string(REPLACE "v" "" FC21_REV_TAG2 "${FC21_REV_TAG2}")
string(REPLACE "." " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
string(REPLACE "-" " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
set(FC21_REV_TAG_LIST ${FC21_REV_TAG2})
Expand Down

0 comments on commit 55b4aa5

Please sign in to comment.