Skip to content

Commit 989bcfe

Browse files
committed
Use file:// protocol for cloning under test
1 parent e76bc17 commit 989bcfe

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

pre_commit/languages/golang.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def in_env(repo_cmd_runner):
3737
def guess_go_dir(remote_url):
3838
if remote_url.endswith('.git'):
3939
remote_url = remote_url[:-1 * len('.git')]
40+
looks_like_url = (
41+
not remote_url.startswith('file://') and
42+
('//' in remote_url or '@' in remote_url)
43+
)
4044
remote_url = remote_url.replace(':', '/')
41-
looks_like_url = '//' in remote_url or '@' in remote_url
4245
if looks_like_url:
4346
_, _, remote_url = remote_url.rpartition('//')
4447
_, _, remote_url = remote_url.rpartition('@')

testing/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def config_with_local_hooks():
8383
def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
8484
manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE))
8585
config = OrderedDict((
86-
('repo', repo_path),
86+
('repo', 'file://{}'.format(repo_path)),
8787
('sha', sha or get_head_sha(repo_path)),
8888
(
8989
'hooks',

tests/languages/golang_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
('url', 'expected'),
1111
(
1212
('/im/a/path/on/disk', 'unknown_src_dir'),
13+
('file:///im/a/path/on/disk', 'unknown_src_dir'),
1314
('git@github.com:golang/lint', 'github.com/golang/lint'),
1415
('git://github.com/golang/lint', 'github.com/golang/lint'),
1516
('http://github.com/golang/lint', 'github.com/golang/lint'),

tests/repository_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def test_hook_id_not_present(tempdir_factory, store, fake_log_handler):
714714
with pytest.raises(SystemExit):
715715
repo.require_installed()
716716
assert fake_log_handler.handle.call_args[0][0].msg == (
717-
'`i-dont-exist` is not present in repository {}. '
717+
'`i-dont-exist` is not present in repository file://{}. '
718718
'Typo? Perhaps it is introduced in a newer version? '
719719
'Often `pre-commit autoupdate` fixes this.'.format(path)
720720
)

0 commit comments

Comments
 (0)