def test_it_updates(file_config): assert not main(('--config-file', str(file_config.cfg))) # Recloning should end up with an updated revision subprocess.check_call(( 'git', '-C', file_config.dir1, 'commit', '--allow-empty', '-m', 'foo', )) new_rev = revparse(file_config.dir1) assert new_rev != file_config.rev1 assert not main(('--config-file', str(file_config.cfg))) assert revparse(file_config.output_dir.join('repo1')) == new_rev
def test_it_clones(file_config): assert not main(('--config-file', str(file_config.cfg))) assert file_config.output_dir.isdir() expected = {'repo1': str(file_config.dir1), 'repo2': str(file_config.dir2)} repos = json.loads(file_config.output_dir.join('repos.json').read()) assert repos == expected repos_filtered = file_config.output_dir.join('repos_filtered.json') repos_filtered = json.loads(repos_filtered.read()) assert repos_filtered == expected assert file_config.output_dir.join('repo1').isdir() assert revparse(file_config.output_dir.join('repo1')) == file_config.rev1 assert file_config.output_dir.join('repo2').isdir() assert revparse(file_config.output_dir.join('repo2')) == file_config.rev2
def autoupdatable(tmpdir): hook_repo = tmpdir.join('hook_repo') init_repo(hook_repo) hook_repo.join('.pre-commit-hooks.yaml').write( '- id: hook\n' ' name: Hook\n' ' entry: echo hi\n' ' language: system\n' ' types: [file]\n', ) subprocess.check_call(('git', '-C', hook_repo, 'add', '.')) subprocess.check_call(( 'git', '-C', hook_repo, 'commit', '-m', 'add hook', )) rev = revparse(hook_repo) subprocess.check_call(('git', '-C', hook_repo, 'tag', 'v1')) consuming_repo = tmpdir.join('consuming') init_repo(consuming_repo) consuming_repo.join('.pre-commit-config.yaml').write( f'- repo: {hook_repo}\n' f' rev: {rev}\n' f' hooks:\n' f' - id: hook\n', ) subprocess.check_call(('git', '-C', consuming_repo, 'add', '.')) subprocess.check_call(( 'git', '-C', consuming_repo, 'commit', '-m', 'consume hook', )) update_repo = tmpdir.join('update_repo') subprocess.check_call(('git', 'clone', consuming_repo, update_repo)) return auto_namedtuple( hook_repo=hook_repo, hook_repo_rev=rev, consuming_repo=consuming_repo, update_repo=update_repo, )