Skip to content

Commit

Permalink
Remove guess_go_dir and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
taoufik07 committed Dec 30, 2022
1 parent d5ed387 commit d128ccd
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 43 deletions.
5 changes: 0 additions & 5 deletions pre_commit/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ def get_git_common_dir(git_root: str = '.') -> str:
return get_git_dir(git_root)


def get_remote_url(git_root: str) -> str:
_, out, _ = cmd_output('git', 'config', 'remote.origin.url', cwd=git_root)
return out.strip()


def is_in_merge_conflict() -> bool:
git_dir = get_git_dir('.')
return (
Expand Down
16 changes: 0 additions & 16 deletions pre_commit/languages/golang.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,6 @@ def in_env(
yield


def guess_go_dir(remote_url: str) -> str:
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(':', '/')
if looks_like_url:
_, _, remote_url = remote_url.rpartition('//')
_, _, remote_url = remote_url.rpartition('@')
return remote_url
else:
return 'unknown_src_dir'


def install_environment(
prefix: Prefix, version: str, additional_dependencies: Sequence[str],
) -> None:
Expand Down
5 changes: 0 additions & 5 deletions tests/git_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,3 @@ def test_no_git_env():
def test_init_repo_no_hooks(tmpdir):
git.init_repo(str(tmpdir), remote='dne')
assert not tmpdir.join('.git/hooks').exists()


def test_get_remote_url(tmpdir):
git.init_repo(str(tmpdir), remote='dne')
assert git.get_remote_url(tmpdir) == 'dne'
17 changes: 0 additions & 17 deletions tests/languages/golang_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,3 @@ def test_golang_default_version_system_available(exe_exists_mck):
def test_golang_default_version_system_not_available(exe_exists_mck):
exe_exists_mck.return_value = False
assert ACTUAL_GET_DEFAULT_VERSION() == '1.19.4'


@pytest.mark.parametrize(
('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'),
('https://github.com/golang/lint', 'github.com/golang/lint'),
('ssh://git@github.com/golang/lint', 'github.com/golang/lint'),
('git@github.com:golang/lint.git', 'github.com/golang/lint'),
),
)
def test_guess_go_dir(url, expected):
assert golang.guess_go_dir(url) == expected

0 comments on commit d128ccd

Please sign in to comment.