dycw-pre-commit-hooks 0.12.10__py3-none-any.whl → 0.13.1__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.12.10
3
+ Version: 0.13.1
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,8 +32,9 @@ 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
35
+ - id: check-submodules-updated
36
36
  - id: format-requirements
37
+ - id: mirror-files
37
38
  - id: replace-sequence-str
38
39
  - id: run-bump-my-version
39
40
  - id: tag-commits
@@ -1,8 +1,9 @@
1
- pre_commit_hooks/__init__.py,sha256=XUa7teN-vfW7cBdLFmZJi5bnnqzvnrGbZY3GK3org8U,60
1
+ pre_commit_hooks/__init__.py,sha256=XDh4WYUHQpFHqfiNjwLsIiVWCHsk_R5GkN8WEkuVTzI,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/__init__.py,sha256=DJWJHzuYRwTNcx37MoE76X54DzXl9tHFPqSwBr8ckOA,1275
5
- pre_commit_hooks/check_submodules/__main__.py,sha256=foSVebwCfSkKcAc3cD5YTzkmrWd7Wso9_mR9-zuyG-o,153
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
6
7
  pre_commit_hooks/format_requirements/__init__.py,sha256=ByGP9oCf5c5-55Tayp8BvnT6O-_Fi5om1AAva1BzLvg,3223
7
8
  pre_commit_hooks/format_requirements/__main__.py,sha256=15JSp_rhjI_Ddoj4MRkHFShfnYxs6GggUhLRlGtrQ0E,156
8
9
  pre_commit_hooks/mirror_files/__init__.py,sha256=GSoFXo_og3d7NkQcmzdWOZyxQJPCO1nr4JtMVVcNJOI,1646
@@ -13,7 +14,7 @@ pre_commit_hooks/run_bump_my_version/__init__.py,sha256=FhvLQEEoFm21_2c_12Loy_lc
13
14
  pre_commit_hooks/run_bump_my_version/__main__.py,sha256=w2V3y61jrSau-zxjl8ciHtWPlJQwXbYxNJ2tGYVyI4s,156
14
15
  pre_commit_hooks/tag_commits/__init__.py,sha256=6HWjXOcTd9gjiZwXmy2lIhZzru-zeRgbpEYxKi1z5sg,3294
15
16
  pre_commit_hooks/tag_commits/__main__.py,sha256=qefgYw7LWbvmzZS45-ym6olS4cHqw1Emw2wlqZBXN_o,148
16
- dycw_pre_commit_hooks-0.12.10.dist-info/METADATA,sha256=k9yZ--US0dvsnixJb2nmU1vzM6kMzjHIpnvE9NVmRtw,1106
17
- dycw_pre_commit_hooks-0.12.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- dycw_pre_commit_hooks-0.12.10.dist-info/entry_points.txt,sha256=0xGzim6HTjeOXJpusYjBk0aEYkXQR2IwrmfzM6KT_r0,368
19
- dycw_pre_commit_hooks-0.12.10.dist-info/RECORD,,
17
+ dycw_pre_commit_hooks-0.13.1.dist-info/METADATA,sha256=52dsmzmWQfN0lpavMvJsKe731ZEGRL7vrQ8foeoJTqM,1141
18
+ dycw_pre_commit_hooks-0.13.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ dycw_pre_commit_hooks-0.13.1.dist-info/entry_points.txt,sha256=OTVj55u2A6hqtbiPa_h9Zd9pTToCsI9P5xpzE3g4NZc,310
20
+ dycw_pre_commit_hooks-0.13.1.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  [console_scripts]
2
- check-submodules = pre_commit_hooks.check_submodules:main
3
2
  format-requirements = pre_commit_hooks.format_requirements:main
4
3
  mirror-files = pre_commit_hooks.mirror_files:main
5
4
  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.12.10"
3
+ __version__ = "0.13.1"
@@ -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"]
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from pre_commit_hooks.check_submodules import main
3
+ from pre_commit_hooks.check_submodules_updated import main
4
4
 
5
5
  if __name__ == "__main__":
6
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 "$@"
@@ -1,56 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import TYPE_CHECKING
4
-
5
- import utilities.click
6
- from click import argument, command
7
- from git import Repo, Submodule
8
-
9
- from pre_commit_hooks.common import (
10
- DEFAULT_MODE,
11
- Mode,
12
- get_toml_path,
13
- get_version,
14
- mode_option,
15
- run_all,
16
- run_every_option,
17
- throttled_run,
18
- )
19
-
20
- if TYPE_CHECKING:
21
- from pathlib import Path
22
-
23
- from whenever import DateTimeDelta
24
-
25
-
26
- @command()
27
- @argument("paths", nargs=-1, type=utilities.click.Path())
28
- @run_every_option
29
- def main(*, paths: tuple[Path, ...], run_every: DateTimeDelta | None = None) -> bool:
30
- """CLI for the `check-submodules` hook."""
31
- return run_all(
32
- throttled_run("check-submodules", run_every, _process, p) for p in paths
33
- )
34
-
35
-
36
- def _process(path: Path, /) -> bool:
37
- repo = Repo(path, search_parent_directories=True)
38
- return run_all(_process_submodule(s) for s in repo.submodules)
39
-
40
-
41
- def _process_submodule(submodule: Submodule, /) -> bool:
42
- repo = submodule.module()
43
- _ = repo.remotes.origin.fetch()
44
- local = repo.commit("master")
45
- remote = repo.commit("origin/master")
46
- return local.hexsha == remote.hexsha
47
-
48
-
49
- __all__ = [
50
- "DEFAULT_MODE",
51
- "Mode",
52
- "get_toml_path",
53
- "get_version",
54
- "main",
55
- "mode_option",
56
- ]