mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
Run pre-commit autoupdate
Committed via https://github.com/asottile/all-repos
This commit is contained in:
parent
06d01c8c9d
commit
dc28922ccb
11 changed files with 125 additions and 101 deletions
|
|
@ -84,9 +84,11 @@ def _write_new_config_file(path, output):
|
|||
new_contents = ordered_dump(output, **C.YAML_DUMP_KWARGS)
|
||||
|
||||
lines = original_contents.splitlines(True)
|
||||
rev_line_indices_reversed = list(reversed([
|
||||
i for i, line in enumerate(lines) if REV_LINE_RE.match(line)
|
||||
]))
|
||||
rev_line_indices_reversed = list(
|
||||
reversed([
|
||||
i for i, line in enumerate(lines) if REV_LINE_RE.match(line)
|
||||
]),
|
||||
)
|
||||
|
||||
for line in new_contents.splitlines(True):
|
||||
if REV_LINE_RE.match(line):
|
||||
|
|
@ -140,9 +142,11 @@ def autoupdate(config_file, store, tags_only, repos=()):
|
|||
|
||||
if new_repo_config['rev'] != repo_config['rev']:
|
||||
changed = True
|
||||
output.write_line('updating {} -> {}.'.format(
|
||||
repo_config['rev'], new_repo_config['rev'],
|
||||
))
|
||||
output.write_line(
|
||||
'updating {} -> {}.'.format(
|
||||
repo_config['rev'], new_repo_config['rev'],
|
||||
),
|
||||
)
|
||||
output_repos.append(new_repo_config)
|
||||
else:
|
||||
output.write_line('already up to date.')
|
||||
|
|
|
|||
|
|
@ -53,9 +53,7 @@ def shebang():
|
|||
# Homebrew/homebrew-core#35825: be more timid about appropriate `PATH`
|
||||
path_choices = [p for p in os.defpath.split(os.pathsep) if p]
|
||||
exe_choices = [
|
||||
'python{}'.format('.'.join(
|
||||
str(v) for v in sys.version_info[:i]
|
||||
))
|
||||
'python{}'.format('.'.join(str(v) for v in sys.version_info[:i]))
|
||||
for i in range(3)
|
||||
]
|
||||
for path, exe in itertools.product(path_choices, exe_choices):
|
||||
|
|
|
|||
|
|
@ -85,30 +85,36 @@ def _run_single_hook(classifier, hook, args, skips, cols):
|
|||
)
|
||||
|
||||
if hook.id in skips or hook.alias in skips:
|
||||
output.write(get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose),
|
||||
end_msg=SKIPPED,
|
||||
end_color=color.YELLOW,
|
||||
use_color=args.color,
|
||||
cols=cols,
|
||||
))
|
||||
output.write(
|
||||
get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose),
|
||||
end_msg=SKIPPED,
|
||||
end_color=color.YELLOW,
|
||||
use_color=args.color,
|
||||
cols=cols,
|
||||
),
|
||||
)
|
||||
return 0
|
||||
elif not filenames and not hook.always_run:
|
||||
output.write(get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose),
|
||||
postfix=NO_FILES,
|
||||
end_msg=SKIPPED,
|
||||
end_color=color.TURQUOISE,
|
||||
use_color=args.color,
|
||||
cols=cols,
|
||||
))
|
||||
output.write(
|
||||
get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose),
|
||||
postfix=NO_FILES,
|
||||
end_msg=SKIPPED,
|
||||
end_color=color.TURQUOISE,
|
||||
use_color=args.color,
|
||||
cols=cols,
|
||||
),
|
||||
)
|
||||
return 0
|
||||
|
||||
# Print the hook and the dots first in case the hook takes hella long to
|
||||
# run.
|
||||
output.write(get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose), end_len=6, cols=cols,
|
||||
))
|
||||
output.write(
|
||||
get_hook_message(
|
||||
_hook_msg_start(hook, args.verbose), end_len=6, cols=cols,
|
||||
),
|
||||
)
|
||||
sys.stdout.flush()
|
||||
|
||||
diff_before = cmd_output(
|
||||
|
|
|
|||
|
|
@ -84,20 +84,24 @@ def get_conflicted_files():
|
|||
# If they resolved the merge conflict by choosing a mesh of both sides
|
||||
# this will also include the conflicted files
|
||||
tree_hash = cmd_output('git', 'write-tree')[1].strip()
|
||||
merge_diff_filenames = zsplit(cmd_output(
|
||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||
'-m', tree_hash, 'HEAD', 'MERGE_HEAD',
|
||||
)[1])
|
||||
merge_diff_filenames = zsplit(
|
||||
cmd_output(
|
||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||
'-m', tree_hash, 'HEAD', 'MERGE_HEAD',
|
||||
)[1],
|
||||
)
|
||||
return set(merge_conflict_filenames) | set(merge_diff_filenames)
|
||||
|
||||
|
||||
def get_staged_files(cwd=None):
|
||||
return zsplit(cmd_output(
|
||||
'git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z',
|
||||
# Everything except for D
|
||||
'--diff-filter=ACMRTUXB',
|
||||
cwd=cwd,
|
||||
)[1])
|
||||
return zsplit(
|
||||
cmd_output(
|
||||
'git', 'diff', '--staged', '--name-only', '--no-ext-diff', '-z',
|
||||
# Everything except for D
|
||||
'--diff-filter=ACMRTUXB',
|
||||
cwd=cwd,
|
||||
)[1],
|
||||
)
|
||||
|
||||
|
||||
def intent_to_add_files():
|
||||
|
|
@ -119,10 +123,12 @@ def get_all_files():
|
|||
|
||||
|
||||
def get_changed_files(new, old):
|
||||
return zsplit(cmd_output(
|
||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||
'{}...{}'.format(old, new),
|
||||
)[1])
|
||||
return zsplit(
|
||||
cmd_output(
|
||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||
'{}...{}'.format(old, new),
|
||||
)[1],
|
||||
)
|
||||
|
||||
|
||||
def head_rev(remote):
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ def main(argv=None):
|
|||
parser.add_argument('--dest', default='pre_commit/resources')
|
||||
args = parser.parse_args(argv)
|
||||
for archive_name, repo, ref in REPOS:
|
||||
output.write_line('Making {}.tar.gz for {}@{}'.format(
|
||||
archive_name, repo, ref,
|
||||
))
|
||||
output.write_line(
|
||||
'Making {}.tar.gz for {}@{}'.format(archive_name, repo, ref),
|
||||
)
|
||||
make_archive(archive_name, repo, ref, args.dest)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue