Merge pull request #629 from pre-commit/more_realistic_test_clones

Use file:// protocol for cloning under test
This commit is contained in:
Anthony Sottile
2017-09-22 11:04:37 -07:00
committed by GitHub
4 changed files with 7 additions and 3 deletions

View File

@@ -37,8 +37,11 @@ def in_env(repo_cmd_runner):
def guess_go_dir(remote_url):
if remote_url.endswith('.git'):
remote_url = remote_url[:-1 * len('.git')]
looks_like_url = (
not remote_url.startswith('file://') and
('//' in remote_url or '@' in remote_url)
)
remote_url = remote_url.replace(':', '/')
looks_like_url = '//' in remote_url or '@' in remote_url
if looks_like_url:
_, _, remote_url = remote_url.rpartition('//')
_, _, remote_url = remote_url.rpartition('@')

View File

@@ -83,7 +83,7 @@ def config_with_local_hooks():
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
config = OrderedDict((
('repo', repo_path),
('repo', 'file://{}'.format(repo_path)),
('sha', sha or get_head_sha(repo_path)),
(
'hooks',

View File

@@ -10,6 +10,7 @@ from pre_commit.languages.golang import guess_go_dir
('url', 'expected'),
(
('/im/a/path/on/disk', 'unknown_src_dir'),
('file:///im/a/path/on/disk', 'unknown_src_dir'),
('git@github.com:golang/lint', 'github.com/golang/lint'),
('git://github.com/golang/lint', 'github.com/golang/lint'),
('http://github.com/golang/lint', 'github.com/golang/lint'),

View File

@@ -714,7 +714,7 @@ def test_hook_id_not_present(tempdir_factory, store, fake_log_handler):
with pytest.raises(SystemExit):
repo.require_installed()
assert fake_log_handler.handle.call_args[0][0].msg == (
'`i-dont-exist` is not present in repository {}. '
'`i-dont-exist` is not present in repository file://{}. '
'Typo? Perhaps it is introduced in a newer version? '
'Often `pre-commit autoupdate` fixes this.'.format(path)
)