mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Use asottile/add-trailing-comma
This commit is contained in:
@@ -21,3 +21,7 @@
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
language_version: python2.7
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
sha: v0.3.0
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
|
||||
@@ -20,18 +20,18 @@ def bool_errcheck(result, func, args):
|
||||
|
||||
GetStdHandle = WINFUNCTYPE(HANDLE, DWORD)(
|
||||
("GetStdHandle", windll.kernel32),
|
||||
((1, "nStdHandle"), )
|
||||
((1, "nStdHandle"), ),
|
||||
)
|
||||
|
||||
GetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, POINTER(DWORD))(
|
||||
("GetConsoleMode", windll.kernel32),
|
||||
((1, "hConsoleHandle"), (2, "lpMode"))
|
||||
((1, "hConsoleHandle"), (2, "lpMode")),
|
||||
)
|
||||
GetConsoleMode.errcheck = bool_errcheck
|
||||
|
||||
SetConsoleMode = WINFUNCTYPE(BOOL, HANDLE, DWORD)(
|
||||
("SetConsoleMode", windll.kernel32),
|
||||
((1, "hConsoleHandle"), (1, "dwMode"))
|
||||
((1, "hConsoleHandle"), (1, "dwMode")),
|
||||
)
|
||||
SetConsoleMode.errcheck = bool_errcheck
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def _update_repo(repo_config, runner, tags_only):
|
||||
if hooks_missing:
|
||||
raise RepositoryCannotBeUpdatedError(
|
||||
'Cannot update because the tip of master is missing these hooks:\n'
|
||||
'{}'.format(', '.join(sorted(hooks_missing)))
|
||||
'{}'.format(', '.join(sorted(hooks_missing))),
|
||||
)
|
||||
|
||||
return new_config
|
||||
|
||||
@@ -51,7 +51,7 @@ def install(
|
||||
'Running in migration mode with existing hooks at {}\n'
|
||||
'Use -f to use only pre-commit.'.format(
|
||||
legacy_path,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
with io.open(hook_path, 'w') as pre_commit_file_obj:
|
||||
|
||||
@@ -235,7 +235,7 @@ def run(runner, args, environ=os.environ):
|
||||
logger.error(
|
||||
'Your .pre-commit-config.yaml is unstaged.\n'
|
||||
'`git add .pre-commit-config.yaml` to fix this.\n'
|
||||
'Run pre-commit with --allow-unstaged-config to silence this.'
|
||||
'Run pre-commit with --allow-unstaged-config to silence this.',
|
||||
)
|
||||
return 1
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def get_root():
|
||||
except CalledProcessError:
|
||||
raise FatalError(
|
||||
'git failed. Is it installed, and are you in a Git repository '
|
||||
'directory?'
|
||||
'directory?',
|
||||
)
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ def get_staged_files():
|
||||
return cmd_output(
|
||||
'git', 'diff', '--staged', '--name-only', '--no-ext-diff',
|
||||
# Everything except for D
|
||||
'--diff-filter=ACMRTUXB'
|
||||
'--diff-filter=ACMRTUXB',
|
||||
)[1].splitlines()
|
||||
|
||||
|
||||
@@ -130,5 +130,5 @@ def check_for_cygwin_mismatch():
|
||||
' - git {}\n'.format(
|
||||
exe_type[is_cygwin_python],
|
||||
exe_type[is_cygwin_git],
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ def md5(s): # pragma: windows no cover
|
||||
|
||||
def docker_tag(repo_cmd_runner): # pragma: windows no cover
|
||||
return 'pre-commit-{}'.format(
|
||||
md5(os.path.basename(repo_cmd_runner.path()))
|
||||
md5(os.path.basename(repo_cmd_runner.path())),
|
||||
).lower()
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ def run_hook(repo_cmd_runner, hook, file_args): # pragma: windows no cover
|
||||
'-v', '{}:/src:rw'.format(os.getcwd()),
|
||||
'--workdir', '/src',
|
||||
'--entrypoint', entry_executable,
|
||||
docker_tag(repo_cmd_runner)
|
||||
docker_tag(repo_cmd_runner),
|
||||
) + cmd_rest
|
||||
|
||||
return xargs(cmd, file_args)
|
||||
|
||||
@@ -107,7 +107,7 @@ def install_environment(repo_cmd_runner, version, additional_dependencies):
|
||||
with clean_path_on_failure(repo_cmd_runner.path(directory)):
|
||||
venv_cmd = [
|
||||
sys.executable, '-m', 'virtualenv',
|
||||
'{{prefix}}{}'.format(directory)
|
||||
'{{prefix}}{}'.format(directory),
|
||||
]
|
||||
if version != 'default':
|
||||
venv_cmd.extend(['-p', norm_version(version)])
|
||||
|
||||
@@ -81,7 +81,7 @@ def _install_rbenv(
|
||||
# directory
|
||||
"export GEM_HOME='{directory}/gems'\n"
|
||||
'export PATH="$GEM_HOME/bin:$PATH"\n'
|
||||
'\n'.format(directory=repo_cmd_runner.path(directory))
|
||||
'\n'.format(directory=repo_cmd_runner.path(directory)),
|
||||
)
|
||||
|
||||
# If we aren't using the system ruby, add a version here
|
||||
|
||||
@@ -30,7 +30,7 @@ class LoggingHandler(logging.Handler):
|
||||
self.use_color,
|
||||
) + ' ',
|
||||
record.getMessage(),
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ def _add_color_option(parser):
|
||||
def _add_config_option(parser):
|
||||
parser.add_argument(
|
||||
'-c', '--config', default='.pre-commit-config.yaml',
|
||||
help='Path to alternate config file'
|
||||
help='Path to alternate config file',
|
||||
)
|
||||
|
||||
|
||||
@@ -228,11 +228,11 @@ def main(argv=None):
|
||||
return sample_config()
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
'Command {} not implemented.'.format(args.command)
|
||||
'Command {} not implemented.'.format(args.command),
|
||||
)
|
||||
|
||||
raise AssertionError(
|
||||
'Command {} failed to exit with a returncode'.format(args.command)
|
||||
'Command {} failed to exit with a returncode'.format(args.command),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ REPOS = (
|
||||
|
||||
|
||||
RESOURCES_DIR = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), 'resources')
|
||||
os.path.join(os.path.dirname(__file__), 'resources'),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class Manifest(object):
|
||||
'If `pre-commit autoupdate` does not silence this warning '
|
||||
'consider making an issue / pull request.'.format(
|
||||
self.repo_url, C.MANIFEST_FILE_LEGACY, C.MANIFEST_FILE,
|
||||
)
|
||||
),
|
||||
)
|
||||
return load_manifest(legacy_path)
|
||||
else:
|
||||
|
||||
@@ -50,7 +50,7 @@ def get_hook_message(
|
||||
raise ValueError('Expected one of (`end_msg`, `end_len`)')
|
||||
if end_msg is not None and (end_color is None or use_color is None):
|
||||
raise ValueError(
|
||||
'`end_color` and `use_color` are required with `end_msg`'
|
||||
'`end_color` and `use_color` are required with `end_msg`',
|
||||
)
|
||||
|
||||
if end_len:
|
||||
|
||||
@@ -20,7 +20,7 @@ class PrefixedCommandRunner(object):
|
||||
self,
|
||||
prefix_dir,
|
||||
popen=subprocess.Popen,
|
||||
makedirs=os.makedirs
|
||||
makedirs=os.makedirs,
|
||||
):
|
||||
self.prefix_dir = prefix_dir.rstrip(os.sep) + os.sep
|
||||
self.__popen = popen
|
||||
|
||||
@@ -72,7 +72,7 @@ def _install_all(venvs, repo_url):
|
||||
|
||||
if need_installed:
|
||||
logger.info(
|
||||
'Installing environment for {}.'.format(repo_url)
|
||||
'Installing environment for {}.'.format(repo_url),
|
||||
)
|
||||
logger.info('Once installed this environment will be reused.')
|
||||
logger.info('This may take a few minutes...')
|
||||
@@ -102,7 +102,7 @@ def _validate_minimum_version(hook):
|
||||
'version {} is installed. '
|
||||
'Perhaps run `pip install --upgrade pre-commit`.'.format(
|
||||
hook['id'], hook_version, C.VERSION_PARSED,
|
||||
)
|
||||
),
|
||||
)
|
||||
exit(1)
|
||||
return hook
|
||||
@@ -147,7 +147,7 @@ class Repository(object):
|
||||
'Typo? Perhaps it is introduced in a newer version? '
|
||||
'Often `pre-commit autoupdate` fixes this.'.format(
|
||||
hook['id'], self.repo_config['repo'],
|
||||
)
|
||||
),
|
||||
)
|
||||
exit(1)
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ def _check_conditional(self, dct):
|
||||
cond_key=self.condition_key,
|
||||
op=op,
|
||||
cond_val=cond_val,
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def staged_files_only(cmd_runner):
|
||||
except CalledProcessError:
|
||||
logger.warning(
|
||||
'Stashed changes conflicted with hook auto-fixes... '
|
||||
'Rolling back fixes...'
|
||||
'Rolling back fixes...',
|
||||
)
|
||||
# We failed to apply the patch, presumably due to fixes made
|
||||
# by hooks.
|
||||
|
||||
@@ -49,7 +49,7 @@ class Store(object):
|
||||
with io.open(os.path.join(self.directory, 'README'), 'w') as readme:
|
||||
readme.write(
|
||||
'This directory is maintained by the pre-commit project.\n'
|
||||
'Learn more: https://github.com/pre-commit/pre-commit\n'
|
||||
'Learn more: https://github.com/pre-commit/pre-commit\n',
|
||||
)
|
||||
|
||||
def _write_sqlite_db(self):
|
||||
@@ -68,7 +68,7 @@ class Store(object):
|
||||
' ref CHAR(255) NOT NULL,'
|
||||
' path CHAR(255) NOT NULL,'
|
||||
' PRIMARY KEY (repo, ref)'
|
||||
');'
|
||||
');',
|
||||
)
|
||||
|
||||
# Atomic file move
|
||||
|
||||
@@ -124,7 +124,7 @@ class CalledProcessError(RuntimeError):
|
||||
if maybe_text:
|
||||
output.append(
|
||||
b'\n ' +
|
||||
five.to_bytes(maybe_text).replace(b'\n', b'\n ')
|
||||
five.to_bytes(maybe_text).replace(b'\n', b'\n '),
|
||||
)
|
||||
else:
|
||||
output.append(b'(none)')
|
||||
@@ -134,8 +134,8 @@ class CalledProcessError(RuntimeError):
|
||||
'Command: {!r}\n'
|
||||
'Return code: {}\n'
|
||||
'Expected return code: {}\n'.format(
|
||||
self.cmd, self.returncode, self.expected_returncode
|
||||
)
|
||||
self.cmd, self.returncode, self.expected_returncode,
|
||||
),
|
||||
),
|
||||
b'Output: ', output[0], b'\n',
|
||||
b'Errors: ', output[1], b'\n',
|
||||
|
||||
@@ -75,7 +75,7 @@ def config_with_local_hooks():
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))])
|
||||
))]),
|
||||
))
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def cmd_output_mocked_pre_commit_home(*args, **kwargs):
|
||||
|
||||
skipif_cant_run_docker = pytest.mark.skipif(
|
||||
docker_is_running() is False,
|
||||
reason='Docker isn\'t running or can\'t be accessed'
|
||||
reason='Docker isn\'t running or can\'t be accessed',
|
||||
)
|
||||
|
||||
skipif_slowtests_false = pytest.mark.skipif(
|
||||
@@ -44,7 +44,7 @@ skipif_slowtests_false = pytest.mark.skipif(
|
||||
|
||||
skipif_cant_run_swift = pytest.mark.skipif(
|
||||
parse_shebang.find_executable('swift') is None,
|
||||
reason='swift isn\'t installed or can\'t be found'
|
||||
reason='swift isn\'t installed or can\'t be found',
|
||||
)
|
||||
|
||||
xfailif_windows_no_ruby = pytest.mark.xfail(
|
||||
|
||||
@@ -208,7 +208,7 @@ def test_validate_manifest_main(args, expected_output):
|
||||
}],
|
||||
True,
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_valid_manifests(manifest_obj, expected):
|
||||
ret = is_valid_according_to_schema(manifest_obj, MANIFEST_SCHEMA)
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_out_of_date_repo(out_of_date_repo, runner_with_mocked_store):
|
||||
|
||||
|
||||
def test_autoupdate_out_of_date_repo(
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
# Write out the config
|
||||
config = make_config_from_repo(
|
||||
@@ -181,7 +181,7 @@ def hook_disappearing_repo(tempdir_factory):
|
||||
|
||||
|
||||
def test_hook_disppearing_repo_raises(
|
||||
hook_disappearing_repo, runner_with_mocked_store
|
||||
hook_disappearing_repo, runner_with_mocked_store,
|
||||
):
|
||||
config = make_config_from_repo(
|
||||
hook_disappearing_repo.path,
|
||||
@@ -193,7 +193,7 @@ def test_hook_disppearing_repo_raises(
|
||||
|
||||
|
||||
def test_autoupdate_hook_disappearing_repo(
|
||||
hook_disappearing_repo, in_tmpdir, mock_out_store_directory
|
||||
hook_disappearing_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
config = make_config_from_repo(
|
||||
hook_disappearing_repo.path,
|
||||
@@ -222,7 +222,7 @@ def test_autoupdate_local_hooks(tempdir_factory):
|
||||
|
||||
|
||||
def test_autoupdate_local_hooks_with_out_of_date_repo(
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
stale_config = make_config_from_repo(
|
||||
out_of_date_repo.path, sha=out_of_date_repo.original_sha, check=False,
|
||||
|
||||
@@ -145,7 +145,7 @@ NORMAL_PRE_COMMIT_RUN = re.compile(
|
||||
r'Bash hook\.+Passed\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 foo\r?\n$'
|
||||
r' create mode 100644 foo\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ FAILING_PRE_COMMIT_RUN = re.compile(
|
||||
r'\r?\n'
|
||||
r'Fail\r?\n'
|
||||
r'foo\r?\n'
|
||||
r'\r?\n$'
|
||||
r'\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ EXISTING_COMMIT_RUN = re.compile(
|
||||
r'^legacy hook\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 baz\r?\n$'
|
||||
r' create mode 100644 baz\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory):
|
||||
FAIL_OLD_HOOK = re.compile(
|
||||
r'fail!\r?\n'
|
||||
r'\[INFO\] Initializing environment for .+\.\r?\n'
|
||||
r'Bash hook\.+Passed\r?\n'
|
||||
r'Bash hook\.+Passed\r?\n',
|
||||
)
|
||||
|
||||
|
||||
@@ -448,7 +448,7 @@ PRE_INSTALLED = re.compile(
|
||||
r'Bash hook\.+Passed\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 foo\r?\n$'
|
||||
r' create mode 100644 foo\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ def test_show_diff_on_failure(
|
||||
True,
|
||||
),
|
||||
({}, (b'Bash hook', b'(no files to check)', b'Skipped'), 0, False),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_run(
|
||||
cap_out,
|
||||
@@ -259,7 +259,7 @@ def test_run_output_logfile(
|
||||
git_path, {},
|
||||
expected_output,
|
||||
expected_ret=1,
|
||||
stage=True
|
||||
stage=True,
|
||||
)
|
||||
logfile_path = os.path.join(git_path, 'test.log')
|
||||
assert os.path.exists(logfile_path)
|
||||
@@ -301,7 +301,7 @@ def test_always_run_alt_config(
|
||||
(b'Bash hook', b'Passed'),
|
||||
0,
|
||||
stage=False,
|
||||
config_file=alt_config_file
|
||||
config_file=alt_config_file,
|
||||
)
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ def test_always_run_alt_config(
|
||||
('master', 'master', False),
|
||||
('master', '', True),
|
||||
('', 'master', True),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_origin_source_error_msg(
|
||||
repo_with_passing_hook, origin, source, expect_failure,
|
||||
@@ -588,7 +588,7 @@ def test_lots_of_files(mock_out_store_directory, tempdir_factory):
|
||||
('commit', [], ['commit'], [b'hook 1', b'hook 2']),
|
||||
('commit', ['push'], ['commit'], [b'', b'hook 2']),
|
||||
('commit', ['commit'], ['push'], [b'hook 1', b'']),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_local_hook_for_stages(
|
||||
cap_out,
|
||||
@@ -606,15 +606,15 @@ def test_local_hook_for_stages(
|
||||
('entry', 'python -m flake8.__main__'),
|
||||
('language', 'system'),
|
||||
('files', r'\.py$'),
|
||||
('stages', stage_for_first_hook)
|
||||
('stages', stage_for_first_hook),
|
||||
)), OrderedDict((
|
||||
('id', 'do_not_commit'),
|
||||
('name', 'hook 2'),
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
('stages', stage_for_second_hook)
|
||||
))))
|
||||
('stages', stage_for_second_hook),
|
||||
)))),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
@@ -628,7 +628,7 @@ def test_local_hook_for_stages(
|
||||
{'hook_stage': hook_stage},
|
||||
expected_outputs=expected_output,
|
||||
expected_ret=0,
|
||||
stage=False
|
||||
stage=False,
|
||||
)
|
||||
|
||||
|
||||
@@ -649,7 +649,7 @@ def test_local_hook_passes(
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
@@ -678,7 +678,7 @@ def test_local_hook_fails(
|
||||
('entry', 'sh -c "! grep -iI todo $@" --'),
|
||||
('language', 'system'),
|
||||
('files', ''),
|
||||
))])
|
||||
))]),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
@@ -770,7 +770,7 @@ def test_files_running_subdir(
|
||||
(False, [], b''),
|
||||
(True, ['some', 'args'], b'some args foo.py'),
|
||||
(False, ['some', 'args'], b'some args'),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_pass_filenames(
|
||||
cap_out, repo_with_passing_hook, mock_out_store_directory,
|
||||
|
||||
@@ -10,6 +10,6 @@ from pre_commit.util import CalledProcessError
|
||||
def test_docker_is_running_process_error():
|
||||
with mock.patch(
|
||||
'pre_commit.languages.docker.cmd_output',
|
||||
side_effect=CalledProcessError(*(None,) * 4)
|
||||
side_effect=CalledProcessError(*(None,) * 4),
|
||||
):
|
||||
assert docker.docker_is_running() is False
|
||||
|
||||
@@ -31,7 +31,7 @@ def test_CalledProcessError_str():
|
||||
|
||||
def test_CalledProcessError_str_nooutput():
|
||||
error = CalledProcessError(
|
||||
1, [str('git'), str('status')], 0, (str(''), str(''))
|
||||
1, [str('git'), str('status')], 0, (str(''), str('')),
|
||||
)
|
||||
assert str(error) == (
|
||||
"Command: ['git', 'status']\n"
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_python_hook(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n"
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_python_hook_args_with_spaces(tempdir_factory, store):
|
||||
'hooks': [{
|
||||
'id': 'foo',
|
||||
'args': ['i have spaces', 'and"\'quotes', '$and !this'],
|
||||
}]
|
||||
}],
|
||||
},
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_python_hook_weird_setup_cfg(tempdir_factory, store):
|
||||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n"
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ def test_run_a_failing_docker_hook(tempdir_factory, store):
|
||||
tempdir_factory, store, 'docker_hooks_repo',
|
||||
'docker-hook-failing',
|
||||
['Hello World from docker'], b'',
|
||||
expected_return_code=1
|
||||
expected_return_code=1,
|
||||
)
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ def test_run_ruby_hook_with_disable_shared_gems(
|
||||
tmpdir.join('.bundle').mkdir()
|
||||
tmpdir.join('.bundle', 'config').write(
|
||||
'BUNDLE_DISABLE_SHARED_GEMS: true\n'
|
||||
'BUNDLE_PATH: vendor/gem\n'
|
||||
'BUNDLE_PATH: vendor/gem\n',
|
||||
)
|
||||
with cwd(tmpdir.strpath):
|
||||
_test_hook_repo(
|
||||
@@ -322,7 +322,7 @@ def test_run_hook_with_curly_braced_arguments(tempdir_factory, store):
|
||||
'hooks': [{
|
||||
'id': 'arg-per-line',
|
||||
'args': ['hi {1}', "I'm {a} problem"],
|
||||
}]
|
||||
}],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ def test_local_hooks(tempdir_factory, mock_out_store_directory):
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
git_path = git_dir(tempdir_factory)
|
||||
add_config_to_repo(git_path, config)
|
||||
@@ -101,7 +101,7 @@ def test_local_hooks_alt_config(tempdir_factory, mock_out_store_directory):
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
git_path = git_dir(tempdir_factory)
|
||||
alt_config_file = 'alternate_config.yaml'
|
||||
|
||||
@@ -366,7 +366,7 @@ def test_load_from_filename_fails_load_strategy(tmpdir):
|
||||
_assert_exception_trace(
|
||||
excinfo.value.args[0],
|
||||
# ANY is json's error message
|
||||
('File {}'.format(f.strpath), mock.ANY)
|
||||
('File {}'.format(f.strpath), mock.ANY),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def test_get_default_directory_defaults_to_home():
|
||||
|
||||
def test_uses_environment_variable_when_present():
|
||||
with mock.patch.dict(
|
||||
os.environ, {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'}
|
||||
os.environ, {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'},
|
||||
):
|
||||
ret = _get_default_directory()
|
||||
assert ret == '/tmp/pre_commit_home'
|
||||
@@ -89,7 +89,7 @@ def test_clone(store, tempdir_factory, log_info_mock):
|
||||
ret = store.clone(path, sha)
|
||||
# Should have printed some stuff
|
||||
assert log_info_mock.call_args_list[0][0][0].startswith(
|
||||
'Initializing environment for '
|
||||
'Initializing environment for ',
|
||||
)
|
||||
|
||||
# Should return a directory inside of the store
|
||||
@@ -138,7 +138,7 @@ def test_clone_when_repo_already_exists(store):
|
||||
with sqlite3.connect(store.db_path) as db:
|
||||
db.execute(
|
||||
'INSERT INTO repos (repo, ref, path) '
|
||||
'VALUES ("fake_repo", "fake_ref", "fake_path")'
|
||||
'VALUES ("fake_repo", "fake_ref", "fake_path")',
|
||||
)
|
||||
|
||||
assert store.clone('fake_repo', 'fake_ref') == 'fake_path'
|
||||
|
||||
Reference in New Issue
Block a user