mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #629 from pre-commit/more_realistic_test_clones
Use file:// protocol for cloning under test
This commit is contained in:
commit
3a7806ea30
4 changed files with 7 additions and 3 deletions
|
|
@ -37,8 +37,11 @@ def in_env(repo_cmd_runner):
|
||||||
def guess_go_dir(remote_url):
|
def guess_go_dir(remote_url):
|
||||||
if remote_url.endswith('.git'):
|
if remote_url.endswith('.git'):
|
||||||
remote_url = remote_url[:-1 * len('.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(':', '/')
|
remote_url = remote_url.replace(':', '/')
|
||||||
looks_like_url = '//' in remote_url or '@' in remote_url
|
|
||||||
if looks_like_url:
|
if looks_like_url:
|
||||||
_, _, remote_url = remote_url.rpartition('//')
|
_, _, remote_url = remote_url.rpartition('//')
|
||||||
_, _, remote_url = remote_url.rpartition('@')
|
_, _, remote_url = remote_url.rpartition('@')
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ def config_with_local_hooks():
|
||||||
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
|
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
|
||||||
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
|
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
|
||||||
config = OrderedDict((
|
config = OrderedDict((
|
||||||
('repo', repo_path),
|
('repo', 'file://{}'.format(repo_path)),
|
||||||
('sha', sha or get_head_sha(repo_path)),
|
('sha', sha or get_head_sha(repo_path)),
|
||||||
(
|
(
|
||||||
'hooks',
|
'hooks',
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from pre_commit.languages.golang import guess_go_dir
|
||||||
('url', 'expected'),
|
('url', 'expected'),
|
||||||
(
|
(
|
||||||
('/im/a/path/on/disk', 'unknown_src_dir'),
|
('/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'),
|
||||||
('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'),
|
('http://github.com/golang/lint', 'github.com/golang/lint'),
|
||||||
|
|
|
||||||
|
|
@ -714,7 +714,7 @@ def test_hook_id_not_present(tempdir_factory, store, fake_log_handler):
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
repo.require_installed()
|
repo.require_installed()
|
||||||
assert fake_log_handler.handle.call_args[0][0].msg == (
|
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? '
|
'Typo? Perhaps it is introduced in a newer version? '
|
||||||
'Often `pre-commit autoupdate` fixes this.'.format(path)
|
'Often `pre-commit autoupdate` fixes this.'.format(path)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue