sync-pre-commit-deps 0.0.4__tar.gz → 0.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sync_pre_commit_deps
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Sync pre-commit hook dependencies based on other installed hooks
5
5
  Home-page: https://github.com/pre-commit/sync-pre-commit-deps
6
6
  Author: Max R
@@ -35,7 +35,7 @@ Sample `.pre-commit-config.yaml`:
35
35
 
36
36
  ```yaml
37
37
  - repo: https://github.com/pre-commit/sync-pre-commit-deps
38
- rev: v0.0.4
38
+ rev: v0.0.5
39
39
  hooks:
40
40
  - id: sync-pre-commit-deps
41
41
  ```
@@ -17,7 +17,7 @@ Sample `.pre-commit-config.yaml`:
17
17
 
18
18
  ```yaml
19
19
  - repo: https://github.com/pre-commit/sync-pre-commit-deps
20
- rev: v0.0.4
20
+ rev: v0.0.5
21
21
  hooks:
22
22
  - id: sync-pre-commit-deps
23
23
  ```
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = sync_pre_commit_deps
3
- version = 0.0.4
3
+ version = 0.0.5
4
4
  description = Sync pre-commit hook dependencies based on other installed hooks
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sync_pre_commit_deps
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Sync pre-commit hook dependencies based on other installed hooks
5
5
  Home-page: https://github.com/pre-commit/sync-pre-commit-deps
6
6
  Author: Max R
@@ -35,7 +35,7 @@ Sample `.pre-commit-config.yaml`:
35
35
 
36
36
  ```yaml
37
37
  - repo: https://github.com/pre-commit/sync-pre-commit-deps
38
- rev: v0.0.4
38
+ rev: v0.0.5
39
39
  hooks:
40
40
  - id: sync-pre-commit-deps
41
41
  ```
@@ -20,6 +20,23 @@ SUPPORTED = {
20
20
 
21
21
  _SEPS = ('==', '@')
22
22
  _RE_SEP = re.compile(rf'^(.+)({"|".join(_SEPS)})(.+)$')
23
+ _RE_FROZEN = re.compile(r'#\s*frozen:\s*(\S+)')
24
+
25
+
26
+ def _version(repo: ruamel.yaml.comments.CommentedMap) -> str:
27
+ tokens = repo.ca.items.get('rev') or ()
28
+ for token in tokens:
29
+ if token and (match := _RE_FROZEN.search(token.value)):
30
+ rev = match.group(1)
31
+ break
32
+ else:
33
+ rev = repo['rev']
34
+
35
+ # `mirrors-mypy` and various node revs have a 'v' prefix,
36
+ # so we have to strip that out to get the
37
+ # additional_dependency version.
38
+ return rev.removeprefix('v')
39
+
23
40
 
24
41
  _ARGUMENT_HELP_TEMPLATE = (
25
42
  'The `{}` argument to the YAML dumper. '
@@ -69,11 +86,7 @@ def main(argv: Sequence[str] | None = None) -> int:
69
86
  if repo['repo'] not in ('local', 'meta'):
70
87
  for hook in repo['hooks']:
71
88
  if (dep := SUPPORTED.get(hook['id'])) is not None:
72
- # `mirrors-mypy` and various node revs have a 'v' prefix,
73
- # so we have to strip that out to get the
74
- # additional_dependency version.
75
- cleaned_rev = repo['rev'].removeprefix('v')
76
- versions[dep] = cleaned_rev
89
+ versions[dep] = _version(repo)
77
90
 
78
91
  updated = []
79
92
  for repo in loaded['repos']: