Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-dunamai for openSUSE:Factory checked in at 2024-06-28 15:47:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-dunamai (Old)
and /work/SRC/openSUSE:Factory/.python-dunamai.new.18349 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-dunamai"
Fri Jun 28 15:47:33 2024 rev:6 rq:1183716 version:1.21.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-dunamai/python-dunamai.changes 2024-06-06 12:34:56.709561246 +0200
+++ /work/SRC/openSUSE:Factory/.python-dunamai.new.18349/python-dunamai.changes 2024-06-28 15:50:33.605678899 +0200
@@ -1,0 +2,7 @@
+Fri Jun 28 01:52:24 UTC 2024 - Richard Rahl
+
+- update to 1.21.2:
+ * Fixed: Some timestamps could fail to parse on Python 3.5 and 3.6.
+
+
+-------------------------------------------------------------------
Old:
----
python-dunamai-1.21.1.tar.gz
New:
----
python-dunamai-1.21.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-dunamai.spec ++++++
--- /var/tmp/diff_new_pack.NiH4em/_old 2024-06-28 15:50:39.301885008 +0200
+++ /var/tmp/diff_new_pack.NiH4em/_new 2024-06-28 15:50:39.317885586 +0200
@@ -18,7 +18,7 @@
%{?sle15_python_module_pythons}
Name: python-dunamai
-Version: 1.21.1
+Version: 1.21.2
Release: 0
Summary: Dynamic version generation
License: MIT
++++++ python-dunamai-1.21.1.tar.gz -> python-dunamai-1.21.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/CHANGELOG.md new/dunamai-1.21.2/CHANGELOG.md
--- old/dunamai-1.21.1/CHANGELOG.md 2024-05-04 04:31:55.686449300 +0200
+++ new/dunamai-1.21.2/CHANGELOG.md 2024-06-27 05:58:28.811013500 +0200
@@ -1,3 +1,7 @@
+## v1.21.2 (2024-06-26)
+
+* Fixed: Some timestamps could fail to parse on Python 3.5 and 3.6.
+
## v1.21.1 (2024-05-03)
* Fixed: Distance was calculated inconsistently for Git
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/PKG-INFO new/dunamai-1.21.2/PKG-INFO
--- old/dunamai-1.21.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
+++ new/dunamai-1.21.2/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: dunamai
-Version: 1.21.1
+Version: 1.21.2
Summary: Dynamic version generation
Home-page: https://github.com/mtkennerly/dunamai
License: MIT
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/dunamai/__init__.py new/dunamai-1.21.2/dunamai/__init__.py
--- old/dunamai-1.21.1/dunamai/__init__.py 2024-05-03 17:00:19.560035000 +0200
+++ new/dunamai-1.21.2/dunamai/__init__.py 2024-06-27 05:28:41.888780600 +0200
@@ -64,6 +64,11 @@
""".strip()
_VALID_PVP = r"^\d+(\.\d+)*(-[a-zA-Z0-9]+)*$"
+_TIMESTAMP_GENERIC = "%Y-%m-%dT%H:%M:%S.%f%z"
+_TIMESTAMP_GENERIC_SPACE = "%Y-%m-%d %H:%M:%S.%f%z"
+_TIMESTAMP_GIT_ISO_STRICT = "%Y-%m-%dT%H:%M:%S%z"
+_TIMESTAMP_GIT_ISO = "%Y-%m-%d %H:%M:%S %z"
+
_T = TypeVar("_T")
@@ -186,9 +191,7 @@
return ""
-def _pattern_error(
- primary: str, pattern: Union[str, Pattern], tags: Optional[Sequence[str]] = None
-) -> str:
+def _pattern_error(primary: str, pattern: Union[str, Pattern], tags: Optional[Sequence[str]] = None) -> str:
parts = [primary, "Pattern:\n{}".format(pattern)]
if tags is not None:
@@ -214,11 +217,7 @@
)
output = result.stdout.decode().strip()
if codes and result.returncode not in codes:
- raise RuntimeError(
- "The command '{}' returned code {}. Output:\n{}".format(
- command, result.returncode, output
- )
- )
+ raise RuntimeError("The command '{}' returned code {}. Output:\n{}".format(command, result.returncode, output))
return (result.returncode, output)
@@ -267,9 +266,7 @@
except re.error as e:
raise re.error(
_pattern_error(
- "The pattern is an invalid regular expression: {}".format(
- e.msg # type: ignore
- ),
+ "The pattern is an invalid regular expression: {}".format(e.msg), # type: ignore
pattern,
),
e.pattern, # type: ignore
@@ -283,9 +280,7 @@
if base is not None:
break
except IndexError:
- raise ValueError(
- _pattern_error("The pattern did not include required capture group 'base'", pattern)
- )
+ raise ValueError(_pattern_error("The pattern did not include required capture group 'base'", pattern))
if pattern_match is None or base is None:
if latest_source:
raise ValueError(
@@ -315,9 +310,7 @@
except ValueError:
raise ValueError("Epoch '{}' is not a valid number".format(epoch))
- return _MatchedVersionPattern(
- source, base, stage_revision, newer_unmatched_tags, tagged_metadata, epoch
- )
+ return _MatchedVersionPattern(source, base, stage_revision, newer_unmatched_tags, tagged_metadata, epoch)
def _blank(value: Optional[_T], default: _T) -> _T:
@@ -375,9 +368,7 @@
if code != 0:
if expected_vcs == Vcs.Git and dubious_ownership_flag in msg:
raise RuntimeError(dubious_ownership_error)
- raise RuntimeError(
- "This does not appear to be a {} project".format(expected_vcs.value.title())
- )
+ raise RuntimeError("This does not appear to be a {} project".format(expected_vcs.value.title()))
return expected_vcs
else:
disproven = []
@@ -415,9 +406,7 @@
return None
-def _find_higher_file(
- name: str, start: Optional[Path], limit: Optional[str] = None
-) -> Optional[Path]:
+def _find_higher_file(name: str, start: Optional[Path], limit: Optional[str] = None) -> Optional[Path]:
"""
:param name: Bare name of a file we'd like to find.
:param limit: Give up if we find a file/folder with this name.
@@ -435,9 +424,7 @@
class _GitRefInfo:
- def __init__(
- self, ref: str, commit: str, creatordate: str, committerdate: str, taggerdate: str
- ):
+ def __init__(self, ref: str, commit: str, creatordate: str, committerdate: str, taggerdate: str):
self.fullref = ref
self.commit = commit
self.creatordate = self.normalize_git_dt(creatordate)
@@ -457,10 +444,7 @@
return _parse_git_timestamp_iso_strict(timestamp)
def __repr__(self):
- return (
- "_GitRefInfo(ref={!r}, commit={!r}, creatordate={!r},"
- " committerdate={!r}, taggerdate={!r})"
- ).format(
+ return ("_GitRefInfo(ref={!r}, commit={!r}, creatordate={!r}," " committerdate={!r}, taggerdate={!r})").format(
self.fullref, self.commit_offset, self.creatordate, self.committerdate, self.taggerdate
)
@@ -478,9 +462,7 @@
return self.tag_topo_lookup[self.fullref]
except KeyError:
raise RuntimeError(
- "Unable to determine commit offset for ref {} in data: {}".format(
- self.fullref, self.tag_topo_lookup
- )
+ "Unable to determine commit offset for ref {} in data: {}".format(self.fullref, self.tag_topo_lookup)
)
@property
@@ -499,19 +481,15 @@
return "refs/tags/{}".format(ref)
@staticmethod
- def from_git_tag_topo_order(
- tag_branch: str, git_version: List[int], path: Optional[Path]
- ) -> Mapping[str, int]:
- cmd = (
- '{} --simplify-by-decoration --topo-order --decorate=full {} "--format=%H%d"'
- ).format(_git_log(git_version), tag_branch)
+ def from_git_tag_topo_order(tag_branch: str, git_version: List[int], path: Optional[Path]) -> Mapping[str, int]:
+ cmd = ('{} --simplify-by-decoration --topo-order --decorate=full {} "--format=%H%d"').format(
+ _git_log(git_version), tag_branch
+ )
if git_version >= [2, 16]:
cmd += " --decorate-refs=refs/tags/"
code, logmsg = _run_cmd(cmd, path)
- filtered_lines = [
- x for x in logmsg.strip().splitlines(keepends=False) if " (" not in x or "tag: " in x
- ]
+ filtered_lines = [x for x in logmsg.strip().splitlines(keepends=False) if " (" not in x or "tag: " in x]
tag_lookup = {}
for tag_offset, line in enumerate(filtered_lines):
@@ -522,9 +500,7 @@
if tags:
# remove trailing ')'
tags = tags[:-1]
- taglist = [
- tag.strip() for tag in tags.split(", ") if tag.strip().startswith("tag: ")
- ]
+ taglist = [tag.strip() for tag in tags.split(", ") if tag.strip().startswith("tag: ")]
taglist = [tag.split()[-1] for tag in taglist]
taglist = [_GitRefInfo.normalize_tag_ref(tag) for tag in taglist]
for tag in taglist:
@@ -637,9 +613,7 @@
def __eq__(self, other: Any) -> bool:
if not isinstance(other, Version):
- raise TypeError(
- "Cannot compare Version with type {}".format(other.__class__.__qualname__)
- )
+ raise TypeError("Cannot compare Version with type {}".format(other.__class__.__qualname__))
return (
self.base == other.base
and self.stage == other.stage
@@ -676,9 +650,7 @@
def __lt__(self, other: Any) -> bool:
if not isinstance(other, Version):
- raise TypeError(
- "Cannot compare Version with type {}".format(other.__class__.__qualname__)
- )
+ raise TypeError("Cannot compare Version with type {}".format(other.__class__.__qualname__))
import packaging.version as pv
@@ -863,9 +835,7 @@
failed = False
try:
- matched_pattern = _match_version_pattern(
- pattern, [normalized], True, strict=True, pattern_prefix=None
- )
+ matched_pattern = _match_version_pattern(pattern, [normalized], True, strict=True, pattern_prefix=None)
except ValueError:
failed = True
@@ -1087,9 +1057,7 @@
vcs=vcs,
)
- matched_pattern = _match_version_pattern(
- pattern, [tag], latest_tag, strict, pattern_prefix
- )
+ matched_pattern = _match_version_pattern(pattern, [tag], latest_tag, strict, pattern_prefix)
if matched_pattern is None:
return cls._fallback(
strict,
@@ -1144,28 +1112,20 @@
branch = msg
code, msg = _run_cmd(
- '{} -n 1 --format="format:{}"'.format(
- _git_log(git_version), "%H" if full_commit else "%h"
- ),
+ '{} -n 1 --format="format:{}"'.format(_git_log(git_version), "%H" if full_commit else "%h"),
path,
codes=[0, 128],
)
if code == 128:
- return cls._fallback(
- strict, distance=0, dirty=True, branch=branch, concerns=concerns, vcs=vcs
- )
+ return cls._fallback(strict, distance=0, dirty=True, branch=branch, concerns=concerns, vcs=vcs)
commit = msg
timestamp = None
if git_version < [2, 2]:
- code, msg = _run_cmd(
- '{} -n 1 --pretty=format:"%ci"'.format(_git_log(git_version)), path
- )
+ code, msg = _run_cmd('{} -n 1 --pretty=format:"%ci"'.format(_git_log(git_version)), path)
timestamp = _parse_git_timestamp_iso(msg)
else:
- code, msg = _run_cmd(
- '{} -n 1 --pretty=format:"%cI"'.format(_git_log(git_version)), path
- )
+ code, msg = _run_cmd('{} -n 1 --pretty=format:"%cI"'.format(_git_log(git_version)), path)
timestamp = _parse_git_timestamp_iso_strict(msg)
code, msg = _run_cmd("git describe --always --dirty", path)
@@ -1177,9 +1137,7 @@
dirty = True
if git_version < [2, 7]:
- code, msg = _run_cmd(
- 'git for-each-ref "refs/tags/**" --format "%(refname)" --sort -creatordate', path
- )
+ code, msg = _run_cmd('git for-each-ref "refs/tags/**" --format "%(refname)" --sort -creatordate', path)
if not msg:
try:
code, msg = _run_cmd("git rev-list --count HEAD", path)
@@ -1197,13 +1155,10 @@
vcs=vcs,
)
tags = [line.replace("refs/tags/", "") for line in msg.splitlines()]
- matched_pattern = _match_version_pattern(
- pattern, tags, latest_tag, strict, pattern_prefix
- )
+ matched_pattern = _match_version_pattern(pattern, tags, latest_tag, strict, pattern_prefix)
else:
code, msg = _run_cmd(
- 'git for-each-ref "refs/tags/**" --merged {}'.format(tag_branch)
- + ' --format "%(refname)'
+ 'git for-each-ref "refs/tags/**" --merged {}'.format(tag_branch) + ' --format "%(refname)'
"@{%(objectname)"
"@{%(creatordate:iso-strict)"
"@{%(*committerdate:iso-strict)"
@@ -1238,9 +1193,7 @@
detailed_tags.append(_GitRefInfo(*parts).with_tag_topo_lookup(tag_topo_lookup))
tags = [t.ref for t in sorted(detailed_tags, key=lambda x: x.sort_key, reverse=True)]
- matched_pattern = _match_version_pattern(
- pattern, tags, latest_tag, strict, pattern_prefix
- )
+ matched_pattern = _match_version_pattern(pattern, tags, latest_tag, strict, pattern_prefix)
if matched_pattern is None:
try:
@@ -1325,9 +1278,7 @@
branch = data.get("branch")
if tag is None or tag == "null":
- return cls._fallback(
- strict, distance=distance, commit=commit, branch=branch, vcs=vcs
- )
+ return cls._fallback(strict, distance=distance, commit=commit, branch=branch, vcs=vcs)
all_tags_file = _find_higher_file(".hgtags", path, ".hg")
if all_tags_file is None:
@@ -1341,9 +1292,7 @@
continue
all_tags.append(parts[1])
- matched_pattern = _match_version_pattern(
- pattern, all_tags, latest_tag, strict, pattern_prefix
- )
+ matched_pattern = _match_version_pattern(pattern, all_tags, latest_tag, strict, pattern_prefix)
if matched_pattern is None:
return cls._fallback(
strict,
@@ -1376,9 +1325,7 @@
code, msg = _run_cmd("hg branch", path)
branch = msg
- code, msg = _run_cmd(
- 'hg id --template "{}"'.format("{id}" if full_commit else "{id|short}"), path
- )
+ code, msg = _run_cmd('hg id --template "{}"'.format("{id}" if full_commit else "{id|short}"), path)
commit = msg if set(msg) != {"0"} else None
code, msg = _run_cmd('hg log --limit 1 --template "{date|rfc3339date}"', path)
@@ -1485,9 +1432,7 @@
distance = int(msg)
except Exception:
distance = 0
- return cls._fallback(
- strict, distance=distance, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs
- )
+ return cls._fallback(strict, distance=distance, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs)
tags = msg.splitlines()
matched_pattern = _match_version_pattern(pattern, tags, latest_tag, strict, pattern_prefix)
@@ -1569,9 +1514,7 @@
timestamp = _parse_timestamp(msg)
if not commit:
- return cls._fallback(
- strict, distance=0, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs
- )
+ return cls._fallback(strict, distance=0, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs)
code, msg = _run_cmd('svn ls -v -r {} "{}/{}"'.format(commit, url, tag_dir), path)
lines = [line.split(maxsplit=5) for line in msg.splitlines()[1:]]
tags_to_revs = {line[-1].strip("/"): int(line[0]) for line in lines}
@@ -1580,14 +1523,10 @@
distance = int(commit)
except Exception:
distance = 0
- return cls._fallback(
- strict, distance=distance, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs
- )
+ return cls._fallback(strict, distance=distance, commit=commit, dirty=dirty, timestamp=timestamp, vcs=vcs)
tags_to_sources_revs = {}
for tag, rev in tags_to_revs.items():
- code, msg = _run_cmd(
- 'svn log -v "{}/{}/{}" --stop-on-copy'.format(url, tag_dir, tag), path
- )
+ code, msg = _run_cmd('svn log -v "{}/{}/{}" --stop-on-copy'.format(url, tag_dir, tag), path)
for line in msg.splitlines():
match = re.search(r"A /{}/{} \(from .+?:(\d+)\)".format(tag_dir, tag), line)
if match:
@@ -1687,11 +1626,7 @@
timestamp=timestamp,
vcs=vcs,
)
- tags_to_revs = {
- line.split()[0]: int(line.split()[1])
- for line in msg.splitlines()
- if line.split()[1] != "?"
- }
+ tags_to_revs = {line.split()[0]: int(line.split()[1]) for line in msg.splitlines() if line.split()[1] != "?"}
tags = [x[1] for x in sorted([(v, k) for k, v in tags_to_revs.items()], reverse=True)]
matched_pattern = _match_version_pattern(pattern, tags, latest_tag, strict, pattern_prefix)
@@ -1756,9 +1691,7 @@
code, msg = _run_cmd("fossil branch current", path)
branch = msg
- code, msg = _run_cmd(
- "fossil sql \"SELECT value FROM vvar WHERE name = 'checkout-hash' LIMIT 1\"", path
- )
+ code, msg = _run_cmd("fossil sql \"SELECT value FROM vvar WHERE name = 'checkout-hash' LIMIT 1\"", path)
commit = msg.strip("'")
code, msg = _run_cmd(
@@ -1825,8 +1758,7 @@
)
tags_to_distance = [
- (line.rsplit(",", 1)[0][5:-1], int(line.rsplit(",", 1)[1]) - 1)
- for line in msg.splitlines()
+ (line.rsplit(",", 1)[0][5:-1], int(line.rsplit(",", 1)[1]) - 1) for line in msg.splitlines()
]
matched_pattern = _match_version_pattern(
@@ -1934,7 +1866,7 @@
tag_state = line.split("State ", 1)[1]
elif line.startswith("Date:"):
tag_timestamp = _parse_timestamp(
- line.split("Date: ", 1)[1].replace(" UTC", "Z"), space=True
+ line.split("Date: ", 1)[1].replace(" UTC", "Z"), format=_TIMESTAMP_GENERIC_SPACE
)
elif line.startswith(" "):
tag_message += line[4:]
@@ -1956,9 +1888,7 @@
else:
tag_message += line
if tag_after_header:
- tag_meta.append(
- {"state": tag_state, "timestamp": tag_timestamp, "message": tag_message.strip()}
- )
+ tag_meta.append({"state": tag_state, "timestamp": tag_timestamp, "message": tag_message.strip()})
tag_meta_by_msg = {} # type: dict
for meta in tag_meta:
@@ -1968,10 +1898,7 @@
):
tag_meta_by_msg[meta["message"]] = meta
- tags = [
- t["message"]
- for t in sorted(tag_meta_by_msg.values(), key=lambda x: x["timestamp"], reverse=True)
- ]
+ tags = [t["message"] for t in sorted(tag_meta_by_msg.values(), key=lambda x: x["timestamp"], reverse=True)]
matched_pattern = _match_version_pattern(pattern, tags, latest_tag, strict, pattern_prefix)
if matched_pattern is None:
@@ -2377,21 +2304,16 @@
def _parse_git_timestamp_iso_strict(raw: str) -> dt.datetime:
# Remove colon from timezone offset for pre-3.7 Python:
compat = re.sub(r"(.*T.*[-+]\d+):(\d+)", r"\1\2", raw)
- return dt.datetime.strptime(compat, "%Y-%m-%dT%H:%M:%S%z")
+ return _parse_timestamp(compat, _TIMESTAMP_GIT_ISO_STRICT)
def _parse_git_timestamp_iso(raw: str) -> dt.datetime:
# Remove colon from timezone offset for pre-3.7 Python:
compat = re.sub(r"(.* .* [-+]\d+):(\d+)", r"\1\2", raw)
- return dt.datetime.strptime(compat, "%Y-%m-%d %H:%M:%S %z")
-
+ return _parse_timestamp(compat, _TIMESTAMP_GIT_ISO)
-def _parse_timestamp(raw: str, space: bool = False) -> dt.datetime:
- if space:
- format = "%Y-%m-%d %H:%M:%S.%f%z"
- else:
- format = "%Y-%m-%dT%H:%M:%S.%f%z"
+def _parse_timestamp(raw: str, format: str = _TIMESTAMP_GENERIC) -> dt.datetime:
# Normalize "Z" for pre-3.7 compatibility:
normalized = re.sub(r"Z$", "+0000", raw)
# Truncate %f to six digits:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/dunamai/__main__.py new/dunamai-1.21.2/dunamai/__main__.py
--- old/dunamai-1.21.1/dunamai/__main__.py 2024-04-29 19:49:58.040704500 +0200
+++ new/dunamai-1.21.2/dunamai/__main__.py 2024-06-27 04:59:56.764542800 +0200
@@ -91,10 +91,7 @@
"action": "store_true",
"dest": "strict",
"default": False,
- "help": (
- "Elevate warnings to errors."
- " When there are no tags, fail instead of falling back to 0.0.0"
- ),
+ "help": ("Elevate warnings to errors." " When there are no tags, fail instead of falling back to 0.0.0"),
},
{
"triggers": ["--path"],
@@ -269,9 +266,7 @@
path: Optional[Path],
pattern_prefix: Optional[str],
) -> None:
- version = Version.from_vcs(
- vcs, pattern, latest_tag, tag_dir, tag_branch, full_commit, strict, path, pattern_prefix
- )
+ version = Version.from_vcs(vcs, pattern, latest_tag, tag_dir, tag_branch, full_commit, strict, path, pattern_prefix)
for concern in version.concerns:
print("Warning: {}".format(concern.message()), file=sys.stderr)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/pyproject.toml new/dunamai-1.21.2/pyproject.toml
--- old/dunamai-1.21.1/pyproject.toml 2024-05-04 04:32:10.808475500 +0200
+++ new/dunamai-1.21.2/pyproject.toml 2024-06-27 05:57:05.618044400 +0200
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dunamai"
-version = "1.21.1"
+version = "1.21.2"
description = "Dynamic version generation"
license = "MIT"
authors = ["Matthew T. Kennerly "]
@@ -43,10 +43,10 @@
dunamai = 'dunamai.__main__:main'
[tool.black]
-line-length = 100
+line-length = 120
[tool.ruff]
-line-length = 100
+line-length = 120
extend-select = ["W605", "N"]
[build-system]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/tests/integration/test_dunamai.py new/dunamai-1.21.2/tests/integration/test_dunamai.py
--- old/dunamai-1.21.1/tests/integration/test_dunamai.py 2024-05-03 16:48:34.291910600 +0200
+++ new/dunamai-1.21.2/tests/integration/test_dunamai.py 2024-06-27 04:59:57.113332700 +0200
@@ -59,9 +59,7 @@
return inner
-def make_from_callback(
- function: Callable, clear: bool = True, chronological: bool = True
-) -> Callable:
+def make_from_callback(function: Callable, clear: bool = True, chronological: bool = True) -> Callable:
def inner(*args, fresh: bool = False, **kwargs):
version = function(*args, **kwargs)
if fresh:
@@ -124,9 +122,7 @@
# Detect dirty if untracked files
(vcs / "bar.txt").write_text("bye")
assert from_vcs() == Version("0.0.0", distance=1, dirty=True, branch=b)
- assert from_vcs(ignore_untracked=True) == Version(
- "0.0.0", distance=1, dirty=False, branch=b
- )
+ assert from_vcs(ignore_untracked=True) == Version("0.0.0", distance=1, dirty=False, branch=b)
# Once the untracked file is removed we are no longer dirty
(vcs / "bar.txt").unlink()
@@ -159,12 +155,8 @@
assert from_explicit_vcs(Vcs.Any) == Version("0.1.0", dirty=False, branch=b)
assert from_explicit_vcs(Vcs.Git) == Version("0.1.0", dirty=False, branch=b)
assert run("dunamai from any --bump") == "0.1.0"
- assert run('dunamai from git --format "{commit}"') != run(
- 'dunamai from git --format "{commit}" --full-commit'
- )
- assert run('dunamai from any --format "{commit}"') != run(
- 'dunamai from any --format "{commit}" --full-commit'
- )
+ assert run('dunamai from git --format "{commit}"') != run('dunamai from git --format "{commit}" --full-commit')
+ assert run('dunamai from any --format "{commit}"') != run('dunamai from any --format "{commit}" --full-commit')
if not legacy:
# Verify tags with '/' work
@@ -425,9 +417,7 @@
assert Version.from_any_vcs() == detected
- assert (
- Version.from_git(full_commit=True).commit == "8fe614dbf9e767e70442ab8f56e99bd08d7e782d"
- )
+ assert Version.from_git(full_commit=True).commit == "8fe614dbf9e767e70442ab8f56e99bd08d7e782d"
with pytest.raises(RuntimeError):
Version.from_git(strict=True)
@@ -549,9 +539,7 @@
assert run('dunamai from mercurial --format "{commit}"') != run(
'dunamai from mercurial --format "{commit}" --full-commit'
)
- assert run('dunamai from any --format "{commit}"') != run(
- 'dunamai from any --format "{commit}" --full-commit'
- )
+ assert run('dunamai from any --format "{commit}"') != run('dunamai from any --format "{commit}" --full-commit')
run("hg tag v0.1.0")
assert from_vcs() == Version("0.1.0", dirty=False, branch=b)
@@ -662,9 +650,7 @@
assert from_vcs(path=vcs) == Version("0.1.0", dirty=False)
-@pytest.mark.skipif(
- None in [shutil.which("svn"), shutil.which("svnadmin")], reason="Requires Subversion"
-)
+@pytest.mark.skipif(None in [shutil.which("svn"), shutil.which("svnadmin")], reason="Requires Subversion")
def test__version__from_subversion(tmp_path) -> None:
vcs = tmp_path / "dunamai-svn"
vcs.mkdir()
@@ -706,9 +692,7 @@
# Two commits, but still no tag. Version should still be 0.0.0.
assert from_vcs() == Version("0.0.0", distance=2, commit="2", dirty=False)
- run(
- 'svn copy {0}/trunk {0}/tags/v0.1.0 -m "Tag 1"'.format(vcs_srv_uri)
- ) # commit 3 and first tag!
+ run('svn copy {0}/trunk {0}/tags/v0.1.0 -m "Tag 1"'.format(vcs_srv_uri)) # commit 3 and first tag!
run("svn update")
# 3 commits, one tag (v.0.1.0), version should be 0.1.0.
@@ -753,9 +737,7 @@
# #3), so version should be 0.1.0.
run("svn update -r 3")
assert from_vcs() == Version("0.1.0", distance=0, commit="3", dirty=False)
- assert from_vcs(latest_tag=True) == Version(
- "0.1.0", distance=0, commit="3", dirty=False
- )
+ assert from_vcs(latest_tag=True) == Version("0.1.0", distance=0, commit="3", dirty=False)
assert from_vcs(path=vcs) == Version("0.1.0", distance=0, commit="3", dirty=False)
@@ -792,9 +774,7 @@
run("bzr add .")
run('bzr commit -m "Second"')
assert from_vcs() == Version("0.1.0", distance=1, commit="2", dirty=False, branch=b)
- assert from_any_vcs_unmocked() == Version(
- "0.1.0", distance=1, commit="2", dirty=False, branch=b
- )
+ assert from_any_vcs_unmocked() == Version("0.1.0", distance=1, commit="2", dirty=False, branch=b)
run("bzr tag unmatched")
assert from_vcs() == Version("0.1.0", distance=1, commit="2", dirty=False, branch=b)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/tests/unit/test_dunamai.py new/dunamai-1.21.2/tests/unit/test_dunamai.py
--- old/dunamai-1.21.1/tests/unit/test_dunamai.py 2024-04-29 18:40:44.492175000 +0200
+++ new/dunamai-1.21.2/tests/unit/test_dunamai.py 2024-06-27 04:59:57.105827800 +0200
@@ -81,9 +81,7 @@
def test__version__init() -> None:
- v = Version(
- "1", stage=("a", 2), distance=3, commit="abc", dirty=True, tagged_metadata="def", epoch=4
- )
+ v = Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True, tagged_metadata="def", epoch=4)
assert v.base == "1"
assert v.stage == "a"
assert v.revision == 2
@@ -136,34 +134,22 @@
def test__version__serialize__pep440() -> None:
assert Version("0.1.0").serialize() == "0.1.0"
- assert (
- Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize()
- == "1a2.post3.dev0+abc"
- )
+ assert Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize() == "1a2.post3.dev0+abc"
assert (
Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize(dirty=True)
== "1a2.post3.dev0+abc.dirty"
)
assert (
- Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize(metadata=False)
- == "1a2.post3.dev0"
+ Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize(metadata=False) == "1a2.post3.dev0"
)
assert (
- Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize(
- metadata=False, dirty=True
- )
+ Version("1", stage=("a", 2), distance=3, commit="abc", dirty=True).serialize(metadata=False, dirty=True)
== "1a2.post3.dev0"
)
- assert (
- Version("1", stage=("a", 0), distance=3, commit="abc", dirty=False).serialize()
- == "1a0.post3.dev0+abc"
- )
+ assert Version("1", stage=("a", 0), distance=3, commit="abc", dirty=False).serialize() == "1a0.post3.dev0+abc"
assert Version("1", stage=("a", 2), distance=0, commit="abc", dirty=False).serialize() == "1a2"
- assert (
- Version("1", stage=("a", 2), distance=3, commit="000", dirty=False).serialize()
- == "1a2.post3.dev0+000"
- )
+ assert Version("1", stage=("a", 2), distance=3, commit="000", dirty=False).serialize() == "1a2.post3.dev0+000"
assert Version("1", stage=("a", None)).serialize() == "1a0"
assert Version("1", stage=("b", 2)).serialize() == "1b2"
@@ -179,9 +165,7 @@
assert Version("0.1.0", stage=("post", 1)).serialize() == "0.1.0.post1"
assert Version("0.1.0", stage=("post", 1), distance=3).serialize() == "0.1.0.post1.dev3"
- assert (
- Version("0.1.0", stage=("post", 1), distance=3).serialize(bump=True) == "0.1.0.post2.dev3"
- )
+ assert Version("0.1.0", stage=("post", 1), distance=3).serialize(bump=True) == "0.1.0.post2.dev3"
assert Version("0.1.0", stage=("dev", 1)).serialize() == "0.1.0.dev1"
assert Version("0.1.0", stage=("dev", 1), distance=3).serialize() == "0.1.0.dev4"
assert Version("0.1.0", stage=("dev", 1), distance=3).serialize(bump=True) == "0.1.0.dev5"
@@ -192,15 +176,11 @@
assert Version("0.1.0").serialize(style=style) == "0.1.0"
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(style=style)
== "0.1.0-alpha.2.post.3+abc"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(
- dirty=True, style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(dirty=True, style=style)
== "0.1.0-alpha.2.post.3+abc.dirty"
)
assert (
@@ -217,21 +197,15 @@
)
assert (
- Version("0.1.0", stage=("alpha", 0), distance=3, commit="abc", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 0), distance=3, commit="abc", dirty=False).serialize(style=style)
== "0.1.0-alpha.0.post.3+abc"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=0, commit="abc", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=0, commit="abc", dirty=False).serialize(style=style)
== "0.1.0-alpha.2"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="000", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="000", dirty=False).serialize(style=style)
== "0.1.0-alpha.2.post.3+000"
)
@@ -242,13 +216,9 @@
assert Version("0.1.0").serialize(style=style, bump=True) == "0.1.0"
assert Version("0.1.0", distance=3).serialize(style=style, bump=True) == "0.1.1-pre.3"
assert (
- Version("0.1.0", stage=("alpha", None), distance=3).serialize(style=style, bump=True)
- == "0.1.0-alpha.2.pre.3"
- )
- assert (
- Version("0.1.0", stage=("beta", 2), distance=4).serialize(style=style, bump=True)
- == "0.1.0-beta.3.pre.4"
+ Version("0.1.0", stage=("alpha", None), distance=3).serialize(style=style, bump=True) == "0.1.0-alpha.2.pre.3"
)
+ assert Version("0.1.0", stage=("beta", 2), distance=4).serialize(style=style, bump=True) == "0.1.0-beta.3.pre.4"
assert Version("0.1.0", epoch=2).serialize(style=style) == "0.1.0"
@@ -258,15 +228,11 @@
assert Version("0.1.0").serialize(style=style) == "0.1.0"
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(style=style)
== "0.1.0-alpha-2-post-3-abc"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(
- dirty=True, style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="abc", dirty=True).serialize(dirty=True, style=style)
== "0.1.0-alpha-2-post-3-abc-dirty"
)
assert (
@@ -283,21 +249,15 @@
)
assert (
- Version("0.1.0", stage=("alpha", 0), distance=3, commit="abc", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 0), distance=3, commit="abc", dirty=False).serialize(style=style)
== "0.1.0-alpha-0-post-3-abc"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=0, commit="abc", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=0, commit="abc", dirty=False).serialize(style=style)
== "0.1.0-alpha-2"
)
assert (
- Version("0.1.0", stage=("alpha", 2), distance=3, commit="000", dirty=False).serialize(
- style=style
- )
+ Version("0.1.0", stage=("alpha", 2), distance=3, commit="000", dirty=False).serialize(style=style)
== "0.1.0-alpha-2-post-3-000"
)
@@ -308,13 +268,9 @@
assert Version("0.1.0").serialize(style=style, bump=True) == "0.1.0"
assert Version("0.1.0", distance=3).serialize(style=style, bump=True) == "0.1.1-pre-3"
assert (
- Version("0.1.0", stage=("alpha", None), distance=3).serialize(style=style, bump=True)
- == "0.1.0-alpha-2-pre-3"
- )
- assert (
- Version("0.1.0", stage=("beta", 2), distance=4).serialize(style=style, bump=True)
- == "0.1.0-beta-3-pre-4"
+ Version("0.1.0", stage=("alpha", None), distance=3).serialize(style=style, bump=True) == "0.1.0-alpha-2-pre-3"
)
+ assert Version("0.1.0", stage=("beta", 2), distance=4).serialize(style=style, bump=True) == "0.1.0-beta-3-pre-4"
assert Version("0.1.0", epoch=2).serialize(style=style) == "0.1.0"
@@ -329,18 +285,11 @@
assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=False) == "0.1.0a1"
assert Version("0.1.0", distance=1, commit="abc").serialize() == "0.1.0.post1.dev0+abc"
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=True)
- == "0.1.0.post1.dev0+abc"
- )
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=False) == "0.1.0.post1.dev0"
- )
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=True) == "0.1.0.post1.dev0+abc"
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=False) == "0.1.0.post1.dev0"
assert (
- Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(
- tagged_metadata=True
- )
+ Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(tagged_metadata=True)
== "0.1.0.post1.dev0+def.abc"
)
@@ -352,29 +301,15 @@
assert Version("0.1.0").serialize(metadata=False, style=style) == "0.1.0"
assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(style=style) == "0.1.0-a.1"
- assert (
- Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=True, style=style)
- == "0.1.0-a.1+abc"
- )
- assert (
- Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=False, style=style)
- == "0.1.0-a.1"
- )
+ assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=True, style=style) == "0.1.0-a.1+abc"
+ assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=False, style=style) == "0.1.0-a.1"
assert Version("0.1.0", distance=1, commit="abc").serialize(style=style) == "0.1.0-post.1+abc"
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=True, style=style)
- == "0.1.0-post.1+abc"
- )
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=False, style=style)
- == "0.1.0-post.1"
- )
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=True, style=style) == "0.1.0-post.1+abc"
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=False, style=style) == "0.1.0-post.1"
assert (
- Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(
- style=style, tagged_metadata=True
- )
+ Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(style=style, tagged_metadata=True)
== "0.1.0-post.1+def.abc"
)
@@ -386,29 +321,15 @@
assert Version("0.1.0").serialize(metadata=False, style=style) == "0.1.0"
assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(style=style) == "0.1.0-a-1"
- assert (
- Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=True, style=style)
- == "0.1.0-a-1-abc"
- )
- assert (
- Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=False, style=style)
- == "0.1.0-a-1"
- )
+ assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=True, style=style) == "0.1.0-a-1-abc"
+ assert Version("0.1.0", stage=("a", 1), commit="abc").serialize(metadata=False, style=style) == "0.1.0-a-1"
assert Version("0.1.0", distance=1, commit="abc").serialize(style=style) == "0.1.0-post-1-abc"
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=True, style=style)
- == "0.1.0-post-1-abc"
- )
- assert (
- Version("0.1.0", distance=1, commit="abc").serialize(metadata=False, style=style)
- == "0.1.0-post-1"
- )
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=True, style=style) == "0.1.0-post-1-abc"
+ assert Version("0.1.0", distance=1, commit="abc").serialize(metadata=False, style=style) == "0.1.0-post-1"
assert (
- Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(
- style=style, tagged_metadata=True
- )
+ Version("0.1.0", distance=1, commit="abc", tagged_metadata="def").serialize(style=style, tagged_metadata=True)
== "0.1.0-post-1-def-abc"
)
@@ -436,15 +357,10 @@
assert Version("0.1.0", dirty=False).serialize(dirty=True, style=style) == "0.1.0"
assert Version("0.1.0", dirty=True).serialize(metadata=True, style=style) == "0.1.0"
- assert (
- Version("0.1.0", dirty=True).serialize(metadata=True, dirty=True, style=style)
- == "0.1.0+dirty"
- )
+ assert Version("0.1.0", dirty=True).serialize(metadata=True, dirty=True, style=style) == "0.1.0+dirty"
assert Version("0.1.0", dirty=True).serialize(metadata=False, style=style) == "0.1.0"
- assert (
- Version("0.1.0", dirty=True).serialize(metadata=False, dirty=True, style=style) == "0.1.0"
- )
+ assert Version("0.1.0", dirty=True).serialize(metadata=False, dirty=True, style=style) == "0.1.0"
def test__version__serialize__pvp_with_dirty() -> None:
@@ -456,22 +372,14 @@
assert Version("0.1.0", dirty=False).serialize(dirty=True, style=style) == "0.1.0"
assert Version("0.1.0", dirty=True).serialize(metadata=True, style=style) == "0.1.0"
- assert (
- Version("0.1.0", dirty=True).serialize(metadata=True, dirty=True, style=style)
- == "0.1.0-dirty"
- )
+ assert Version("0.1.0", dirty=True).serialize(metadata=True, dirty=True, style=style) == "0.1.0-dirty"
assert Version("0.1.0", dirty=True).serialize(metadata=False, style=style) == "0.1.0"
- assert (
- Version("0.1.0", dirty=True).serialize(metadata=False, dirty=True, style=style) == "0.1.0"
- )
+ assert Version("0.1.0", dirty=True).serialize(metadata=False, dirty=True, style=style) == "0.1.0"
def test__version__serialize__format_as_str() -> None:
- format = (
- "{base},{stage},{revision},{distance},{commit},{dirty}"
- ",{branch},{branch_escaped},{timestamp}"
- )
+ format = "{base},{stage},{revision},{distance},{commit},{dirty}" ",{branch},{branch_escaped},{timestamp}"
assert Version("0.1.0").serialize(format=format) == "0.1.0,,,0,,clean,,,"
assert (
Version(
@@ -569,9 +477,7 @@
def test__get_version__third_choice() -> None:
- assert get_version("dunamai_nonexistent_test", third_choice=lambda: Version("3")) == Version(
- "3"
- )
+ assert get_version("dunamai_nonexistent_test", third_choice=lambda: Version("3")) == Version("3")
def test__get_version__fallback() -> None:
@@ -793,9 +699,7 @@
assert serialize_pep440("1.2.3", metadata=[4]) == "1.2.3+4"
assert (
- serialize_pep440(
- "1.2.3", epoch=0, stage="a", revision=4, post=5, dev=6, metadata=["foo", "bar"]
- )
+ serialize_pep440("1.2.3", epoch=0, stage="a", revision=4, post=5, dev=6, metadata=["foo", "bar"])
== "0!1.2.3a4.post5.dev6+foo.bar"
)
@@ -818,10 +722,7 @@
assert serialize_semver("1.2.3", metadata=["foo", "bar"]) == "1.2.3+foo.bar"
assert serialize_semver("1.2.3", metadata=[4]) == "1.2.3+4"
- assert (
- serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"])
- == "1.2.3-alpha.4+foo.bar"
- )
+ assert serialize_semver("1.2.3", pre=["alpha", 4], metadata=["foo", "bar"]) == "1.2.3-alpha.4+foo.bar"
with pytest.raises(ValueError):
serialize_semver("foo")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/dunamai-1.21.1/tests/unit/test_main.py new/dunamai-1.21.2/tests/unit/test_main.py
--- old/dunamai-1.21.1/tests/unit/test_main.py 2024-04-29 19:48:05.295097400 +0200
+++ new/dunamai-1.21.2/tests/unit/test_main.py 2024-06-27 04:59:56.723363400 +0200
@@ -62,9 +62,7 @@
def test__parse_args__check():
- assert parse_args(["check", "0.1.0"]) == Namespace(
- command="check", version="0.1.0", style="pep440"
- )
+ assert parse_args(["check", "0.1.0"]) == Namespace(command="check", version="0.1.0", style="pep440")
assert parse_args(["check", "0.1.0", "--style", "semver"]).style == "semver"
assert parse_args(["check", "0.1.0", "--style", "pvp"]).style == "pvp"