dycw-pre-commit-hooks 0.13.3__py3-none-any.whl → 0.13.4__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.13.3
3
+ Version: 0.13.4
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: click<8.3,>=8.2.1
@@ -33,6 +33,7 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
33
33
  rev: master
34
34
  hooks:
35
35
  - id: check-submodules-updated
36
+ - id: check-version-bumped
36
37
  - id: format-requirements
37
38
  - id: mirror-files
38
39
  - id: replace-sequence-str
@@ -1,9 +1,12 @@
1
- pre_commit_hooks/__init__.py,sha256=floLWm48dua3qihPRV76d1j0to53voZnQ37c7FuVpyI,59
1
+ pre_commit_hooks/__init__.py,sha256=L00KYwDuvWYAcVeBI2vLilhyVgOyXcZn_OjbD9_V1WE,59
2
2
  pre_commit_hooks/common.py,sha256=BkGWepSj_y_y6pOrvKX4G8259o5Klp1C-Yg2cdDTi0s,4482
3
3
  pre_commit_hooks/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pre_commit_hooks/check_submodules_updated/__init__.py,sha256=j-NrV-_l_47meqcMz-QxIUOyWloI3coQXXDKg1Jhwgs,900
5
5
  pre_commit_hooks/check_submodules_updated/__main__.py,sha256=_-uQnuopAJQiHgoSLRMekYrVBbO9-rjP2s9cCC0u3jQ,161
6
6
  pre_commit_hooks/check_submodules_updated/check-submodules-updated,sha256=bgYJ4bUCcRr53HQ0_1pGK-zoWmYg1eEsAd02qJgcrQw,917
7
+ pre_commit_hooks/check_version_bumped/__init__.py,sha256=9WQ4hx2KyPpeboAH4wKQc407dlPjjqmUDObKS9SvIaM,774
8
+ pre_commit_hooks/check_version_bumped/__main__.py,sha256=ujl_2PmNW065bAKzVmJzgCYW70fxGy9hqtT-B0dhWok,157
9
+ pre_commit_hooks/check_version_bumped/check-version-bumped,sha256=5JEOYakcAHzpw_4m6feB8PROsyp6ZVH746UXzZGfOT4,1918
7
10
  pre_commit_hooks/format_requirements/__init__.py,sha256=ByGP9oCf5c5-55Tayp8BvnT6O-_Fi5om1AAva1BzLvg,3223
8
11
  pre_commit_hooks/format_requirements/__main__.py,sha256=15JSp_rhjI_Ddoj4MRkHFShfnYxs6GggUhLRlGtrQ0E,156
9
12
  pre_commit_hooks/mirror_files/__init__.py,sha256=GSoFXo_og3d7NkQcmzdWOZyxQJPCO1nr4JtMVVcNJOI,1646
@@ -14,7 +17,7 @@ pre_commit_hooks/run_bump_my_version/__init__.py,sha256=FhvLQEEoFm21_2c_12Loy_lc
14
17
  pre_commit_hooks/run_bump_my_version/__main__.py,sha256=w2V3y61jrSau-zxjl8ciHtWPlJQwXbYxNJ2tGYVyI4s,156
15
18
  pre_commit_hooks/tag_commits/__init__.py,sha256=6HWjXOcTd9gjiZwXmy2lIhZzru-zeRgbpEYxKi1z5sg,3294
16
19
  pre_commit_hooks/tag_commits/__main__.py,sha256=qefgYw7LWbvmzZS45-ym6olS4cHqw1Emw2wlqZBXN_o,148
17
- dycw_pre_commit_hooks-0.13.3.dist-info/METADATA,sha256=ei-7ZTkO9visi6Sm9FcQH5ksRgeeckKqMw47LWcDe-g,1141
18
- dycw_pre_commit_hooks-0.13.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
- dycw_pre_commit_hooks-0.13.3.dist-info/entry_points.txt,sha256=NhMhVnLeFn50DKZgCDL7dmeQ2Kdt-sItuoOIYBODw7o,384
20
- dycw_pre_commit_hooks-0.13.3.dist-info/RECORD,,
20
+ dycw_pre_commit_hooks-0.13.4.dist-info/METADATA,sha256=xop5zO4J-sO1VsZPHJ4GryHQCVEgPANFCwI2ElaDh3c,1177
21
+ dycw_pre_commit_hooks-0.13.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ dycw_pre_commit_hooks-0.13.4.dist-info/entry_points.txt,sha256=mpEGGgi0HF_ukOSex2k3_DnActXAj3rMtHv5uwO2sMI,450
23
+ dycw_pre_commit_hooks-0.13.4.dist-info/RECORD,,
@@ -1,5 +1,6 @@
1
1
  [console_scripts]
2
2
  check-submodules-updated = pre_commit_hooks.check_submodules_updated:main
3
+ check-version-bumped = pre_commit_hooks.check_version_bumped:main
3
4
  format-requirements = pre_commit_hooks.format_requirements:main
4
5
  mirror-files = pre_commit_hooks.mirror_files:main
5
6
  replace-sequence-str = pre_commit_hooks.replace_sequence_str:main
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.13.3"
3
+ __version__ = "0.13.4"
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ from importlib.resources import files
4
+ from subprocess import SubprocessError, run
5
+ from typing import TYPE_CHECKING, cast
6
+
7
+ from click import command
8
+
9
+ from pre_commit_hooks.common import run_all, run_every_option, throttled_run, write_text
10
+
11
+ if TYPE_CHECKING:
12
+ from pathlib import Path
13
+
14
+
15
+ @command()
16
+ def main() -> bool:
17
+ """CLI for the `check-version-bumped` hook."""
18
+ return _process()
19
+
20
+
21
+ def _process() -> bool:
22
+ file = cast("Path", files("pre_commit_hooks")).joinpath(
23
+ "check_version_bumped", "check-version-bumped"
24
+ )
25
+ try:
26
+ _ = run([str(file)], check=True)
27
+ except SubprocessError:
28
+ return False
29
+ return True
30
+
31
+
32
+ __all__ = ["main", "run_all", "run_every_option", "throttled_run", "write_text"]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from pre_commit_hooks.check_version_bumped import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(int(not main()))
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env sh
2
+
3
+ echo_date() { echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*"; }
4
+ get_origin_master_version() {
5
+ if ! git show-ref --verify --quiet refs/remotes/origin/master; then
6
+ echo_date "'origin/master' does not exist; fetching..." >&2 && exit 1
7
+ if ! git fetch origin master; then
8
+ echo_date "Failed to fetch 'origin/master'" >&2 && exit 1
9
+ fi
10
+ fi
11
+ temp_dir=$(mktemp -d)
12
+ trap 'rm -rf "${temp_dir}"' EXIT HUP INT TERM
13
+ if ! git show "origin/master:$1" >"${temp_dir}/$1"; then
14
+ echo_date "File '$1' does not exist on 'origin/master'" >&2 && return 1
15
+ fi
16
+ (
17
+ if ! cd "${temp_dir}"; then
18
+ echo_date "Failed to 'cd' into '${temp_dir}'" >&2 && exit 1
19
+ fi
20
+ get_version
21
+ )
22
+ }
23
+ get_version() { bump-my-version show current_version; }
24
+ has_one_commit() { git rev-parse --verify HEAD >/dev/null 2>&1; }
25
+ have_command() { command -v "$1" >/dev/null 2>&1; }
26
+ have_bump_my_version() { have_command 'bump-my-version'; }
27
+
28
+ main() {
29
+ if ! has_one_commit; then
30
+ echo_date "There must be at least 1 commit; got none" >&2 && return 1
31
+ elif [ $# -ne 0 ]; then
32
+ echo_date "'check-version-bumped' accepts 0 arguments; got $#" >&2 && return 1
33
+ elif ! have_bump_my_version && ! have_command pip; then
34
+ echo_date "'bump-my-version' or 'pip' must be available" >&2 && return 1
35
+ fi
36
+ if ! have_bump_my_version && have_command pip; then
37
+ pip install bump-my-version
38
+ fi
39
+ if ! have_bump_my_version; then
40
+ echo_date "'bump-my-version' must be available" >&2 && return 1
41
+ fi
42
+ current=$(get_version)
43
+ if [ $# -ne 0 ]; then
44
+ echo_date "Failed to get current version" >&2 && return 1
45
+ fi
46
+ if [ -f '.bumpversion.toml' ]; then
47
+ previous=$(get_origin_master_version '.bumpversion.toml')
48
+ elif [ -f 'pyproject.toml' ]; then
49
+ previous=$(get_origin_master_version 'pyproject.toml')
50
+ fi
51
+ if [ "${current}" = "${previous}" ]; then
52
+ echo_date "Both 'HEAD' and 'origin/master' have version '${current}'" >&2 && return 1
53
+ fi
54
+ return 0
55
+ }
56
+
57
+ main "$@"