mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 01:51:46 +04:00
feat: make better error message if try-repo fails because there are no commits on the repo.
This commit is contained in:
parent
d2b61d0ef2
commit
ef638716cb
3 changed files with 34 additions and 4 deletions
|
|
@ -168,7 +168,19 @@ def get_changed_files(old: str, new: str) -> list[str]:
|
|||
|
||||
|
||||
def head_rev(remote: str) -> str:
|
||||
_, out, _ = cmd_output('git', 'ls-remote', '--exit-code', remote, 'HEAD')
|
||||
try:
|
||||
_, out, _ = cmd_output(
|
||||
'git', 'ls-remote', '--exit-code',
|
||||
remote, 'HEAD',
|
||||
)
|
||||
except CalledProcessError as e:
|
||||
if e.returncode == 2:
|
||||
raise FatalError(
|
||||
f'repo {remote} found but appears to have no commits. '
|
||||
f'Make a commit in {remote} to use it',
|
||||
)
|
||||
raise e
|
||||
|
||||
return out.split()[0]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue