summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2021-08-26 14:44:57 +0200
committerRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2021-08-26 14:44:57 +0200
commit261a4f06bfc91da9824b89921536fed6c3122bdd (patch)
treebd968b52bb8771daae7192cea45caaba8c53b9bb /src
parentff88ecd38619134e6415b09c67e1f654acf51269 (diff)
downloadsetuptools-scm-261a4f06bfc91da9824b89921536fed6c3122bdd.tar.gz
fix #593: allow calver-by-date on top of legacy version
Diffstat (limited to 'src')
-rw-r--r--src/setuptools_scm/version.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py
index 12b0b90..0adafc3 100644
--- a/src/setuptools_scm/version.py
+++ b/src/setuptools_scm/version.py
@@ -323,21 +323,27 @@ def guess_next_date_ver(version, node_date=None, date_fmt=None, version_cls=None
"""
match = date_ver_match(version)
if match is None:
- raise ValueError(
- "{version} does not correspond to a valid versioning date, "
- "please correct or use a custom version scheme".format(version=version)
+ warnings.warn(
+ f"{version} does not correspond to a valid versioning date, "
+ "assuming legacy version"
)
+ if date_fmt is None:
+ date_fmt = "%y.%m.%d"
+
# deduct date format if not provided
if date_fmt is None:
date_fmt = "%Y.%m.%d" if len(match.group("year")) == 4 else "%y.%m.%d"
head_date = node_date or datetime.date.today()
# compute patch
- tag_date = datetime.datetime.strptime(match.group("date"), date_fmt).date()
+ if match is None:
+ tag_date = datetime.date.today()
+ else:
+ tag_date = datetime.datetime.strptime(match.group("date"), date_fmt).date()
if tag_date == head_date:
- patch = match.group("patch") or "0"
+ patch = "0" if match is None else (match.group("patch") or "0")
patch = int(patch) + 1
else:
- if tag_date > head_date:
+ if tag_date > head_date and match is not None:
# warn on future times
warnings.warn(
"your previous tag ({}) is ahead your node date ({})".format(