Limit repository creation to one process

This commit is contained in:
Anthony Sottile
2017-08-23 17:24:49 -07:00
parent bba711f468
commit 625aaf54aa
6 changed files with 133 additions and 46 deletions

View File

@@ -142,7 +142,8 @@ FILES_CHANGED = (
NORMAL_PRE_COMMIT_RUN = re.compile(
r'^\[INFO\] Initializing environment for .+\.\r?\n'
r'^\[INFO\] Locking pre-commit directory\r?\n'
r'\[INFO\] Initializing environment for .+\.\r?\n'
r'Bash hook\.+Passed\r?\n'
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
FILES_CHANGED +
@@ -254,7 +255,8 @@ def test_environment_not_sourced(tempdir_factory):
FAILING_PRE_COMMIT_RUN = re.compile(
r'^\[INFO\] Initializing environment for .+\.\r?\n'
r'^\[INFO\] Locking pre-commit directory\r?\n'
r'\[INFO\] Initializing environment for .+\.\r?\n'
r'Failing hook\.+Failed\r?\n'
r'hookid: failing_hook\r?\n'
r'\r?\n'
@@ -332,6 +334,7 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory):
FAIL_OLD_HOOK = re.compile(
r'fail!\r?\n'
r'\[INFO\] Locking pre-commit directory\r?\n'
r'\[INFO\] Initializing environment for .+\.\r?\n'
r'Bash hook\.+Passed\r?\n',
)

View File

@@ -547,8 +547,8 @@ def test_reinstall(tempdir_factory, store, log_info_mock):
config = make_config_from_repo(path)
repo = Repository.create(config, store)
repo.require_installed()
# We print some logging during clone (1) + install (3)
assert log_info_mock.call_count == 4
# We print some logging during clone (2) + install (4)
assert log_info_mock.call_count == 6
log_info_mock.reset_mock()
# Reinstall with same repo should not trigger another install
repo.require_installed()

View File

@@ -88,7 +88,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(
assert log_info_mock.call_args_list[1][0][0].startswith(
'Initializing environment for ',
)