feat: make better error message if try-repo fails because there are no commits on the repo.

This commit is contained in:
Jared Koontz 2025-03-31 17:23:33 -06:00
parent d2b61d0ef2
commit ef638716cb
3 changed files with 34 additions and 4 deletions

View file

@ -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]