dycw-pre-commit-hooks 0.13.0__py3-none-any.whl → 0.13.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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-pre-commit-hooks
3
- Version: 0.13.0
3
+ Version: 0.13.2
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
@@ -32,6 +32,7 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
32
32
  - repo: https://github.com/dycw/pre-commit-hooks
33
33
  rev: master
34
34
  hooks:
35
+ - id: check-submodules-updated
35
36
  - id: format-requirements
36
37
  - id: mirror-files
37
38
  - id: replace-sequence-str
@@ -1,6 +1,9 @@
1
- pre_commit_hooks/__init__.py,sha256=VX99Js9MSUXrTMe_OSKIYhYYPRRvI_8mU7_0pIpdJmw,59
1
+ pre_commit_hooks/__init__.py,sha256=FsJ79P0AgK-7XWIC9X52-EYKoU-xt_DIbfxq3FFA2CI,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
+ pre_commit_hooks/check_submodules_updated/__init__.py,sha256=j-NrV-_l_47meqcMz-QxIUOyWloI3coQXXDKg1Jhwgs,900
5
+ pre_commit_hooks/check_submodules_updated/__main__.py,sha256=_-uQnuopAJQiHgoSLRMekYrVBbO9-rjP2s9cCC0u3jQ,161
6
+ pre_commit_hooks/check_submodules_updated/check-submodules-updated,sha256=bgYJ4bUCcRr53HQ0_1pGK-zoWmYg1eEsAd02qJgcrQw,917
4
7
  pre_commit_hooks/format_requirements/__init__.py,sha256=ByGP9oCf5c5-55Tayp8BvnT6O-_Fi5om1AAva1BzLvg,3223
5
8
  pre_commit_hooks/format_requirements/__main__.py,sha256=15JSp_rhjI_Ddoj4MRkHFShfnYxs6GggUhLRlGtrQ0E,156
6
9
  pre_commit_hooks/mirror_files/__init__.py,sha256=GSoFXo_og3d7NkQcmzdWOZyxQJPCO1nr4JtMVVcNJOI,1646
@@ -11,7 +14,7 @@ pre_commit_hooks/run_bump_my_version/__init__.py,sha256=FhvLQEEoFm21_2c_12Loy_lc
11
14
  pre_commit_hooks/run_bump_my_version/__main__.py,sha256=w2V3y61jrSau-zxjl8ciHtWPlJQwXbYxNJ2tGYVyI4s,156
12
15
  pre_commit_hooks/tag_commits/__init__.py,sha256=6HWjXOcTd9gjiZwXmy2lIhZzru-zeRgbpEYxKi1z5sg,3294
13
16
  pre_commit_hooks/tag_commits/__main__.py,sha256=qefgYw7LWbvmzZS45-ym6olS4cHqw1Emw2wlqZBXN_o,148
14
- dycw_pre_commit_hooks-0.13.0.dist-info/METADATA,sha256=iEdyGf05U2B_FOypZ9Um7DknncrbYhHIdA9_zskLIzU,1101
15
- dycw_pre_commit_hooks-0.13.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- dycw_pre_commit_hooks-0.13.0.dist-info/entry_points.txt,sha256=OTVj55u2A6hqtbiPa_h9Zd9pTToCsI9P5xpzE3g4NZc,310
17
- dycw_pre_commit_hooks-0.13.0.dist-info/RECORD,,
17
+ dycw_pre_commit_hooks-0.13.2.dist-info/METADATA,sha256=ntjyRLU0LhWnCXirp5srH7mY0-iIlkDBcDoqsFyOp10,1141
18
+ dycw_pre_commit_hooks-0.13.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ dycw_pre_commit_hooks-0.13.2.dist-info/entry_points.txt,sha256=NhMhVnLeFn50DKZgCDL7dmeQ2Kdt-sItuoOIYBODw7o,384
20
+ dycw_pre_commit_hooks-0.13.2.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  [console_scripts]
2
+ check-submodules-updated = pre_commit_hooks.check_submodules_updated:main
2
3
  format-requirements = pre_commit_hooks.format_requirements:main
3
4
  mirror-files = pre_commit_hooks.mirror_files:main
4
5
  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.0"
3
+ __version__ = "0.13.2"
@@ -0,0 +1,35 @@
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
+ from whenever import DateTimeDelta
15
+
16
+
17
+ @command()
18
+ @run_every_option
19
+ def main(*, run_every: DateTimeDelta | None = None) -> bool:
20
+ """CLI for the `check-submodules-updated` hook."""
21
+ return throttled_run("check-submodules-updated", run_every, _process)
22
+
23
+
24
+ def _process() -> bool:
25
+ file = cast("Path", files("pre_commit_hooks")).joinpath(
26
+ "check_submodules_updated", "check-submodules-updated"
27
+ )
28
+ try:
29
+ _ = run([str(file)], check=True)
30
+ except SubprocessError:
31
+ return False
32
+ return True
33
+
34
+
35
+ __all__ = ["main", "run_all", "write_text"]
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from pre_commit_hooks.check_submodules_updated import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(int(not main()))
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env sh
2
+
3
+ echo_date() { echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*"; }
4
+ get_sha() { git rev-parse --short "$1"; }
5
+
6
+ main() {
7
+ if [ $# -ne 0 ]; then
8
+ echo_date "'check-submodules-updated' accepts 0 arguments; got $#" >&2 && return 1
9
+ fi
10
+ behind=false
11
+ for path in $(git config --file .gitmodules --get-regexp path | awk '{print $2}'); do
12
+ if ! (
13
+ if ! cd "${path}"; then
14
+ echo_date "Failed to 'cd' into '${path}'" >&2 && exit 1
15
+ fi
16
+ if ! git fetch origin master; then
17
+ echo_date "For '${path}', failed to fetch 'origin/master'" >&2 && exit 1
18
+ fi
19
+ local_sha=$(get_sha HEAD)
20
+ remote_sha=$(get_sha origin/master)
21
+ if [ "${local_sha}" != "${remote_sha}" ]; then
22
+ echo_date "For '${path}', local and remote must have the same SHA; got '${local_sha}' and '${remote_sha}'" >&2 && exit 1
23
+ fi
24
+ ); then
25
+ behind=true
26
+ fi
27
+ done
28
+ if "${behind}"; then
29
+ return 1
30
+ else
31
+ return 0
32
+ fi
33
+ }
34
+
35
+ main "$@"