pre_commit_mirror_maker_2 1.10.0.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.
- pre_commit_mirror_maker_2-1.10.0.1/LICENSE +19 -0
- pre_commit_mirror_maker_2-1.10.0.1/PKG-INFO +74 -0
- pre_commit_mirror_maker_2-1.10.0.1/README.md +55 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/__init__.py +0 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/all/.pre-commit-hooks.yaml +10 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/all/.version +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/languages.py +58 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/main.py +115 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/make_repo.py +102 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/node/.npmignore +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/node/package.json +5 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/python/setup.py +10 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/ruby/pre_commit_fake_gem.gemspec +8 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/rust/Cargo.toml +7 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker/rust/main.rs +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/PKG-INFO +74 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/SOURCES.txt +22 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/dependency_links.txt +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/entry_points.txt +2 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/requires.txt +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/pre_commit_mirror_maker_2.egg-info/top_level.txt +1 -0
- pre_commit_mirror_maker_2-1.10.0.1/setup.cfg +67 -0
- pre_commit_mirror_maker_2-1.10.0.1/setup.py +4 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2014 Anthony Sottile
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pre_commit_mirror_maker_2
|
|
3
|
+
Version: 1.10.0.1
|
|
4
|
+
Summary: Fork of pre-commit-mirror-maker
|
|
5
|
+
Home-page: https://github.com/GideonBear/pre-commit-mirror-maker-2
|
|
6
|
+
Author: Anthony Sottile
|
|
7
|
+
Author-email: asottile@umich.edu
|
|
8
|
+
License: MIT
|
|
9
|
+
Platform: all
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: packaging
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
[](https://github.com/GideonBear/pre-commit-mirror-maker-2/actions/workflows/main.yml)
|
|
21
|
+
[](https://results.pre-commit.ci/latest/github/GideonBear/pre-commit-mirror-maker-2/main)
|
|
22
|
+
|
|
23
|
+
pre-commit-mirror-maker-2
|
|
24
|
+
=======================
|
|
25
|
+
|
|
26
|
+
Scripts for creating mirror repositories that do not have
|
|
27
|
+
.pre-commit-hooks.yaml
|
|
28
|
+
|
|
29
|
+
This is a fork of [pre-commit-mirror-maker](https://github.com/pre-commit/pre-commit-mirror-maker) to add a few features.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
`$ pip install pre-commit-mirror-maker-2`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Sample Usage
|
|
38
|
+
|
|
39
|
+
To see all supported configuration options, run:
|
|
40
|
+
|
|
41
|
+
```console
|
|
42
|
+
$ pre-commit-mirror --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For example: making a mirror of the yapf package:
|
|
46
|
+
|
|
47
|
+
```console
|
|
48
|
+
$ git init mirrors-yapf
|
|
49
|
+
Initialized empty Git repository in /tmp/mirrors-yapf/.git/
|
|
50
|
+
|
|
51
|
+
$ pre-commit-mirror mirrors-yapf --language python --package-name yapf --args=-i --types python
|
|
52
|
+
[main (root-commit) 88bffee] Mirror: 0.1.3
|
|
53
|
+
3 files changed, 16 insertions(+)
|
|
54
|
+
create mode 100644 .pre-commit-hooks.yaml
|
|
55
|
+
create mode 100644 .version
|
|
56
|
+
create mode 100644 setup.py
|
|
57
|
+
[main 24cd5f4] Mirror: 0.1.4
|
|
58
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
59
|
+
[main 6695a76] Mirror: 0.1.5
|
|
60
|
+
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
[main 091ab92] Mirror: 0.22.0
|
|
64
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
65
|
+
|
|
66
|
+
$ ls -al mirrors-yapf/
|
|
67
|
+
total 24
|
|
68
|
+
drwxrwxr-x 3 asottile asottile 4096 May 26 10:00 .
|
|
69
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 ..
|
|
70
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 .git
|
|
71
|
+
-rw-rw-r-- 1 asottile asottile 136 May 26 10:00 .pre-commit-hooks.yaml
|
|
72
|
+
-rw-rw-r-- 1 asottile asottile 137 May 26 10:00 setup.py
|
|
73
|
+
-rw-rw-r-- 1 asottile asottile 7 May 26 10:00 .version
|
|
74
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[](https://github.com/GideonBear/pre-commit-mirror-maker-2/actions/workflows/main.yml)
|
|
2
|
+
[](https://results.pre-commit.ci/latest/github/GideonBear/pre-commit-mirror-maker-2/main)
|
|
3
|
+
|
|
4
|
+
pre-commit-mirror-maker-2
|
|
5
|
+
=======================
|
|
6
|
+
|
|
7
|
+
Scripts for creating mirror repositories that do not have
|
|
8
|
+
.pre-commit-hooks.yaml
|
|
9
|
+
|
|
10
|
+
This is a fork of [pre-commit-mirror-maker](https://github.com/pre-commit/pre-commit-mirror-maker) to add a few features.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
|
|
15
|
+
`$ pip install pre-commit-mirror-maker-2`
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Sample Usage
|
|
19
|
+
|
|
20
|
+
To see all supported configuration options, run:
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
$ pre-commit-mirror --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
For example: making a mirror of the yapf package:
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
$ git init mirrors-yapf
|
|
30
|
+
Initialized empty Git repository in /tmp/mirrors-yapf/.git/
|
|
31
|
+
|
|
32
|
+
$ pre-commit-mirror mirrors-yapf --language python --package-name yapf --args=-i --types python
|
|
33
|
+
[main (root-commit) 88bffee] Mirror: 0.1.3
|
|
34
|
+
3 files changed, 16 insertions(+)
|
|
35
|
+
create mode 100644 .pre-commit-hooks.yaml
|
|
36
|
+
create mode 100644 .version
|
|
37
|
+
create mode 100644 setup.py
|
|
38
|
+
[main 24cd5f4] Mirror: 0.1.4
|
|
39
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
40
|
+
[main 6695a76] Mirror: 0.1.5
|
|
41
|
+
|
|
42
|
+
...
|
|
43
|
+
|
|
44
|
+
[main 091ab92] Mirror: 0.22.0
|
|
45
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
46
|
+
|
|
47
|
+
$ ls -al mirrors-yapf/
|
|
48
|
+
total 24
|
|
49
|
+
drwxrwxr-x 3 asottile asottile 4096 May 26 10:00 .
|
|
50
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 ..
|
|
51
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 .git
|
|
52
|
+
-rw-rw-r-- 1 asottile asottile 136 May 26 10:00 .pre-commit-hooks.yaml
|
|
53
|
+
-rw-rw-r-- 1 asottile asottile 137 May 26 10:00 setup.py
|
|
54
|
+
-rw-rw-r-- 1 asottile asottile 7 May 26 10:00 .version
|
|
55
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
- id: {id}
|
|
2
|
+
name: {name}
|
|
3
|
+
description: {description!r}
|
|
4
|
+
entry: {entry}
|
|
5
|
+
language: {language}
|
|
6
|
+
'{match_key}': {match_val}
|
|
7
|
+
args: {args}
|
|
8
|
+
require_serial: {require_serial}
|
|
9
|
+
additional_dependencies: {additional_dependencies}
|
|
10
|
+
minimum_pre_commit_version: {minimum_pre_commit_version!r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{version}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import subprocess
|
|
5
|
+
import urllib.request
|
|
6
|
+
|
|
7
|
+
from packaging import requirements
|
|
8
|
+
from packaging import version
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def ruby_get_package_versions(package_name: str) -> list[str]:
|
|
12
|
+
url = f'https://rubygems.org/api/v1/versions/{package_name}.json'
|
|
13
|
+
resp = json.load(urllib.request.urlopen(url))
|
|
14
|
+
return list(reversed([version['number'] for version in resp]))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def node_get_package_versions(package_name: str) -> list[str]:
|
|
18
|
+
cmd = ('npm', 'view', package_name, '--json')
|
|
19
|
+
output = json.loads(subprocess.check_output(cmd))
|
|
20
|
+
return output['versions']
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def python_get_package_versions(package_name: str) -> list[str]:
|
|
24
|
+
pypi_name = requirements.Requirement(package_name).name
|
|
25
|
+
url = f'https://pypi.org/pypi/{pypi_name}/json'
|
|
26
|
+
resp = json.load(urllib.request.urlopen(url))
|
|
27
|
+
return sorted(resp['releases'], key=lambda k: version.parse(k))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def rust_get_package_versions(package_name: str) -> list[str]:
|
|
31
|
+
url = f'https://crates.io/api/v1/crates/{package_name}'
|
|
32
|
+
resp = json.load(urllib.request.urlopen(url))
|
|
33
|
+
return list(reversed([version['num'] for version in resp['versions']]))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def node_get_additional_dependencies(
|
|
37
|
+
package_name: str, package_version: str,
|
|
38
|
+
) -> list[str]:
|
|
39
|
+
return [f'{package_name}@{package_version}']
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def rust_get_additional_dependencies(
|
|
43
|
+
package_name: str, package_version: str,
|
|
44
|
+
) -> list[str]:
|
|
45
|
+
return [f'cli:{package_name}:{package_version}']
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
LIST_VERSIONS = {
|
|
49
|
+
'node': node_get_package_versions,
|
|
50
|
+
'python': python_get_package_versions,
|
|
51
|
+
'ruby': ruby_get_package_versions,
|
|
52
|
+
'rust': rust_get_package_versions,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ADDITIONAL_DEPENDENCIES = {
|
|
56
|
+
'node': node_get_additional_dependencies,
|
|
57
|
+
'rust': rust_get_additional_dependencies,
|
|
58
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
|
|
7
|
+
from pre_commit_mirror_maker.make_repo import LIST_VERSIONS
|
|
8
|
+
from pre_commit_mirror_maker.make_repo import make_repo
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def split_by_commas(maybe_s: str) -> tuple[str, ...]:
|
|
12
|
+
"""Split a string by commas, but allow escaped commas.
|
|
13
|
+
- If maybe_s is falsey, returns an empty tuple
|
|
14
|
+
- Ignore backslashed commas
|
|
15
|
+
"""
|
|
16
|
+
if not maybe_s:
|
|
17
|
+
return ()
|
|
18
|
+
parts: list[str] = []
|
|
19
|
+
split_by_backslash = maybe_s.split(r'\,')
|
|
20
|
+
for split_by_backslash_part in split_by_backslash:
|
|
21
|
+
splitby_comma = split_by_backslash_part.split(',')
|
|
22
|
+
if parts:
|
|
23
|
+
parts[-1] += ',' + splitby_comma[0]
|
|
24
|
+
else:
|
|
25
|
+
parts.append(splitby_comma[0])
|
|
26
|
+
parts.extend(splitby_comma[1:])
|
|
27
|
+
return tuple(parts)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
31
|
+
parser = argparse.ArgumentParser()
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
'repo_path',
|
|
34
|
+
help='Local path where the git repo is checked out.',
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
'--language', required=True, choices=LIST_VERSIONS,
|
|
38
|
+
help='Which language to use.',
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
'--package-name', required=True,
|
|
42
|
+
help='Package name as it appears on the remote package manager.',
|
|
43
|
+
)
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
'--description', help='Hook description.', default='',
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
mutex = parser.add_mutually_exclusive_group(required=True)
|
|
49
|
+
mutex.add_argument(
|
|
50
|
+
'--files-regex', help='Files regex to use in hooks.yaml',
|
|
51
|
+
)
|
|
52
|
+
mutex.add_argument('--types', help='`identify` type to AND match')
|
|
53
|
+
mutex.add_argument(
|
|
54
|
+
'--types-or', action='append', help='`identify` type to OR match',
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
'--id', help='Hook id, defaults to the entry point.',
|
|
59
|
+
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
'--entry', help='Entry point, defaults to the package name.',
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
'--args',
|
|
65
|
+
help=(
|
|
66
|
+
'Comma separated arguments for the hook. Escape commas in args '
|
|
67
|
+
'with a backslash (\\). '
|
|
68
|
+
r"For example: --args='-i,--ignore=E265\,E501' would give "
|
|
69
|
+
'you [-i, --ignore=E265,E501]'
|
|
70
|
+
),
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
'--require-serial', action='store_true',
|
|
74
|
+
help='Set `require_serial: true` for the hook',
|
|
75
|
+
)
|
|
76
|
+
args = parser.parse_args(argv)
|
|
77
|
+
|
|
78
|
+
minimum_pre_commit_version = '0'
|
|
79
|
+
|
|
80
|
+
if args.types_or:
|
|
81
|
+
match_key = 'types_or'
|
|
82
|
+
match_val = '[{}]'.format(', '.join(args.types_or))
|
|
83
|
+
minimum_pre_commit_version = '2.9.2'
|
|
84
|
+
elif args.types:
|
|
85
|
+
match_key = 'types'
|
|
86
|
+
match_val = f'[{args.types}]'
|
|
87
|
+
else:
|
|
88
|
+
match_key = 'files'
|
|
89
|
+
match_val = args.files_regex
|
|
90
|
+
|
|
91
|
+
hook_id = args.id or args.entry or args.package_name
|
|
92
|
+
if ' ' in hook_id:
|
|
93
|
+
raise SystemExit(
|
|
94
|
+
f'hook id should not contain spaces, perhaps specify --id?\n\n'
|
|
95
|
+
f'- id: {hook_id}',
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
make_repo(
|
|
99
|
+
args.repo_path,
|
|
100
|
+
name=args.package_name,
|
|
101
|
+
description=args.description,
|
|
102
|
+
language=args.language,
|
|
103
|
+
entry=args.entry or args.package_name,
|
|
104
|
+
id=hook_id,
|
|
105
|
+
match_key=match_key,
|
|
106
|
+
match_val=match_val,
|
|
107
|
+
args=json.dumps(split_by_commas(args.args)),
|
|
108
|
+
require_serial=json.dumps(args.require_serial),
|
|
109
|
+
minimum_pre_commit_version=minimum_pre_commit_version,
|
|
110
|
+
)
|
|
111
|
+
return 0
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == '__main__':
|
|
115
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib.resources
|
|
4
|
+
import json
|
|
5
|
+
import os.path
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
from pre_commit_mirror_maker.languages import ADDITIONAL_DEPENDENCIES
|
|
9
|
+
from pre_commit_mirror_maker.languages import LIST_VERSIONS
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def format_files(src: os.PathLike[str], dest: str, **fmt_vars: str) -> None:
|
|
13
|
+
"""Copies all files inside src into dest while formatting the contents
|
|
14
|
+
of the files into the output.
|
|
15
|
+
|
|
16
|
+
For example, a file with the following contents:
|
|
17
|
+
|
|
18
|
+
{foo} bar {baz}
|
|
19
|
+
|
|
20
|
+
and the vars {'foo': 'herp', 'baz': 'derp'}
|
|
21
|
+
|
|
22
|
+
will end up in the output as
|
|
23
|
+
|
|
24
|
+
herp bar derp
|
|
25
|
+
:param text src: Source directory.
|
|
26
|
+
:param text dest: Destination directory.
|
|
27
|
+
:param dict fmt_vars: Vars to format into the files.
|
|
28
|
+
"""
|
|
29
|
+
assert os.path.exists(src)
|
|
30
|
+
assert os.path.exists(dest)
|
|
31
|
+
# Only at the root. Could be made more complicated and recursive later
|
|
32
|
+
for filename in os.listdir(src):
|
|
33
|
+
# Flat directory structure
|
|
34
|
+
if not os.path.isfile(os.path.join(src, filename)):
|
|
35
|
+
continue
|
|
36
|
+
with open(os.path.join(src, filename)) as f:
|
|
37
|
+
output_contents = f.read().format(**fmt_vars)
|
|
38
|
+
with open(os.path.join(dest, filename), 'w') as file_obj:
|
|
39
|
+
file_obj.write(output_contents)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _commit_version(
|
|
43
|
+
repo: str, *,
|
|
44
|
+
language: str,
|
|
45
|
+
version: str,
|
|
46
|
+
**fmt_vars: str,
|
|
47
|
+
) -> None:
|
|
48
|
+
# 'all' writes the .version and .pre-commit-hooks.yaml files
|
|
49
|
+
files = importlib.resources.files('pre_commit_mirror_maker')
|
|
50
|
+
with importlib.resources.as_file(files) as files_p:
|
|
51
|
+
for lang in ('all', language):
|
|
52
|
+
src = files_p.joinpath(lang)
|
|
53
|
+
format_files(
|
|
54
|
+
src,
|
|
55
|
+
repo,
|
|
56
|
+
language=language,
|
|
57
|
+
version=version,
|
|
58
|
+
**fmt_vars,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
hooks_yaml = os.path.join(repo, 'hooks.yaml')
|
|
62
|
+
if os.path.exists(hooks_yaml):
|
|
63
|
+
os.remove(hooks_yaml)
|
|
64
|
+
|
|
65
|
+
def git(*cmd: str) -> None:
|
|
66
|
+
subprocess.check_call(('git', '-C', repo) + cmd)
|
|
67
|
+
|
|
68
|
+
# Commit and tag
|
|
69
|
+
git('add', '.')
|
|
70
|
+
git('commit', '-m', f'Mirror: {version}')
|
|
71
|
+
git('tag', f'v{version}')
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def make_repo(repo: str, *, language: str, name: str, **fmt_vars: str) -> None:
|
|
75
|
+
assert os.path.exists(os.path.join(repo, '.git')), repo
|
|
76
|
+
|
|
77
|
+
package_versions = LIST_VERSIONS[language](name)
|
|
78
|
+
version_file = os.path.join(repo, '.version')
|
|
79
|
+
if os.path.exists(version_file):
|
|
80
|
+
previous_version = open(version_file).read().strip()
|
|
81
|
+
previous_version_index = package_versions.index(previous_version)
|
|
82
|
+
versions_to_apply = package_versions[previous_version_index + 1:]
|
|
83
|
+
else:
|
|
84
|
+
versions_to_apply = package_versions
|
|
85
|
+
|
|
86
|
+
for version in versions_to_apply:
|
|
87
|
+
if language in ADDITIONAL_DEPENDENCIES:
|
|
88
|
+
additional_dependencies = ADDITIONAL_DEPENDENCIES[language](
|
|
89
|
+
name,
|
|
90
|
+
version,
|
|
91
|
+
)
|
|
92
|
+
else:
|
|
93
|
+
additional_dependencies = []
|
|
94
|
+
|
|
95
|
+
_commit_version(
|
|
96
|
+
repo,
|
|
97
|
+
name=name,
|
|
98
|
+
language=language,
|
|
99
|
+
version=version,
|
|
100
|
+
additional_dependencies=json.dumps(additional_dependencies),
|
|
101
|
+
**fmt_vars,
|
|
102
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fn main() {{}}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pre_commit_mirror_maker_2
|
|
3
|
+
Version: 1.10.0.1
|
|
4
|
+
Summary: Fork of pre-commit-mirror-maker
|
|
5
|
+
Home-page: https://github.com/GideonBear/pre-commit-mirror-maker-2
|
|
6
|
+
Author: Anthony Sottile
|
|
7
|
+
Author-email: asottile@umich.edu
|
|
8
|
+
License: MIT
|
|
9
|
+
Platform: all
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: packaging
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
[](https://github.com/GideonBear/pre-commit-mirror-maker-2/actions/workflows/main.yml)
|
|
21
|
+
[](https://results.pre-commit.ci/latest/github/GideonBear/pre-commit-mirror-maker-2/main)
|
|
22
|
+
|
|
23
|
+
pre-commit-mirror-maker-2
|
|
24
|
+
=======================
|
|
25
|
+
|
|
26
|
+
Scripts for creating mirror repositories that do not have
|
|
27
|
+
.pre-commit-hooks.yaml
|
|
28
|
+
|
|
29
|
+
This is a fork of [pre-commit-mirror-maker](https://github.com/pre-commit/pre-commit-mirror-maker) to add a few features.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Installation
|
|
33
|
+
|
|
34
|
+
`$ pip install pre-commit-mirror-maker-2`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Sample Usage
|
|
38
|
+
|
|
39
|
+
To see all supported configuration options, run:
|
|
40
|
+
|
|
41
|
+
```console
|
|
42
|
+
$ pre-commit-mirror --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For example: making a mirror of the yapf package:
|
|
46
|
+
|
|
47
|
+
```console
|
|
48
|
+
$ git init mirrors-yapf
|
|
49
|
+
Initialized empty Git repository in /tmp/mirrors-yapf/.git/
|
|
50
|
+
|
|
51
|
+
$ pre-commit-mirror mirrors-yapf --language python --package-name yapf --args=-i --types python
|
|
52
|
+
[main (root-commit) 88bffee] Mirror: 0.1.3
|
|
53
|
+
3 files changed, 16 insertions(+)
|
|
54
|
+
create mode 100644 .pre-commit-hooks.yaml
|
|
55
|
+
create mode 100644 .version
|
|
56
|
+
create mode 100644 setup.py
|
|
57
|
+
[main 24cd5f4] Mirror: 0.1.4
|
|
58
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
59
|
+
[main 6695a76] Mirror: 0.1.5
|
|
60
|
+
|
|
61
|
+
...
|
|
62
|
+
|
|
63
|
+
[main 091ab92] Mirror: 0.22.0
|
|
64
|
+
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
65
|
+
|
|
66
|
+
$ ls -al mirrors-yapf/
|
|
67
|
+
total 24
|
|
68
|
+
drwxrwxr-x 3 asottile asottile 4096 May 26 10:00 .
|
|
69
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 ..
|
|
70
|
+
drwxrwxr-x 8 asottile asottile 4096 May 26 10:00 .git
|
|
71
|
+
-rw-rw-r-- 1 asottile asottile 136 May 26 10:00 .pre-commit-hooks.yaml
|
|
72
|
+
-rw-rw-r-- 1 asottile asottile 137 May 26 10:00 setup.py
|
|
73
|
+
-rw-rw-r-- 1 asottile asottile 7 May 26 10:00 .version
|
|
74
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
setup.cfg
|
|
4
|
+
setup.py
|
|
5
|
+
pre_commit_mirror_maker/__init__.py
|
|
6
|
+
pre_commit_mirror_maker/languages.py
|
|
7
|
+
pre_commit_mirror_maker/main.py
|
|
8
|
+
pre_commit_mirror_maker/make_repo.py
|
|
9
|
+
pre_commit_mirror_maker/all/.pre-commit-hooks.yaml
|
|
10
|
+
pre_commit_mirror_maker/all/.version
|
|
11
|
+
pre_commit_mirror_maker/node/.npmignore
|
|
12
|
+
pre_commit_mirror_maker/node/package.json
|
|
13
|
+
pre_commit_mirror_maker/python/setup.py
|
|
14
|
+
pre_commit_mirror_maker/ruby/pre_commit_fake_gem.gemspec
|
|
15
|
+
pre_commit_mirror_maker/rust/Cargo.toml
|
|
16
|
+
pre_commit_mirror_maker/rust/main.rs
|
|
17
|
+
pre_commit_mirror_maker_2.egg-info/PKG-INFO
|
|
18
|
+
pre_commit_mirror_maker_2.egg-info/SOURCES.txt
|
|
19
|
+
pre_commit_mirror_maker_2.egg-info/dependency_links.txt
|
|
20
|
+
pre_commit_mirror_maker_2.egg-info/entry_points.txt
|
|
21
|
+
pre_commit_mirror_maker_2.egg-info/requires.txt
|
|
22
|
+
pre_commit_mirror_maker_2.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
packaging
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pre_commit_mirror_maker
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
name = pre_commit_mirror_maker_2
|
|
3
|
+
version = 1.10.0.1
|
|
4
|
+
description = Fork of pre-commit-mirror-maker
|
|
5
|
+
long_description = file: README.md
|
|
6
|
+
long_description_content_type = text/markdown
|
|
7
|
+
url = https://github.com/GideonBear/pre-commit-mirror-maker-2
|
|
8
|
+
author = Anthony Sottile
|
|
9
|
+
author_email = asottile@umich.edu
|
|
10
|
+
license = MIT
|
|
11
|
+
license_files = LICENSE
|
|
12
|
+
platforms = all
|
|
13
|
+
classifiers =
|
|
14
|
+
Programming Language :: Python :: 3
|
|
15
|
+
Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Programming Language :: Python :: Implementation :: CPython
|
|
17
|
+
Programming Language :: Python :: Implementation :: PyPy
|
|
18
|
+
|
|
19
|
+
[options]
|
|
20
|
+
packages = find:
|
|
21
|
+
install_requires =
|
|
22
|
+
packaging
|
|
23
|
+
python_requires = >=3.10
|
|
24
|
+
|
|
25
|
+
[options.packages.find]
|
|
26
|
+
exclude =
|
|
27
|
+
tests*
|
|
28
|
+
testing*
|
|
29
|
+
|
|
30
|
+
[options.entry_points]
|
|
31
|
+
console_scripts =
|
|
32
|
+
pre-commit-mirror = pre_commit_mirror_maker.main:main
|
|
33
|
+
|
|
34
|
+
[options.package_data]
|
|
35
|
+
pre_commit_mirror_maker =
|
|
36
|
+
all/.pre-commit-hooks.yaml
|
|
37
|
+
all/.version
|
|
38
|
+
node/.npmignore
|
|
39
|
+
node/*
|
|
40
|
+
python/*
|
|
41
|
+
ruby/*
|
|
42
|
+
rust/*
|
|
43
|
+
|
|
44
|
+
[bdist_wheel]
|
|
45
|
+
universal = True
|
|
46
|
+
|
|
47
|
+
[coverage:run]
|
|
48
|
+
plugins = covdefaults
|
|
49
|
+
|
|
50
|
+
[mypy]
|
|
51
|
+
check_untyped_defs = true
|
|
52
|
+
disallow_any_generics = true
|
|
53
|
+
disallow_incomplete_defs = true
|
|
54
|
+
disallow_untyped_defs = true
|
|
55
|
+
warn_redundant_casts = true
|
|
56
|
+
warn_unused_ignores = true
|
|
57
|
+
|
|
58
|
+
[mypy-testing.*]
|
|
59
|
+
disallow_untyped_defs = false
|
|
60
|
+
|
|
61
|
+
[mypy-tests.*]
|
|
62
|
+
disallow_untyped_defs = false
|
|
63
|
+
|
|
64
|
+
[egg_info]
|
|
65
|
+
tag_build =
|
|
66
|
+
tag_date = 0
|
|
67
|
+
|