From c2ed0da8313bf44ed8888f6aae348a963c7b80d5 Mon Sep 17 00:00:00 2001 From: Maxim Martynov Date: Thu, 28 Oct 2021 12:04:55 +0300 Subject: [PATCH] Strip leading 'v' symbol from tag name --- setuptools_git_versioning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setuptools_git_versioning.py b/setuptools_git_versioning.py index 8cb700a..55161f6 100644 --- a/setuptools_git_versioning.py +++ b/setuptools_git_versioning.py @@ -197,7 +197,7 @@ def version_from_git( tag = read_version_from_file(version_file) if not count_commits_from_version_file: - return tag + return tag.lstrip("v") # for tag "v1.0.0" drop leading "v" symbol tag_sha = get_latest_file_commit(version_file) else: @@ -228,5 +228,5 @@ def version_from_git( # Ensure local version label only contains permitted characters public, sep, local = version.partition("+") local_sanitized = re.sub(r"[^a-zA-Z0-9.]", ".", local) - public_sanitized = public.lstrip("v") # for tag "v1.0.0" drop leading "v" symbol + public_sanitized = public.lstrip("v") # for version "v1.0.0" drop leading "v" symbol return public_sanitized + sep + local_sanitized