Skip to content

Commit

Permalink
Merge branch 'main' into cwinter_3343
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph M. Wintersteiger authored Mar 25, 2022
2 parents 348900b + e46ab21 commit 570150f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .daily_canary
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Run!!
Run!!!!!
4 changes: 2 additions & 2 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
endif()

if(UNSAFE_VERSION)
set(CCF_VERSION "${CCF_VERSION}_unsafe")
set(CCF_VERSION "${CCF_VERSION}+unsafe")
endif()

# Convert git description into cmake list, separated at '-'
Expand All @@ -47,7 +47,7 @@ else()
)

if(UNSAFE_VERSION)
set(CCF_VERSION "${CCF_VERSION}_unsafe")
set(CCF_VERSION "${CCF_VERSION}+unsafe")
endif()

# Convert directory name into cmake list, separated at '-'
Expand Down
12 changes: 11 additions & 1 deletion python/versionifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def to_python_version(original):
# Keep expanding this suffix until you get a valid version, or run out of attempts.
next_attempt = unprefixed
next_replace = len(next_attempt)
plus_remover = str.maketrans({ord("+"): ""})
while True:
try:
version = Version(next_attempt)
Expand All @@ -34,7 +35,10 @@ def to_python_version(original):
next_replace = unprefixed.rfind("-", 0, next_replace)
if next_replace == -1:
break
next_attempt = replace_char(unprefixed, next_replace, "+")
# Remove any existing +s, and convert one - to a +
next_attempt = replace_char(
unprefixed.translate(plus_remover), next_replace, "+"
)

raise ValueError(f"Cannot convert '{original}' to a Version")

Expand Down Expand Up @@ -71,3 +75,9 @@ def to_python_version(original):
assert v.release == (1, 2, 3)
assert v.post == 42
assert v.local == "deadbeef"

v = to_python_version("ccf-2.0.0-rc4-26-g49d7b7941+unsafe")
assert v.release == (2, 0, 0)
assert v.pre == ("rc", 4)
assert v.post == 26
assert v.local == "g49d7b7941unsafe"

0 comments on commit 570150f

Please sign in to comment.