dycw-pre-commit-hooks 0.13.0__tar.gz → 0.13.2__tar.gz

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.

Files changed (26) hide show
  1. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/PKG-INFO +2 -1
  2. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/README.md +1 -0
  3. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/pyproject.toml +3 -2
  4. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/__init__.py +1 -1
  5. dycw_pre_commit_hooks-0.13.2/src/pre_commit_hooks/check_submodules_updated/__init__.py +35 -0
  6. dycw_pre_commit_hooks-0.13.2/src/pre_commit_hooks/check_submodules_updated/__main__.py +6 -0
  7. dycw_pre_commit_hooks-0.13.2/src/pre_commit_hooks/check_submodules_updated/check-submodules-updated +35 -0
  8. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/.gitignore +0 -0
  9. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/common.py +0 -0
  10. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/format_requirements/__init__.py +0 -0
  11. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/format_requirements/__main__.py +0 -0
  12. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/mirror_files/__init__.py +0 -0
  13. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/mirror_files/__main__.py +0 -0
  14. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/py.typed +0 -0
  15. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/replace_sequence_str/__init__.py +0 -0
  16. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/replace_sequence_str/__main__.py +0 -0
  17. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/run_bump_my_version/__init__.py +0 -0
  18. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/run_bump_my_version/__main__.py +0 -0
  19. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/tag_commits/__init__.py +0 -0
  20. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/pre_commit_hooks/tag_commits/__main__.py +0 -0
  21. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/__init__.py +0 -0
  22. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/format_requirements/__init__.py +0 -0
  23. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/format_requirements/in.toml +0 -0
  24. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/format_requirements/out.toml +0 -0
  25. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/format_requirements/test_format_requirements.py +0 -0
  26. {dycw_pre_commit_hooks-0.13.0 → dycw_pre_commit_hooks-0.13.2}/src/tests/test_main.py +0 -0
@@ -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
@@ -15,6 +15,7 @@ My [`pre-commit`](https://pre-commit.com/) hooks.
15
15
  - repo: https://github.com/dycw/pre-commit-hooks
16
16
  rev: master
17
17
  hooks:
18
+ - id: check-submodules-updated
18
19
  - id: format-requirements
19
20
  - id: mirror-files
20
21
  - id: replace-sequence-str
@@ -31,9 +31,10 @@ dependencies = [
31
31
  name = "dycw-pre-commit-hooks"
32
32
  readme = "README.md"
33
33
  requires-python = ">= 3.12"
34
- version = "0.13.0"
34
+ version = "0.13.2"
35
35
 
36
36
  [project.scripts]
37
+ check-submodules-updated = "pre_commit_hooks.check_submodules_updated:main"
37
38
  format-requirements = "pre_commit_hooks.format_requirements:main"
38
39
  mirror-files = "pre_commit_hooks.mirror_files:main"
39
40
  replace-sequence-str = "pre_commit_hooks.replace_sequence_str:main"
@@ -43,7 +44,7 @@ tag-commits = "pre_commit_hooks.tag_commits:main"
43
44
  # bump-my-version
44
45
  [tool.bumpversion]
45
46
  allow_dirty = true
46
- current_version = "0.13.0"
47
+ current_version = "0.13.2"
47
48
 
48
49
  [[tool.bumpversion.files]]
49
50
  filename = "src/pre_commit_hooks/__init__.py"
@@ -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 "$@"