mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Don't fail if GPG signing is configured by default. All references.
This commit is contained in:
parent
7afb2944b2
commit
28c97a95cd
10 changed files with 60 additions and 50 deletions
|
|
@ -18,6 +18,7 @@ from pre_commit.clientlib import CONFIG_SCHEMA
|
|||
from pre_commit.clientlib import load_manifest
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.util import get_resource_path
|
||||
from testing.util import git_commit
|
||||
|
||||
|
||||
def copy_tree_to_path(src_dir, dest_dir):
|
||||
|
|
@ -48,7 +49,7 @@ def make_repo(tempdir_factory, repo_source):
|
|||
path = git_dir(tempdir_factory)
|
||||
copy_tree_to_path(get_resource_path(repo_source), path)
|
||||
cmd_output('git', 'add', '.', cwd=path)
|
||||
cmd_output('git', 'commit', '--no-gpg-sign', '-m', 'Add hooks', cwd=path)
|
||||
git_commit('Add hooks', cwd=path)
|
||||
return path
|
||||
|
||||
|
||||
|
|
@ -63,11 +64,7 @@ def modify_manifest(path):
|
|||
yield manifest
|
||||
with io.open(manifest_path, 'w') as manifest_file:
|
||||
manifest_file.write(ordered_dump(manifest, **C.YAML_DUMP_KWARGS))
|
||||
cmd_output(
|
||||
'git', 'commit', '--no-gpg-sign', '-am',
|
||||
'update {}'.format(C.MANIFEST_FILE),
|
||||
cwd=path,
|
||||
)
|
||||
git_commit('update {}'.format(C.MANIFEST_FILE), cwd=path)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
|
@ -82,9 +79,7 @@ def modify_config(path='.', commit=True):
|
|||
with io.open(config_path, 'w', encoding='UTF-8') as config_file:
|
||||
config_file.write(ordered_dump(config, **C.YAML_DUMP_KWARGS))
|
||||
if commit:
|
||||
cmd_output(
|
||||
'git', 'commit', '--no-gpg-sign', '-am', 'update config', cwd=path,
|
||||
)
|
||||
git_commit('update config', cwd=path)
|
||||
|
||||
|
||||
def config_with_local_hooks():
|
||||
|
|
@ -140,19 +135,13 @@ def write_config(directory, config, config_file=C.CONFIG_FILE):
|
|||
def add_config_to_repo(git_path, config, config_file=C.CONFIG_FILE):
|
||||
write_config(git_path, config, config_file=config_file)
|
||||
cmd_output('git', 'add', config_file, cwd=git_path)
|
||||
cmd_output(
|
||||
'git', 'commit', '--no-gpg-sign', '-m', 'Add hooks config',
|
||||
cwd=git_path,
|
||||
)
|
||||
git_commit('Add hooks config', cwd=git_path)
|
||||
return git_path
|
||||
|
||||
|
||||
def remove_config_from_repo(git_path, config_file=C.CONFIG_FILE):
|
||||
cmd_output('git', 'rm', config_file, cwd=git_path)
|
||||
cmd_output(
|
||||
'git', 'commit', '--no-gpg-sign', '-m', 'Remove hooks config',
|
||||
cwd=git_path,
|
||||
)
|
||||
git_commit('Remove hooks config', cwd=git_path)
|
||||
return git_path
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -133,3 +133,18 @@ def cwd(path):
|
|||
yield
|
||||
finally:
|
||||
os.chdir(original_cwd)
|
||||
|
||||
|
||||
def git_commit(msg, *_args, **kwargs):
|
||||
args = ['git']
|
||||
config = kwargs.pop('config', None)
|
||||
if config is not None:
|
||||
args.extend(['-C', config])
|
||||
args.append('commit')
|
||||
if msg is not None:
|
||||
args.extend(['-m', msg])
|
||||
if '--allow-empty' not in _args:
|
||||
args.append('--allow-empty')
|
||||
if '--no-gpg-sign' not in _args:
|
||||
args.append('--no-gpg-sign')
|
||||
return cmd_output(*(tuple(args) + tuple(_args)), **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue