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