dycw-pre-commit-hooks 0.12.1__py3-none-any.whl → 0.12.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dycw-pre-commit-hooks might be problematic. Click here for more details.
- {dycw_pre_commit_hooks-0.12.1.dist-info → dycw_pre_commit_hooks-0.12.2.dist-info}/METADATA +1 -1
- {dycw_pre_commit_hooks-0.12.1.dist-info → dycw_pre_commit_hooks-0.12.2.dist-info}/RECORD +8 -8
- pre_commit_hooks/__init__.py +1 -1
- pre_commit_hooks/common.py +11 -21
- pre_commit_hooks/run_bump_my_version/__init__.py +27 -5
- pre_commit_hooks/tag_commits/__init__.py +1 -1
- {dycw_pre_commit_hooks-0.12.1.dist-info → dycw_pre_commit_hooks-0.12.2.dist-info}/WHEEL +0 -0
- {dycw_pre_commit_hooks-0.12.1.dist-info → dycw_pre_commit_hooks-0.12.2.dist-info}/entry_points.txt +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
pre_commit_hooks/__init__.py,sha256=
|
|
2
|
-
pre_commit_hooks/common.py,sha256=
|
|
1
|
+
pre_commit_hooks/__init__.py,sha256=tiNQ40NwKZSP_S-wg-yypkGWxyH5-ueuWipPiizKx8U,59
|
|
2
|
+
pre_commit_hooks/common.py,sha256=rIfVTUYfmeQq7Vk4m_Of-JGqABZlB7dfCyGo2WTibas,2078
|
|
3
3
|
pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
pre_commit_hooks/format_requirements/__init__.py,sha256=bn1JsblINCf0ro2QrhsM8XtTOHnPFSZC2t-Hx5AJDfA,3392
|
|
5
5
|
pre_commit_hooks/format_requirements/__main__.py,sha256=15JSp_rhjI_Ddoj4MRkHFShfnYxs6GggUhLRlGtrQ0E,156
|
|
6
6
|
pre_commit_hooks/replace_sequence_str/__init__.py,sha256=a-pCAcBaa7FDsGDNLzMiD-xG20wKl-SRmhWSbm9hrvo,1618
|
|
7
7
|
pre_commit_hooks/replace_sequence_str/__main__.py,sha256=B1dxOxngV4vUVnDVrXSywiySOs1P_zF30_4ZMRsOSaY,157
|
|
8
|
-
pre_commit_hooks/run_bump_my_version/__init__.py,sha256=
|
|
8
|
+
pre_commit_hooks/run_bump_my_version/__init__.py,sha256=EOKRq04eIKojyfgfvlaPfWeKxOWkEBjmz2UOcuk6U_o,2068
|
|
9
9
|
pre_commit_hooks/run_bump_my_version/__main__.py,sha256=w2V3y61jrSau-zxjl8ciHtWPlJQwXbYxNJ2tGYVyI4s,156
|
|
10
|
-
pre_commit_hooks/tag_commits/__init__.py,sha256=
|
|
10
|
+
pre_commit_hooks/tag_commits/__init__.py,sha256=AmHKjIAMfXZ6T0nw6CiOFTjFzmmVSOonmKyhASZ_sgE,3665
|
|
11
11
|
pre_commit_hooks/tag_commits/__main__.py,sha256=qefgYw7LWbvmzZS45-ym6olS4cHqw1Emw2wlqZBXN_o,148
|
|
12
|
-
dycw_pre_commit_hooks-0.12.
|
|
13
|
-
dycw_pre_commit_hooks-0.12.
|
|
14
|
-
dycw_pre_commit_hooks-0.12.
|
|
15
|
-
dycw_pre_commit_hooks-0.12.
|
|
12
|
+
dycw_pre_commit_hooks-0.12.2.dist-info/METADATA,sha256=DdndJ2NzELgAG-gBuL1cvnDLTEPCAe04GMhKLjju-zs,1029
|
|
13
|
+
dycw_pre_commit_hooks-0.12.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
dycw_pre_commit_hooks-0.12.2.dist-info/entry_points.txt,sha256=r1tnPzaGvOrSdX-ZRriidf8AhZgUtXfjdTpwpkTBA8U,260
|
|
15
|
+
dycw_pre_commit_hooks-0.12.2.dist-info/RECORD,,
|
pre_commit_hooks/__init__.py
CHANGED
pre_commit_hooks/common.py
CHANGED
|
@@ -12,51 +12,41 @@ from utilities.version import Version, parse_version
|
|
|
12
12
|
PYPROJECT_TOML = get_repo_root().joinpath("pyproject.toml")
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
def get_version(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"""Parse the version from a block of text."""
|
|
19
|
-
match path_or_text:
|
|
15
|
+
def get_version(source: Path | str | bytes | TOMLDocument, /) -> Version:
|
|
16
|
+
"""Get the `[tool.bumpversion]` version from a TOML file."""
|
|
17
|
+
match source:
|
|
20
18
|
case Path() as path:
|
|
21
|
-
return get_version(
|
|
22
|
-
path.read_text(), desc=f" from {str(path)!r}" if desc == "" else desc
|
|
23
|
-
)
|
|
19
|
+
return get_version(path.read_text())
|
|
24
20
|
case str() | bytes() as text:
|
|
25
|
-
return get_version(parse(text)
|
|
21
|
+
return get_version(parse(text))
|
|
26
22
|
case TOMLDocument() as doc:
|
|
27
23
|
try:
|
|
28
24
|
tool = doc["tool"]
|
|
29
25
|
except KeyError:
|
|
30
|
-
logger.exception(
|
|
31
|
-
f"Failed to get version{desc}; key 'tool' does not exist"
|
|
32
|
-
)
|
|
26
|
+
logger.exception("Failed to get version; key 'tool' does not exist")
|
|
33
27
|
raise
|
|
34
28
|
if not isinstance(tool, Table):
|
|
35
|
-
logger.exception(
|
|
29
|
+
logger.exception("Failed to get version; `tool` is not a Table")
|
|
36
30
|
raise TypeError
|
|
37
31
|
try:
|
|
38
32
|
bumpversion = tool["bumpversion"]
|
|
39
33
|
except KeyError:
|
|
40
34
|
logger.exception(
|
|
41
|
-
|
|
35
|
+
"Failed to get version; key 'bumpversion' does not exist"
|
|
42
36
|
)
|
|
43
37
|
raise
|
|
44
38
|
if not isinstance(bumpversion, Table):
|
|
45
|
-
logger.exception(
|
|
46
|
-
f"Failed to get version{desc}; `bumpversion` is not a Table"
|
|
47
|
-
)
|
|
39
|
+
logger.exception("Failed to get version; `bumpversion` is not a Table")
|
|
48
40
|
raise TypeError
|
|
49
41
|
try:
|
|
50
42
|
version = bumpversion["current_version"]
|
|
51
43
|
except KeyError:
|
|
52
44
|
logger.exception(
|
|
53
|
-
|
|
45
|
+
"Failed to get version; key 'current_version' does not exist"
|
|
54
46
|
)
|
|
55
47
|
raise
|
|
56
48
|
if not isinstance(version, str):
|
|
57
|
-
logger.exception(
|
|
58
|
-
f"Failed to get version{desc}; `version` is not a string"
|
|
59
|
-
)
|
|
49
|
+
logger.exception("Failed to get version; `version` is not a string")
|
|
60
50
|
raise TypeError
|
|
61
51
|
return parse_version(version)
|
|
62
52
|
case never: # pyright: ignore[reportUnnecessaryComparison]
|
|
@@ -2,21 +2,32 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from subprocess import PIPE, STDOUT, CalledProcessError, check_call, check_output
|
|
5
|
+
from typing import Literal, assert_never
|
|
5
6
|
|
|
6
|
-
from click import command
|
|
7
|
+
from click import Choice, command, option
|
|
7
8
|
from loguru import logger
|
|
9
|
+
from utilities.pathlib import get_repo_root
|
|
8
10
|
|
|
9
11
|
from pre_commit_hooks.common import PYPROJECT_TOML, get_version
|
|
10
12
|
|
|
13
|
+
type _Mode = Literal["pyproject", "bumpversion"]
|
|
14
|
+
_MODE: _Mode = "pyproject"
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
@command()
|
|
13
|
-
|
|
18
|
+
@option(
|
|
19
|
+
"--mode",
|
|
20
|
+
type=Choice(["pyproject", "bumpversion"], case_sensitive=False),
|
|
21
|
+
default=_MODE,
|
|
22
|
+
show_default=True,
|
|
23
|
+
)
|
|
24
|
+
def main(*, mode: _Mode = _MODE) -> bool:
|
|
14
25
|
"""CLI for the `run_bump_my_version` hook."""
|
|
15
|
-
return _process()
|
|
26
|
+
return _process(mode=mode)
|
|
16
27
|
|
|
17
28
|
|
|
18
|
-
def _process() -> bool:
|
|
19
|
-
path =
|
|
29
|
+
def _process(*, mode: _Mode = _MODE) -> bool:
|
|
30
|
+
path = _get_rel_path(mode=mode)
|
|
20
31
|
current = get_version(path)
|
|
21
32
|
commit = check_output(["git", "rev-parse", "origin/master"], text=True).rstrip("\n")
|
|
22
33
|
contents = check_output(["git", "show", f"{commit}:{path}"], text=True)
|
|
@@ -44,4 +55,15 @@ def _process() -> bool:
|
|
|
44
55
|
return False
|
|
45
56
|
|
|
46
57
|
|
|
58
|
+
def _get_rel_path(*, mode: _Mode = _MODE) -> Path:
|
|
59
|
+
match mode:
|
|
60
|
+
case "pyproject":
|
|
61
|
+
path = PYPROJECT_TOML
|
|
62
|
+
case "bumpversion":
|
|
63
|
+
path = get_repo_root().joinpath(".bumpversion.toml")
|
|
64
|
+
case never: # pyright: ignore[reportUnnecessaryComparison]
|
|
65
|
+
assert_never(never)
|
|
66
|
+
return path.relative_to(Path.cwd())
|
|
67
|
+
|
|
68
|
+
|
|
47
69
|
__all__ = ["main"]
|
|
@@ -113,7 +113,7 @@ def _tag_commit(commit: Commit, repo: Repo, /) -> None:
|
|
|
113
113
|
logger.exception(f"`pyproject.toml` not found; failed to tag {sha!r} ({date})")
|
|
114
114
|
return
|
|
115
115
|
text = joined.data_stream.read()
|
|
116
|
-
version = get_version(text
|
|
116
|
+
version = get_version(text)
|
|
117
117
|
try:
|
|
118
118
|
tag = repo.create_tag(str(version), ref=sha)
|
|
119
119
|
except GitCommandError as error:
|
|
File without changes
|
{dycw_pre_commit_hooks-0.12.1.dist-info → dycw_pre_commit_hooks-0.12.2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|