From ae7ff6a25b77fcddd022ff02d2ece75d00736932 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 12:43:24 -0400 Subject: [PATCH 01/21] Install `editables` in test env So that `test_editable_mode_hatch` won't fail due to https://github.com/pypa/hatch/pull/1255 --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index b24e124..1065fab 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ minversion = 3.3.0 [testenv] deps = build>=0.7 # Must be a version that builds wheels from sdists + editables hatchling setuptools>=42 pip From 3aab50782733faad448d3ffd45d9e2f8fbaec49f Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Wed, 13 Mar 2024 13:46:40 +0100 Subject: [PATCH 02/21] improve error message when a tag is not found and match is set --- src/versioningit/git.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/versioningit/git.py b/src/versioningit/git.py index 75de4c1..f5d4eb1 100644 --- a/src/versioningit/git.py +++ b/src/versioningit/git.py @@ -346,7 +346,11 @@ def describe_git_core( distance = int(repo.read("rev-list", "--count", "HEAD")) - 1 rev = description else: - raise NoTagError("`git describe` could not find a tag") + if len(opts.match): + msg = f"`git describe` could not find a tag matching {opts.match}" + else: + msg = "`git describe` could not find a tag" + raise NoTagError(msg) if distance and dirty: state = "distance-dirty" elif distance: From 8ce795763e158e93921d4242b4c579f2dad175d7 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 12:08:56 -0400 Subject: [PATCH 03/21] Show all describe options in message --- .pre-commit-config.yaml | 2 +- src/versioningit/git.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0d9f21..36a8a77 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: exclude: ^test/data - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: diff --git a/src/versioningit/git.py b/src/versioningit/git.py index f5d4eb1..13efca5 100644 --- a/src/versioningit/git.py +++ b/src/versioningit/git.py @@ -3,6 +3,7 @@ from datetime import datetime from pathlib import Path import re +import shlex import subprocess from typing import Any, NamedTuple, Optional from .core import VCSDescription @@ -346,11 +347,8 @@ def describe_git_core( distance = int(repo.read("rev-list", "--count", "HEAD")) - 1 rev = description else: - if len(opts.match): - msg = f"`git describe` could not find a tag matching {opts.match}" - else: - msg = "`git describe` could not find a tag" - raise NoTagError(msg) + argstr = "".join(" " + shlex.quote(a) for a in opts.as_args()) + raise NoTagError(f"`git describe{argstr}` could not find a tag") if distance and dirty: state = "distance-dirty" elif distance: From 7e902bd56a7dbfaa97a8c33b9157d82239453fc9 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 12:35:07 -0400 Subject: [PATCH 04/21] Update tests --- test/data/repos/errors/hatch-no-tag.json | 2 +- test/data/repos/errors/no-tag.json | 2 +- test/data/repos/git/default-version-onbuild-write.json | 4 ++-- test/data/repos/git/default-version.json | 4 ++-- test/test_methods/test_git.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/data/repos/errors/hatch-no-tag.json b/test/data/repos/errors/hatch-no-tag.json index 26fd050..db9361b 100644 --- a/test/data/repos/errors/hatch-no-tag.json +++ b/test/data/repos/errors/hatch-no-tag.json @@ -1,4 +1,4 @@ { "type": "NoTagError", - "message": "`git describe` could not find a tag" + "message": "`git describe --tags '--exclude=*'` could not find a tag" } diff --git a/test/data/repos/errors/no-tag.json b/test/data/repos/errors/no-tag.json index 26fd050..db9361b 100644 --- a/test/data/repos/errors/no-tag.json +++ b/test/data/repos/errors/no-tag.json @@ -1,4 +1,4 @@ { "type": "NoTagError", - "message": "`git describe` could not find a tag" + "message": "`git describe --tags '--exclude=*'` could not find a tag" } diff --git a/test/data/repos/git/default-version-onbuild-write.json b/test/data/repos/git/default-version-onbuild-write.json index e923fe8..5be8d9f 100644 --- a/test/data/repos/git/default-version-onbuild-write.json +++ b/test/data/repos/git/default-version-onbuild-write.json @@ -2,12 +2,12 @@ "version": "0.0.0+error", "next_version": { "type": "NoTagError", - "message": "`git describe` could not find a tag" + "message": "`git describe --tags '--match=v*'` could not find a tag" }, "logmsgs": [ { "level": "ERROR", - "message": "NoTagError: `git describe` could not find a tag" + "message": "NoTagError: `git describe --tags '--match=v*'` could not find a tag" }, { "level": "INFO", diff --git a/test/data/repos/git/default-version.json b/test/data/repos/git/default-version.json index 0f3e8d3..b3e5864 100644 --- a/test/data/repos/git/default-version.json +++ b/test/data/repos/git/default-version.json @@ -2,12 +2,12 @@ "version": "0.0.0+error", "next_version": { "type": "NoTagError", - "message": "`git describe` could not find a tag" + "message": "`git describe --tags` could not find a tag" }, "logmsgs": [ { "level": "ERROR", - "message": "NoTagError: `git describe` could not find a tag" + "message": "NoTagError: `git describe --tags` could not find a tag" }, { "level": "INFO", diff --git a/test/test_methods/test_git.py b/test/test_methods/test_git.py index 7fa25d2..13d60d9 100644 --- a/test/test_methods/test_git.py +++ b/test/test_methods/test_git.py @@ -81,7 +81,7 @@ def test_describe_git_no_tag(tmp_path: Path) -> None: shutil.unpack_archive(DATA_DIR / "repos" / "git" / "default-tag.zip", tmp_path) with pytest.raises(NoTagError) as excinfo: describe_git(project_dir=tmp_path, params={}) - assert str(excinfo.value) == "`git describe` could not find a tag" + assert str(excinfo.value) == "`git describe --tags` could not find a tag" @needs_git From 225e2438c00b18301be9fbc81cc4a9c853c6b618 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 13:41:16 -0400 Subject: [PATCH 05/21] Further improvements --- src/versioningit/git.py | 17 ++++++++++----- test/data/repos/errors/hatch-no-tag.json | 2 +- test/data/repos/errors/no-tag.json | 2 +- .../git/added-no-commits-default-tag.json | 12 ++++++++++- test/data/repos/git/default-tag.json | 8 ++++++- test/data/repos/git/default-version-bad.json | 4 ++-- .../git/default-version-onbuild-write.json | 4 ++-- test/data/repos/git/default-version.json | 4 ++-- test/test_methods/test_git.py | 21 +++++++++++++------ 9 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/versioningit/git.py b/src/versioningit/git.py index 13efca5..125396a 100644 --- a/src/versioningit/git.py +++ b/src/versioningit/git.py @@ -129,6 +129,11 @@ def as_args(self) -> list[str]: args.append(f"--exclude={pat}") return args + def as_cmdline_str(self) -> str: + return "git describe --long --dirty --always" + "".join( + " " + shlex.quote(a) for a in self.as_args() + ) + @dataclass class GitRepo: @@ -195,7 +200,9 @@ def describe(self, opts: DescribeOpts) -> str: except subprocess.CalledProcessError as e: # As far as I'm aware, this only happens in a repo without any # commits or a corrupted repo. - raise NoTagError(f"`git describe` command failed: {e.stderr.strip()}") + raise NoTagError( + f"`{opts.as_cmdline_str()}` command failed: {e.stderr.strip()}" + ) def get_branch(self) -> Optional[str]: """ @@ -339,16 +346,16 @@ def describe_git_core( except ValueError: if default_tag is not None: log.info( - "`git describe` returned a hash instead of a tag; falling back to" - " default tag %r", + "`%s` returned a hash instead of a tag; falling back to default" + " tag %r", + opts.as_cmdline_str(), default_tag, ) tag = default_tag distance = int(repo.read("rev-list", "--count", "HEAD")) - 1 rev = description else: - argstr = "".join(" " + shlex.quote(a) for a in opts.as_args()) - raise NoTagError(f"`git describe{argstr}` could not find a tag") + raise NoTagError(f"`{opts.as_cmdline_str()}` could not find a tag") if distance and dirty: state = "distance-dirty" elif distance: diff --git a/test/data/repos/errors/hatch-no-tag.json b/test/data/repos/errors/hatch-no-tag.json index db9361b..8cb1d08 100644 --- a/test/data/repos/errors/hatch-no-tag.json +++ b/test/data/repos/errors/hatch-no-tag.json @@ -1,4 +1,4 @@ { "type": "NoTagError", - "message": "`git describe --tags '--exclude=*'` could not find a tag" + "message": "`git describe --long --dirty --always --tags '--exclude=*'` could not find a tag" } diff --git a/test/data/repos/errors/no-tag.json b/test/data/repos/errors/no-tag.json index db9361b..8cb1d08 100644 --- a/test/data/repos/errors/no-tag.json +++ b/test/data/repos/errors/no-tag.json @@ -1,4 +1,4 @@ { "type": "NoTagError", - "message": "`git describe --tags '--exclude=*'` could not find a tag" + "message": "`git describe --long --dirty --always --tags '--exclude=*'` could not find a tag" } diff --git a/test/data/repos/git/added-no-commits-default-tag.json b/test/data/repos/git/added-no-commits-default-tag.json index 780dea1..2bfffba 100644 --- a/test/data/repos/git/added-no-commits-default-tag.json +++ b/test/data/repos/git/added-no-commits-default-tag.json @@ -1,4 +1,14 @@ { "version": "0.0.0+d20380119", - "next_version": "0.1.0" + "next_version": "0.1.0", + "logmsgs": [ + { + "level": "ERROR", + "message": "`git describe --long --dirty --always --tags` command failed: fatal: bad revision 'HEAD'" + }, + { + "level": "INFO", + "message": "Falling back to default tag 'v0.0.0'" + } + ] } diff --git a/test/data/repos/git/default-tag.json b/test/data/repos/git/default-tag.json index 7a15df2..2f694bb 100644 --- a/test/data/repos/git/default-tag.json +++ b/test/data/repos/git/default-tag.json @@ -1,4 +1,10 @@ { "version": "0.0.0.post2+gb4461bd", - "next_version": "0.1.0" + "next_version": "0.1.0", + "logmsgs": [ + { + "level": "INFO", + "message": "`git describe --long --dirty --always --tags` returned a hash instead of a tag; falling back to default tag 'v0.0.0'" + } + ] } diff --git a/test/data/repos/git/default-version-bad.json b/test/data/repos/git/default-version-bad.json index 66d81b8..9c3299a 100644 --- a/test/data/repos/git/default-version-bad.json +++ b/test/data/repos/git/default-version-bad.json @@ -2,12 +2,12 @@ "version": "1.1.1m", "next_version": { "type": "NoTagError", - "message": "`git describe` could not find a tag" + "message": "`git describe --long --dirty --always --tags` could not find a tag" }, "logmsgs": [ { "level": "ERROR", - "message": "NoTagError: `git describe` could not find a tag" + "message": "NoTagError: `git describe --long --dirty --always --tags` could not find a tag" }, { "level": "INFO", diff --git a/test/data/repos/git/default-version-onbuild-write.json b/test/data/repos/git/default-version-onbuild-write.json index 5be8d9f..f79911b 100644 --- a/test/data/repos/git/default-version-onbuild-write.json +++ b/test/data/repos/git/default-version-onbuild-write.json @@ -2,12 +2,12 @@ "version": "0.0.0+error", "next_version": { "type": "NoTagError", - "message": "`git describe --tags '--match=v*'` could not find a tag" + "message": "`git describe --long --dirty --always --tags '--match=v*'` could not find a tag" }, "logmsgs": [ { "level": "ERROR", - "message": "NoTagError: `git describe --tags '--match=v*'` could not find a tag" + "message": "NoTagError: `git describe --long --dirty --always --tags '--match=v*'` could not find a tag" }, { "level": "INFO", diff --git a/test/data/repos/git/default-version.json b/test/data/repos/git/default-version.json index b3e5864..26ee5e8 100644 --- a/test/data/repos/git/default-version.json +++ b/test/data/repos/git/default-version.json @@ -2,12 +2,12 @@ "version": "0.0.0+error", "next_version": { "type": "NoTagError", - "message": "`git describe --tags` could not find a tag" + "message": "`git describe --long --dirty --always --tags` could not find a tag" }, "logmsgs": [ { "level": "ERROR", - "message": "NoTagError: `git describe --tags` could not find a tag" + "message": "NoTagError: `git describe --long --dirty --always --tags` could not find a tag" }, { "level": "INFO", diff --git a/test/test_methods/test_git.py b/test/test_methods/test_git.py index 13d60d9..cb7a422 100644 --- a/test/test_methods/test_git.py +++ b/test/test_methods/test_git.py @@ -81,7 +81,10 @@ def test_describe_git_no_tag(tmp_path: Path) -> None: shutil.unpack_archive(DATA_DIR / "repos" / "git" / "default-tag.zip", tmp_path) with pytest.raises(NoTagError) as excinfo: describe_git(project_dir=tmp_path, params={}) - assert str(excinfo.value) == "`git describe --tags` could not find a tag" + assert ( + str(excinfo.value) + == "`git describe --long --dirty --always --tags` could not find a tag" + ) @needs_git @@ -105,7 +108,10 @@ def test_describe_git_added_no_commits(tmp_path: Path) -> None: shutil.unpack_archive( DATA_DIR / "repos" / "git" / "added-no-commits-default-tag.zip", tmp_path ) - with pytest.raises(NoTagError, match=r"^`git describe` command failed: "): + with pytest.raises( + NoTagError, + match=r"^`git describe --long --dirty --always --tags` command failed: ", + ): describe_git(project_dir=tmp_path, params={}) @@ -226,7 +232,7 @@ def test_describe_git_archive_added_no_commits_default_tag( assert any( logger == "versioningit" and level == logging.ERROR - and re.match("^`git describe` command failed: ", msg) + and re.match("^`git describe --long --dirty --always` command failed: ", msg) for logger, level, msg in caplog.record_tuples ) assert ( @@ -244,7 +250,10 @@ def test_describe_git_archive_lightweight_only(tmp_path: Path) -> None: project_dir=tmp_path, params={"describe-subst": "$Format:%(describe)$"}, ) - assert str(excinfo.value) == "`git describe` could not find a tag" + assert ( + str(excinfo.value) + == "`git describe --long --dirty --always` could not find a tag" + ) @needs_git @@ -274,8 +283,8 @@ def test_describe_git_archive_lightweight_only_default_tag( assert ( "versioningit", logging.INFO, - "`git describe` returned a hash instead of a tag; falling back to" - " default tag '0.0.0'", + "`git describe --long --dirty --always` returned a hash instead of a" + " tag; falling back to default tag '0.0.0'", ) in caplog.record_tuples From 20f6952b5207808c23ed1415798ad7c81e3d5136 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 14:11:41 -0400 Subject: [PATCH 06/21] Test `git describe` failure with git-archive method --- test/data/repos/errors/archive-no-tag.json | 4 ++++ test/data/repos/errors/archive-no-tag.marks | 1 + test/data/repos/errors/archive-no-tag.zip | Bin 0 -> 12304 bytes 3 files changed, 5 insertions(+) create mode 100644 test/data/repos/errors/archive-no-tag.json create mode 100644 test/data/repos/errors/archive-no-tag.marks create mode 100644 test/data/repos/errors/archive-no-tag.zip diff --git a/test/data/repos/errors/archive-no-tag.json b/test/data/repos/errors/archive-no-tag.json new file mode 100644 index 0000000..a59a9f0 --- /dev/null +++ b/test/data/repos/errors/archive-no-tag.json @@ -0,0 +1,4 @@ +{ + "type": "NoTagError", + "message": "`git describe --long --dirty --always '--exclude=v*'` could not find a tag" +} diff --git a/test/data/repos/errors/archive-no-tag.marks b/test/data/repos/errors/archive-no-tag.marks new file mode 100644 index 0000000..40e6dd3 --- /dev/null +++ b/test/data/repos/errors/archive-no-tag.marks @@ -0,0 +1 @@ +describe_exclude diff --git a/test/data/repos/errors/archive-no-tag.zip b/test/data/repos/errors/archive-no-tag.zip new file mode 100644 index 0000000000000000000000000000000000000000..85e135fe8f69c6477a5f7384acbd348eb7277db8 GIT binary patch literal 12304 zcmeHN30xD`){h7%5y2H#aAc7+Az=vt#g+%CY=VdaBBWU+5DiI81`KGexG#0B%TsZq zXhjhf_qtUDiwFveyLGp|YAq^7QP6(pP7;!gsgM5J@Atj;`#O4<$;|nmd+v7bx%Zs7 zsP^VPXy{6sq(~wkw0|t%&P1ONp@>1?cful?mCvx*qE4z1YUSpL_*By;iD%@ z2w?_B$T5I3_)1}hBpat2i`g#}CH4e3A}gJk5#b?WN?aU-!5@`(2F@3$yfgU{83l`5 zzML^1Fo-(outK>^EJ;rh%9VI3-Aaio7biPyyDr6}{d;(XsvPsfqAYI5;>5&TfEzg9q@GO}` zXdu(LwgC$}42S?t5p~gNEW%Ynr9?r1USni3ekLx0dh664jNu{)fe{%J6^8W1Tn*S= zQQIN}e8&wyOiDvRNv&6FLuJV26IGN>t*qd*95kcR5YYib_PazT!qs6B@uBbn-qSkZ zjdzQ>7N?HI8*4iCJ+$jdI~vWRi$}Nzjh0tPqqS=U9yFBtXTI6Bm78$BjJtSpl%INo zOI*y53Yra)$tMVSyFYGZz-k=OY%`uKN;bPjfeC5;{r zgD)nWsZ3+1n4U|@sl2GGr?;^j+K$RmUz%5kuES(ZDkk4h=@&dgEp zg%kPdxHpd{kx2+1kEzJf$gK&TN6I}$xW%ByY%{{GggNR?u4Fy zOY3PY7tKQ?6I}`M;o)#gqy=DXy4@G}JLiU7J9*!pE?J)2v>R`7_W&r(2flrF`bo)@ zftQCA@CGypzaEtF=7a3^HZFsX`x zrlbmEFyt@+mFPjszz{3tnZY06=uTL)L8g0CbnFp?RVtCK5+j1L%*Ok75& zn7}zquEhA5cJN@Caup%X!6Y&))Qg<%V!2c*pDdB3W0U1sQV}M=fjeC;7hy0$Fu52c zXqCYfFyC;cOoh2+$+RUP5t*1ojOEC)u*rNGm>4;h1r`mxcMk%v2Qx*^Pel*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oVLVi*Df2pS88 z5;s{8{HBEL7^Mv3gOcscdbIBW3Yku6BR{}u{44}Lk&6ZuLQQegKxnkWJSQE*IN^;d zfSTN<7cfC50EO+TFlt_#9=25n(`30(fz%(&;=b@ zmosMEwA8FI9kej7Ne3iz$UaseTA(x+D)1^yJW^e4Fx9v`YI=?iS(x{m5l(B3sl`&$ zSM+cP@cHz`qSc;?)$yXcvC5Ocha|DutPNw84deUBWazHKyfsERQ^P^Wi|)u3(OjsR zy23i5FH`ID7#FN#M|U(kH5UR8{Sd5kgp5TP>W)m9?kdci^m`&urozXX4*AlW3u*Ez zv?N&#T?qYSP!!0~LkGY>HG-NPFx2?FPJ(k@tVz6KG@hypHGZX&RhX9oUgd|npf&KL z!^pToXQ)CD9@Z4&E}=%MbV@kqy)ubMLfRfngSZv7Kl?#70p7}KKv?fgW$63vBX zMIB~{Gd(qR{OE3M8q5Y7qP2S#{U9>6YtacS%=6ZQ^?MjK7SeP5Fs>B_lt;8hDLVF;r(vFUAWtl_p)YxF`!)_GmO`_~#A=y%rd0wEqFWtX;hT literal 0 HcmV?d00001 From d07ffbf7ea3734db7d40979b199632f7de2a0f04 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 14:27:23 -0400 Subject: [PATCH 07/21] [skip ci] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ docs/changelog.rst | 7 +++++++ src/versioningit/__init__.py | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b16a07..fe2d3f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +v3.1.0 (in development) +----------------------- +- When `git describe` fails to retrieve a tag, the resulting log/error message + now includes all options passed to the command (based on contribution by + [@jenshnielsen](https://github.com/jenshnielsen)) + v3.0.0 (2023-12-13) ------------------- - Migrated from setuptools to hatch diff --git a/docs/changelog.rst b/docs/changelog.rst index 1f42052..77b0714 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,13 @@ Changelog ========= +v3.1.0 (in development) +----------------------- +- When :command:`git describe` fails to retrieve a tag, the resulting log/error + message now includes all options passed to the command (based on contribution + by `@jenshnielsen `_) + + v3.0.0 (2023-12-13) ------------------- - Migrated from setuptools to hatch diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index c908432..1e092fa 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.0.0" +__version__ = "3.1.0.dev1" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" From 25f0b90e6dc4f09ed2b53eab997536dc5c2807fa Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 15:09:56 -0400 Subject: [PATCH 08/21] hg method: Include pattern (if any) in messages about tag-retrieval failure --- CHANGELOG.md | 2 ++ docs/changelog.rst | 2 ++ src/versioningit/hg.py | 12 ++++++++++-- test/data/repos/errors/hg-no-tag.json | 4 ++++ test/data/repos/errors/hg-no-tag.zip | Bin 0 -> 12596 bytes .../repos/hg/default-tag-fallback.fields.json | 8 ++++++++ test/data/repos/hg/default-tag-fallback.json | 10 ++++++++++ test/data/repos/hg/default-tag-fallback.zip | Bin 0 -> 12650 bytes test/test_methods/test_hg.py | 6 ++++++ 9 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 test/data/repos/errors/hg-no-tag.json create mode 100644 test/data/repos/errors/hg-no-tag.zip create mode 100644 test/data/repos/hg/default-tag-fallback.fields.json create mode 100644 test/data/repos/hg/default-tag-fallback.json create mode 100644 test/data/repos/hg/default-tag-fallback.zip diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2d3f2..170757a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ v3.1.0 (in development) - When `git describe` fails to retrieve a tag, the resulting log/error message now includes all options passed to the command (based on contribution by [@jenshnielsen](https://github.com/jenshnielsen)) +- When `hg log` fails to retrieve a tag, the resulting log/error message now + includes the tag pattern passed to `latesttag()`, if any v3.0.0 (2023-12-13) ------------------- diff --git a/docs/changelog.rst b/docs/changelog.rst index 77b0714..3ec9b7f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,8 @@ v3.1.0 (in development) - When :command:`git describe` fails to retrieve a tag, the resulting log/error message now includes all options passed to the command (based on contribution by `@jenshnielsen `_) +- When :command:`hg log` fails to retrieve a tag, the resulting log/error + message now includes the tag pattern passed to ``latesttag()``, if any v3.0.0 (2023-12-13) diff --git a/src/versioningit/hg.py b/src/versioningit/hg.py index 538e8df..1360670 100644 --- a/src/versioningit/hg.py +++ b/src/versioningit/hg.py @@ -102,15 +102,23 @@ def describe_hg(*, project_dir: str | Path, params: dict[str, Any]) -> VCSDescri else: dirty = False if tag == "null": + if pattern is None: + suffix = "" + else: + suffix = f" (pattern = {pattern!r})" + # Unlike the Git methods, don't show the full `hg log` command run, as + # shlex.quote() on `--template` arguments returns something *ugly*. if default_tag is not None: - log.info("No latest tag; falling back to default tag %r", default_tag) + log.info( + "No latest tag%s; falling back to default tag %r", suffix, default_tag + ) tag = default_tag # Act as though the first commit is the one with the default tag, # i.e., don't count it (unless there is no first commit, of course) if distance > 0: distance -= 1 else: - raise NoTagError("No latest tag in Mercurial repository") + raise NoTagError(f"No latest tag in Mercurial repository{suffix}") if distance and dirty: state = "distance-dirty" elif distance: diff --git a/test/data/repos/errors/hg-no-tag.json b/test/data/repos/errors/hg-no-tag.json new file mode 100644 index 0000000..f70dcfb --- /dev/null +++ b/test/data/repos/errors/hg-no-tag.json @@ -0,0 +1,4 @@ +{ + "type": "NoTagError", + "message": "No latest tag in Mercurial repository (pattern = 're:^v')" +} diff --git a/test/data/repos/errors/hg-no-tag.zip b/test/data/repos/errors/hg-no-tag.zip new file mode 100644 index 0000000000000000000000000000000000000000..dbe99e1c17d21a854fb7016cd0b31e9228a2689f GIT binary patch literal 12596 zcmeG?d3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PJTCXHjRD^HNL)b?NTxzTS7K4XSA-*{WtPzW?wyIsap!rQJ#u6hO43QA8 za&>B}hQ?qdR*;oE)HP(0XKmGVB@b~uQB;)WBZF?HE(l26@JkbL524O1CqqTl$-YEZ zDv;q`L{5Y|Y;}4r5q$+jQnsh2Q)kc;U6@qo(`s6EwkpvM%#h`-ax(QmVe%w2bl3~9 zX%C!_jLUcJ8F|;}V R0hx}_5#wR~eg_Z<;-BNI1WW(` literal 0 HcmV?d00001 diff --git a/test/data/repos/hg/default-tag-fallback.fields.json b/test/data/repos/hg/default-tag-fallback.fields.json new file mode 100644 index 0000000..0ed570c --- /dev/null +++ b/test/data/repos/hg/default-tag-fallback.fields.json @@ -0,0 +1,8 @@ +{ + "build_date": "2038-01-19 03:14:07+00:00", + "distance": 3, + "rev": "5296453555c9", + "revision": "5296453555c92c22bab469752758a549e297c922", + "vcs": "h", + "vcs_name": "hg" +} diff --git a/test/data/repos/hg/default-tag-fallback.json b/test/data/repos/hg/default-tag-fallback.json new file mode 100644 index 0000000..be4ec96 --- /dev/null +++ b/test/data/repos/hg/default-tag-fallback.json @@ -0,0 +1,10 @@ +{ + "version": "0.0.0.post3+h5296453555c9", + "next_version": "0.1.0", + "logmsgs": [ + { + "level": "INFO", + "message": "No latest tag (pattern = 're:^v'); falling back to default tag 'v0.0.0'" + } + ] +} diff --git a/test/data/repos/hg/default-tag-fallback.zip b/test/data/repos/hg/default-tag-fallback.zip new file mode 100644 index 0000000000000000000000000000000000000000..39bf79b9c761c483c351fde37728bf66d75c5e81 GIT binary patch literal 12650 zcmeHNd3Y4Xw(leal7>LoVjw{}0|J3$(mne`wn!odL_!FPAPhY{J(D4`F&haABy1`{ z2#7>cP%$VwC<3zGDh?&aS5-XFg26`bi#^*N_b zZKvw|s)~ljHS2((G@{%$ntS1Yn!!_D>c}aQajbu9@*p#OLDZJ#AW5c__BdFV*P(V| z*sWWHE#!7r5RJJ+&`bFIY?$=~iBQ1laS*{$mhif4grD_!2^U@A4F%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^Z4YV8DOR0xj2<1*k5J69Lz7$DF!S~S>G_E5}+^zDwNl;c-m6;sX z7Ex7`(B z9_1;3sOK1Tu2@U{Oh75Fgx^K+7hxF{#YHe)sX>XciyD5FX+Q|5QdWtTi?S}*Rfwfa zP-hM~SL%^2y9ntPQeD*zUXMhB1YDQuiH3NKdJF(&B73BIgf#$x?@~?33n?*RQIqE` zi6*p>SBeU(=m}1TPiT6r;6)pO;oHwkguM#sVAUbHpbRL!y^hE}Dx#&X>Q)pT5#adt z8W40Wq`E2!E@q=Pye*J?dqvXf)KyK4qDTOiMIF(gWzm@Bavj2YA_JP0J)^`4L~UK+ zUJ6t#0zWIolo)_0HYFm4X0}u)TGTEI{Q*K^v?rBA15X)Pi*kzyWtc6MjTWtnvK1MU z*i|Z~TyatG6iH~nW^@xmDY09W5-6AwB?j>lqA!+~7A?3Er0c4@O=KmZmQsx}f)Uk> d=&p?J_~oEzXgr)yU>FJi#>4u30~j&vzX7KO{+$2- literal 0 HcmV?d00001 diff --git a/test/test_methods/test_hg.py b/test/test_methods/test_hg.py index 79c7029..4ed77a1 100644 --- a/test/test_methods/test_hg.py +++ b/test/test_methods/test_hg.py @@ -39,6 +39,12 @@ class HGFields(BaseModel): ("distance", {}, "v0.1.0", "distance"), ("distance-dirty", {}, "v0.1.0", "distance-dirty"), ("default-tag", {"default-tag": "v0.0.0"}, "v0.0.0", "distance"), + ( + "default-tag-fallback", + {"default-tag": "v0.0.0", "pattern": "re:^v"}, + "v0.0.0", + "distance", + ), ("pattern", {"pattern": r"re:^v"}, "v0.1.0", "distance"), ], ) From 8903e8f6683ddf016b14f13ec4005d9eec4bb377 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 16 Mar 2024 15:49:17 -0400 Subject: [PATCH 09/21] =?UTF-8?q?v3.1.0=20=E2=80=94=20Improve=20some=20err?= =?UTF-8?q?or=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - When `git describe` fails to retrieve a tag, the resulting log/error message now includes all options passed to the command (based on contribution by [@jenshnielsen](https://github.com/jenshnielsen)) - When `hg log` fails to retrieve a tag, the resulting log/error message now includes the tag pattern passed to `latesttag()`, if any --- CHANGELOG.md | 4 ++-- LICENSE | 2 +- docs/changelog.rst | 4 ++-- docs/conf.py | 2 +- src/versioningit/__init__.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 170757a..b94d2cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -v3.1.0 (in development) ------------------------ +v3.1.0 (2024-03-16) +------------------- - When `git describe` fails to retrieve a tag, the resulting log/error message now includes all options passed to the command (based on contribution by [@jenshnielsen](https://github.com/jenshnielsen)) diff --git a/LICENSE b/LICENSE index 48e904b..9e4d4ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021-2023 John Thorvald Wodder II and contributors +Copyright (c) 2021-2024 John Thorvald Wodder II and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/changelog.rst b/docs/changelog.rst index 3ec9b7f..e514537 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,8 +3,8 @@ Changelog ========= -v3.1.0 (in development) ------------------------ +v3.1.0 (2024-03-16) +------------------- - When :command:`git describe` fails to retrieve a tag, the resulting log/error message now includes all options passed to the command (based on contribution by `@jenshnielsen `_) diff --git a/docs/conf.py b/docs/conf.py index f2ff574..9bb5553 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ project = "versioningit" author = "John Thorvald Wodder II" -copyright = "2021-2023 John Thorvald Wodder II" # noqa: A001 +copyright = "2021-2024 John Thorvald Wodder II" # noqa: A001 extensions = [ "sphinx.ext.autodoc", diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index 1e092fa..be694f1 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.1.0.dev1" +__version__ = "3.1.0" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" From 37e7d0717d049613f902b11fbda0cfa821636745 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 9 Apr 2024 16:57:28 -0400 Subject: [PATCH 10/21] Correctly mark a certain test as requiring Mercurial --- CHANGELOG.md | 4 +++ docs/changelog.rst | 5 ++++ src/versioningit/__init__.py | 2 +- .../archive-no-tag.json | 0 .../archive-no-tag.marks | 0 .../{errors => git-errors}/archive-no-tag.zip | Bin .../{errors => git-errors}/hatch-no-tag.json | 0 .../{errors => git-errors}/hatch-no-tag.marks | 0 .../{errors => git-errors}/hatch-no-tag.zip | Bin .../repos/{errors => git-errors}/no-tag.json | 0 .../repos/{errors => git-errors}/no-tag.marks | 0 .../repos/{errors => git-errors}/no-tag.zip | Bin .../template-fields-error.json | 0 .../template-fields-error.zip | Bin .../{errors => hg-errors}/hg-no-tag.json | 0 .../repos/{errors => hg-errors}/hg-no-tag.zip | Bin test/test_end2end.py | 27 ++++++++++++++++-- 17 files changed, 35 insertions(+), 3 deletions(-) rename test/data/repos/{errors => git-errors}/archive-no-tag.json (100%) rename test/data/repos/{errors => git-errors}/archive-no-tag.marks (100%) rename test/data/repos/{errors => git-errors}/archive-no-tag.zip (100%) rename test/data/repos/{errors => git-errors}/hatch-no-tag.json (100%) rename test/data/repos/{errors => git-errors}/hatch-no-tag.marks (100%) rename test/data/repos/{errors => git-errors}/hatch-no-tag.zip (100%) rename test/data/repos/{errors => git-errors}/no-tag.json (100%) rename test/data/repos/{errors => git-errors}/no-tag.marks (100%) rename test/data/repos/{errors => git-errors}/no-tag.zip (100%) rename test/data/repos/{errors => git-errors}/template-fields-error.json (100%) rename test/data/repos/{errors => git-errors}/template-fields-error.zip (100%) rename test/data/repos/{errors => hg-errors}/hg-no-tag.json (100%) rename test/data/repos/{errors => hg-errors}/hg-no-tag.zip (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b94d2cc..d994beb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +v3.1.1 (in development) +----------------------- +- Correctly mark a certain test as requiring Mercurial + v3.1.0 (2024-03-16) ------------------- - When `git describe` fails to retrieve a tag, the resulting log/error message diff --git a/docs/changelog.rst b/docs/changelog.rst index e514537..9207ffc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,11 @@ Changelog ========= +v3.1.1 (in development) +----------------------- +- Correctly mark a certain test as requiring Mercurial + + v3.1.0 (2024-03-16) ------------------- - When :command:`git describe` fails to retrieve a tag, the resulting log/error diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index be694f1..5898d97 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.1.0" +__version__ = "3.1.1.dev1" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" diff --git a/test/data/repos/errors/archive-no-tag.json b/test/data/repos/git-errors/archive-no-tag.json similarity index 100% rename from test/data/repos/errors/archive-no-tag.json rename to test/data/repos/git-errors/archive-no-tag.json diff --git a/test/data/repos/errors/archive-no-tag.marks b/test/data/repos/git-errors/archive-no-tag.marks similarity index 100% rename from test/data/repos/errors/archive-no-tag.marks rename to test/data/repos/git-errors/archive-no-tag.marks diff --git a/test/data/repos/errors/archive-no-tag.zip b/test/data/repos/git-errors/archive-no-tag.zip similarity index 100% rename from test/data/repos/errors/archive-no-tag.zip rename to test/data/repos/git-errors/archive-no-tag.zip diff --git a/test/data/repos/errors/hatch-no-tag.json b/test/data/repos/git-errors/hatch-no-tag.json similarity index 100% rename from test/data/repos/errors/hatch-no-tag.json rename to test/data/repos/git-errors/hatch-no-tag.json diff --git a/test/data/repos/errors/hatch-no-tag.marks b/test/data/repos/git-errors/hatch-no-tag.marks similarity index 100% rename from test/data/repos/errors/hatch-no-tag.marks rename to test/data/repos/git-errors/hatch-no-tag.marks diff --git a/test/data/repos/errors/hatch-no-tag.zip b/test/data/repos/git-errors/hatch-no-tag.zip similarity index 100% rename from test/data/repos/errors/hatch-no-tag.zip rename to test/data/repos/git-errors/hatch-no-tag.zip diff --git a/test/data/repos/errors/no-tag.json b/test/data/repos/git-errors/no-tag.json similarity index 100% rename from test/data/repos/errors/no-tag.json rename to test/data/repos/git-errors/no-tag.json diff --git a/test/data/repos/errors/no-tag.marks b/test/data/repos/git-errors/no-tag.marks similarity index 100% rename from test/data/repos/errors/no-tag.marks rename to test/data/repos/git-errors/no-tag.marks diff --git a/test/data/repos/errors/no-tag.zip b/test/data/repos/git-errors/no-tag.zip similarity index 100% rename from test/data/repos/errors/no-tag.zip rename to test/data/repos/git-errors/no-tag.zip diff --git a/test/data/repos/errors/template-fields-error.json b/test/data/repos/git-errors/template-fields-error.json similarity index 100% rename from test/data/repos/errors/template-fields-error.json rename to test/data/repos/git-errors/template-fields-error.json diff --git a/test/data/repos/errors/template-fields-error.zip b/test/data/repos/git-errors/template-fields-error.zip similarity index 100% rename from test/data/repos/errors/template-fields-error.zip rename to test/data/repos/git-errors/template-fields-error.zip diff --git a/test/data/repos/errors/hg-no-tag.json b/test/data/repos/hg-errors/hg-no-tag.json similarity index 100% rename from test/data/repos/errors/hg-no-tag.json rename to test/data/repos/hg-errors/hg-no-tag.json diff --git a/test/data/repos/errors/hg-no-tag.zip b/test/data/repos/hg-errors/hg-no-tag.zip similarity index 100% rename from test/data/repos/errors/hg-no-tag.zip rename to test/data/repos/hg-errors/hg-no-tag.zip diff --git a/test/test_end2end.py b/test/test_end2end.py index c021741..f2690a3 100644 --- a/test/test_end2end.py +++ b/test/test_end2end.py @@ -240,9 +240,32 @@ def test_get_version_config_only( @pytest.mark.parametrize( - "repozip,details", mkcases("errors", [needs_git], details_cls=ErrorDetails) + "repozip,details", mkcases("git-errors", [needs_git], details_cls=ErrorDetails) ) -def test_end2end_error(tmp_path: Path, repozip: Path, details: ErrorDetails) -> None: +def test_end2end_git_error( + tmp_path: Path, repozip: Path, details: ErrorDetails +) -> None: + shutil.unpack_archive(repozip, tmp_path) + with pytest.raises(Error) as excinfo: + get_version(project_dir=tmp_path, write=False, fallback=True) + assert type(excinfo.value).__name__ == details.type + assert str(excinfo.value) == details.message + r = subprocess.run( + [sys.executable, "-m", "build", "--no-isolation", str(tmp_path)], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + assert r.returncode != 0 + out = r.stdout + assert isinstance(out, str) + assert details.message in out + + +@pytest.mark.parametrize( + "repozip,details", mkcases("hg-errors", [needs_hg], details_cls=ErrorDetails) +) +def test_end2end_hg_error(tmp_path: Path, repozip: Path, details: ErrorDetails) -> None: shutil.unpack_archive(repozip, tmp_path) with pytest.raises(Error) as excinfo: get_version(project_dir=tmp_path, write=False, fallback=True) From 82d7a5d2cfb1608ca52c7009b76b986b1459be78 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 23 Apr 2024 15:05:53 -0400 Subject: [PATCH 11/21] Install mercurial through Homebrew --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e79b73..eaf6ccc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,7 +52,7 @@ jobs: # Mercurial seems to be broken on PyPy, so we need to install it before # overriding the default Python. if: startsWith(matrix.os, 'macos-') - run: python3 -m pip install mercurial + run: brew install mercurial - name: Set up Python uses: actions/setup-python@v5 From 5779c9b43edc213c0d33ddc690cb6351e1a4c98f Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 23 Apr 2024 15:15:07 -0400 Subject: [PATCH 12/21] Exclude Python versions not available on ARM macOS --- .github/workflows/install-git-url.yml | 10 ++++++++++ .github/workflows/install-zip-url.yml | 10 ++++++++++ .github/workflows/test.yml | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/.github/workflows/install-git-url.yml b/.github/workflows/install-git-url.yml index 4a5bcd1..cf70b2d 100644 --- a/.github/workflows/install-git-url.yml +++ b/.github/workflows/install-git-url.yml @@ -37,6 +37,16 @@ jobs: - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' + exclude: + # Not available for ARM macOS: + - python-version: '3.7' + os: macos-latest + - python-version: '3.8' + os: macos-latest + - python-version: '3.9' + os: macos-latest + - python-version: 'pypy-3.7' + os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/install-zip-url.yml b/.github/workflows/install-zip-url.yml index e9357ca..0ea33a5 100644 --- a/.github/workflows/install-zip-url.yml +++ b/.github/workflows/install-zip-url.yml @@ -37,6 +37,16 @@ jobs: - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' + exclude: + # Not available for ARM macOS: + - python-version: '3.7' + os: macos-latest + - python-version: '3.8' + os: macos-latest + - python-version: '3.9' + os: macos-latest + - python-version: 'pypy-3.7' + os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaf6ccc..9281824 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,16 @@ jobs: - python-version: '3.7' toxenv: py-oldsetup os: ubuntu-latest + exclude: + # Not available for ARM macOS: + - python-version: '3.7' + os: macos-latest + - python-version: '3.8' + os: macos-latest + - python-version: '3.9' + os: macos-latest + - python-version: 'pypy-3.7' + os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 From b94cea5db7d2a9788f3c028a3179b2efe046617a Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 23 Apr 2024 15:52:47 -0400 Subject: [PATCH 13/21] [skip ci] Adjust rST for README badges Apparently, GitHub is now rendering rST into HTML 5. --- README.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 7805ec8..b235091 100644 --- a/README.rst +++ b/README.rst @@ -1,23 +1,25 @@ -.. image:: https://www.repostatus.org/badges/latest/active.svg +|repostatus| |ci-status| |coverage| |pyversions| |conda| |license| + +.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg :target: https://www.repostatus.org/#active :alt: Project Status: Active — The project has reached a stable, usable state and is being actively developed. -.. image:: https://github.com/jwodder/versioningit/actions/workflows/test.yml/badge.svg +.. |ci-status| image:: https://github.com/jwodder/versioningit/actions/workflows/test.yml/badge.svg :target: https://github.com/jwodder/versioningit/actions/workflows/test.yml :alt: CI Status -.. image:: https://codecov.io/gh/jwodder/versioningit/branch/master/graph/badge.svg +.. |coverage| image:: https://codecov.io/gh/jwodder/versioningit/branch/master/graph/badge.svg :target: https://codecov.io/gh/jwodder/versioningit -.. image:: https://img.shields.io/pypi/pyversions/versioningit.svg +.. |pyversions| image:: https://img.shields.io/pypi/pyversions/versioningit.svg :target: https://pypi.org/project/versioningit/ -.. image:: https://img.shields.io/conda/vn/conda-forge/versioningit.svg +.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/versioningit.svg :target: https://anaconda.org/conda-forge/versioningit :alt: Conda Version -.. image:: https://img.shields.io/github/license/jwodder/versioningit.svg +.. |license| image:: https://img.shields.io/github/license/jwodder/versioningit.svg :target: https://opensource.org/licenses/MIT :alt: MIT License From 6281f8876ec8bc2f9598f49641302e29b647e99f Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 27 Apr 2024 08:03:25 -0400 Subject: [PATCH 14/21] Python 3.8 & 3.9 are now available for ARM macOS on GitHub Actions --- .github/workflows/install-git-url.yml | 4 ---- .github/workflows/install-zip-url.yml | 4 ---- .github/workflows/test.yml | 4 ---- 3 files changed, 12 deletions(-) diff --git a/.github/workflows/install-git-url.yml b/.github/workflows/install-git-url.yml index cf70b2d..d2bb7e2 100644 --- a/.github/workflows/install-git-url.yml +++ b/.github/workflows/install-git-url.yml @@ -41,10 +41,6 @@ jobs: # Not available for ARM macOS: - python-version: '3.7' os: macos-latest - - python-version: '3.8' - os: macos-latest - - python-version: '3.9' - os: macos-latest - python-version: 'pypy-3.7' os: macos-latest steps: diff --git a/.github/workflows/install-zip-url.yml b/.github/workflows/install-zip-url.yml index 0ea33a5..3595623 100644 --- a/.github/workflows/install-zip-url.yml +++ b/.github/workflows/install-zip-url.yml @@ -41,10 +41,6 @@ jobs: # Not available for ARM macOS: - python-version: '3.7' os: macos-latest - - python-version: '3.8' - os: macos-latest - - python-version: '3.9' - os: macos-latest - python-version: 'pypy-3.7' os: macos-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9281824..785210b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,10 +48,6 @@ jobs: # Not available for ARM macOS: - python-version: '3.7' os: macos-latest - - python-version: '3.8' - os: macos-latest - - python-version: '3.9' - os: macos-latest - python-version: 'pypy-3.7' os: macos-latest steps: From 41e8c8af07e8a34f1abebc66088d803b185eec09 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Mon, 29 Apr 2024 07:19:00 -0400 Subject: [PATCH 15/21] =?UTF-8?q?v3.1.1=20=E2=80=94=20Fix=20a=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Correctly mark a certain test as requiring Mercurial --- CHANGELOG.md | 4 ++-- docs/changelog.rst | 4 ++-- src/versioningit/__init__.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d994beb..d9ea9dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -v3.1.1 (in development) ------------------------ +v3.1.1 (2024-04-29) +------------------- - Correctly mark a certain test as requiring Mercurial v3.1.0 (2024-03-16) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9207ffc..de39f4d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,8 +3,8 @@ Changelog ========= -v3.1.1 (in development) ------------------------ +v3.1.1 (2024-04-29) +------------------- - Correctly mark a certain test as requiring Mercurial diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index 5898d97..6947636 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.1.1.dev1" +__version__ = "3.1.1" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" From 94756b8e7d01612b86a9eac20ec4b30c024bc5ee Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Wed, 1 May 2024 19:40:51 -0400 Subject: [PATCH 16/21] Autoupdate .pre-commit-config.yaml --- .pre-commit-config.yaml | 6 +++--- src/versioningit/core.py | 6 +++--- src/versioningit/onbuild.py | 18 ++++++------------ tox.ini | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36a8a77..b2a1a1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-added-large-files - id: check-json @@ -12,13 +12,13 @@ repos: exclude: '\.eml$' - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 24.4.2 hooks: - id: black exclude: ^test/data - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.2 hooks: - id: isort exclude: ^test/data diff --git a/src/versioningit/core.py b/src/versioningit/core.py index 3ba39ec..cbc3b2d 100644 --- a/src/versioningit/core.py +++ b/src/versioningit/core.py @@ -190,9 +190,9 @@ def from_config(cls, project_dir: str | Path, config: Config) -> Versioningit: format=config.format.load(project_dir), template_fields=config.template_fields.load(project_dir), write=config.write.load(project_dir) if config.write is not None else None, - onbuild=config.onbuild.load(project_dir) - if config.onbuild is not None - else None, + onbuild=( + config.onbuild.load(project_dir) if config.onbuild is not None else None + ), ) def get_version(self, write: bool = False, fallback: bool = True) -> str: diff --git a/src/versioningit/onbuild.py b/src/versioningit/onbuild.py index 58a5828..74a31cf 100644 --- a/src/versioningit/onbuild.py +++ b/src/versioningit/onbuild.py @@ -63,8 +63,7 @@ def open( encoding: str | None = None, errors: str | None = None, newline: str | None = None, - ) -> TextIO: - ... + ) -> TextIO: ... @overload def open( @@ -73,8 +72,7 @@ def open( encoding: None = None, errors: None = None, newline: None = None, - ) -> IO[bytes]: - ... + ) -> IO[bytes]: ... @abstractmethod def open( @@ -142,8 +140,7 @@ def open( encoding: str | None = None, errors: str | None = None, newline: str | None = None, - ) -> TextIO: - ... + ) -> TextIO: ... @overload def open( @@ -152,8 +149,7 @@ def open( encoding: None = None, errors: None = None, newline: None = None, - ) -> IO[bytes]: - ... + ) -> IO[bytes]: ... def open( self, @@ -236,8 +232,7 @@ def open( encoding: str | None = None, errors: str | None = None, newline: str | None = None, - ) -> TextIO: - ... + ) -> TextIO: ... @overload def open( @@ -246,8 +241,7 @@ def open( encoding: None = None, errors: None = None, newline: None = None, - ) -> IO[bytes]: - ... + ) -> IO[bytes]: ... def open( self, diff --git a/tox.ini b/tox.ini index 1065fab..f77f54d 100644 --- a/tox.ini +++ b/tox.ini @@ -88,7 +88,7 @@ max-doc-length = 100 max-line-length = 80 unused-arguments-ignore-stub-functions = True extend-select = B901,B902,B950 -ignore = A003,B005,E203,E262,E266,E501,U101,W503 +ignore = A003,A005,B005,E203,E262,E266,E501,E704,U101,W503 [isort] atomic = True From 55946c888eec55ae2c75702426298bb4fed28ebe Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Thu, 2 May 2024 09:13:36 -0400 Subject: [PATCH 17/21] Drop support for Python 3.7 --- .github/workflows/install-git-url.yml | 8 -------- .github/workflows/install-zip-url.yml | 8 -------- .github/workflows/test.yml | 14 +++----------- .github/workflows/tools/minimum-vcs/Dockerfile | 2 +- .github/workflows/tools/no-vcs/Dockerfile | 2 +- CHANGELOG.md | 4 ++++ README.rst | 2 +- docs/changelog.rst | 5 +++++ docs/index.rst | 2 +- pyproject.toml | 3 +-- src/versioningit/__init__.py | 2 +- tox.ini | 2 +- 12 files changed, 19 insertions(+), 35 deletions(-) diff --git a/.github/workflows/install-git-url.yml b/.github/workflows/install-git-url.yml index d2bb7e2..5d7918a 100644 --- a/.github/workflows/install-git-url.yml +++ b/.github/workflows/install-git-url.yml @@ -27,22 +27,14 @@ jobs: - ubuntu-latest - windows-latest python-version: - - '3.7' - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' - - 'pypy-3.7' - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' - exclude: - # Not available for ARM macOS: - - python-version: '3.7' - os: macos-latest - - python-version: 'pypy-3.7' - os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/install-zip-url.yml b/.github/workflows/install-zip-url.yml index 3595623..b4a80fa 100644 --- a/.github/workflows/install-zip-url.yml +++ b/.github/workflows/install-zip-url.yml @@ -27,22 +27,14 @@ jobs: - ubuntu-latest - windows-latest python-version: - - '3.7' - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' - - 'pypy-3.7' - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' - exclude: - # Not available for ARM macOS: - - python-version: '3.7' - os: macos-latest - - python-version: 'pypy-3.7' - os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 785210b..11b2bd2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,33 +23,25 @@ jobs: - ubuntu-latest - windows-latest python-version: - - '3.7' - '3.8' - '3.9' - '3.10' - '3.11' - '3.12' - - 'pypy-3.7' - 'pypy-3.8' - 'pypy-3.9' - 'pypy-3.10' toxenv: [py] include: - - python-version: '3.7' + - python-version: '3.8' toxenv: lint os: ubuntu-latest - - python-version: '3.7' + - python-version: '3.8' toxenv: typing os: ubuntu-latest - - python-version: '3.7' + - python-version: '3.8' toxenv: py-oldsetup os: ubuntu-latest - exclude: - # Not available for ARM macOS: - - python-version: '3.7' - os: macos-latest - - python-version: 'pypy-3.7' - os: macos-latest steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/.github/workflows/tools/minimum-vcs/Dockerfile b/.github/workflows/tools/minimum-vcs/Dockerfile index 5f2e3fd..359de45 100644 --- a/.github/workflows/tools/minimum-vcs/Dockerfile +++ b/.github/workflows/tools/minimum-vcs/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-buster +FROM python:3.8-buster RUN set -ex; \ cd tmp; \ wget http://snapshot.debian.org/archive/debian/20121102T092448Z/pool/main/g/git/git-man_1.8.0-1_all.deb; \ diff --git a/.github/workflows/tools/no-vcs/Dockerfile b/.github/workflows/tools/no-vcs/Dockerfile index b7d38e8..5501124 100644 --- a/.github/workflows/tools/no-vcs/Dockerfile +++ b/.github/workflows/tools/no-vcs/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-slim +FROM python:3.8-slim RUN set -ex; \ pip install --upgrade pip wheel; \ pip install --upgrade --upgrade-strategy=eager tox diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ea9dd..f84b009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +v3.2.0 (in development) +----------------------- +- Drop support for Python 3.7 + v3.1.1 (2024-04-29) ------------------- - Correctly mark a certain test as requiring Mercurial diff --git a/README.rst b/README.rst index b235091..e52b915 100644 --- a/README.rst +++ b/README.rst @@ -73,7 +73,7 @@ extraction & calculation. Installation & Setup ==================== -``versioningit`` requires Python 3.7 or higher. Just use `pip +``versioningit`` requires Python 3.8 or higher. Just use `pip `_ for Python 3 (You have pip, right?) to install ``versioningit`` and its dependencies:: diff --git a/docs/changelog.rst b/docs/changelog.rst index de39f4d..27e0f01 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,11 @@ Changelog ========= +v3.2.0 (in development) +----------------------- +- Drop support for Python 3.7 + + v3.1.1 (2024-04-29) ------------------- - Correctly mark a certain test as requiring Mercurial diff --git a/docs/index.rst b/docs/index.rst index b4b4626..50bebbf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -66,7 +66,7 @@ extraction & calculation. Installation & Setup ==================== -``versioningit`` requires Python 3.7 or higher. Just use `pip +``versioningit`` requires Python 3.8 or higher. Just use `pip `_ for Python 3 (You have pip, right?) to install ``versioningit`` and its dependencies:: diff --git a/pyproject.toml b/pyproject.toml index 868c2f5..fb46e97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "versioningit" dynamic = ["version"] description = "Versioning It with your Version In Git" readme = "README.rst" -requires-python = ">=3.7" +requires-python = ">=3.8" license = "MIT" license-files = { paths = ["LICENSE"] } authors = [ @@ -26,7 +26,6 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index 6947636..6499e60 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.1.1" +__version__ = "3.2.0.dev1" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" diff --git a/tox.ini b/tox.ini index f77f54d..414e19f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint,typing,py37,py38,py39,py310,py311,py312,pypy3,py-oldsetup +envlist = lint,typing,py38,py39,py310,py311,py312,pypy3,py-oldsetup skip_missing_interpreters = True isolated_build = True minversion = 3.3.0 From eb4bbcb25ddb0034b91ff3f473f823493ee3f6ec Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Thu, 18 Jul 2024 13:47:20 -0400 Subject: [PATCH 18/21] Expand "editable" tests, exposing a failure --- test/test_end2end.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test_end2end.py b/test/test_end2end.py index f2690a3..04b37d1 100644 --- a/test/test_end2end.py +++ b/test/test_end2end.py @@ -399,6 +399,10 @@ def test_editable_mode(cmd: list[str], tmp_path: Path) -> None: assert get_repo_status(srcdir) == status info = readcmd(sys.executable, "-m", "pip", "show", "mypackage") assert parse_version_from_metadata(info) == details.version + version_var = readcmd( + sys.executable, "-c", "import mypackage; print(mypackage.__version__)" + ) + assert version_var == "NOT SET" for f in details.files: f.check(srcdir, "project") finally: @@ -425,6 +429,10 @@ def test_editable_mode_hatch(tmp_path: Path) -> None: assert get_repo_status(srcdir) == status info = readcmd(sys.executable, "-m", "pip", "show", "mypackage") assert parse_version_from_metadata(info) == details.version + version_var = readcmd( + sys.executable, "-c", "import mypackage; print(mypackage.__version__)" + ) + assert version_var == "NOT SET" for f in details.files: f.check(srcdir, "project") finally: From 371f3fd8db6ed235c05b4c01db68b834c728acf3 Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Thu, 18 Jul 2024 16:09:12 -0400 Subject: [PATCH 19/21] Don't run onbuild step for editable builds with Hatch --- CHANGELOG.md | 4 +++- docs/changelog.rst | 2 ++ src/versioningit/__init__.py | 2 +- src/versioningit/hatch.py | 5 ++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f84b009..d297692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ -v3.2.0 (in development) +v3.1.2 (in development) ----------------------- - Drop support for Python 3.7 +- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild` + step for editable builds v3.1.1 (2024-04-29) ------------------- diff --git a/docs/changelog.rst b/docs/changelog.rst index 27e0f01..ffc293c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,8 @@ Changelog v3.2.0 (in development) ----------------------- - Drop support for Python 3.7 +- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild` + step for editable builds v3.1.1 (2024-04-29) diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index 6499e60..f6cf509 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.2.0.dev1" +__version__ = "3.1.2.dev1" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" diff --git a/src/versioningit/hatch.py b/src/versioningit/hatch.py index 027bd65..a1c84e3 100644 --- a/src/versioningit/hatch.py +++ b/src/versioningit/hatch.py @@ -73,8 +73,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.__tmpdir = Path(tempfile.mkdtemp()) - def initialize(self, _version: str, build_data: dict[str, Any]) -> None: + def initialize(self, version: str, build_data: dict[str, Any]) -> None: init_logging() + if self.target_name == "wheel" and version == "editable": + log.debug("Not running onbuild step for editable build") + return None version_source = self.metadata.hatch.version.source if not isinstance(version_source, VersioningitSource): raise RuntimeError( From 6c38134184a0fc2b07b7b8cc2ad68be5ed9bb8ae Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Sat, 20 Jul 2024 08:40:39 -0400 Subject: [PATCH 20/21] =?UTF-8?q?v3.1.2=20=E2=80=94=20Bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Drop support for Python 3.7 - **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild` step for editable builds --- CHANGELOG.md | 4 ++-- docs/changelog.rst | 4 ++-- src/versioningit/__init__.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d297692..e1a7efe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -v3.1.2 (in development) ------------------------ +v3.1.2 (2024-07-20) +------------------- - Drop support for Python 3.7 - **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild` step for editable builds diff --git a/docs/changelog.rst b/docs/changelog.rst index ffc293c..6969d36 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,8 +3,8 @@ Changelog ========= -v3.2.0 (in development) ------------------------ +v3.1.2 (2024-07-20) +------------------- - Drop support for Python 3.7 - **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild` step for editable builds diff --git a/src/versioningit/__init__.py b/src/versioningit/__init__.py index f6cf509..d92f0dc 100644 --- a/src/versioningit/__init__.py +++ b/src/versioningit/__init__.py @@ -43,7 +43,7 @@ for more information. """ -__version__ = "3.1.2.dev1" +__version__ = "3.1.2" __author__ = "John Thorvald Wodder II" __author_email__ = "versioningit@varonathe.org" __license__ = "MIT" From 6cc54bc88fe0d62f6979276c57e41ecf2925922a Mon Sep 17 00:00:00 2001 From: "John T. Wodder II" Date: Tue, 8 Oct 2024 12:33:06 -0400 Subject: [PATCH 21/21] Update `docs/requirements.txt` --- docs/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 8b64efa..d657b42 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -Sphinx~=7.0 +Sphinx~=8.0 sphinx-copybutton~=0.5.0 sphinx-inline-tabs -sphinx_rtd_theme~=2.0 +sphinx_rtd_theme~=3.0