alicederyn/git-graph-branch

Fatal error if ref missing

Opened this issue · 0 comments

Traceback (most recent call last):
  File "git_graph_branch/__init__.py", line 58, in main
    print_branch(art, b, config)
  File "git_graph_branch/display.py", line 72, in print_branch
    print(SYNC_STATUS_ICON[remote_sync_status(b)], end="")
                           ^^^^^^^^^^^^^^^^^^^^^
  File "git_graph_branch/display.py", line 50, in remote_sync_status
    if b.upstream.commit.commit_date > b.commit.commit_date:
       ^^^^^^^^^^^^^^^^^
  File "git_graph_branch/git/branch.py", line 45, in commit
    with open(self._ref, "r", encoding="ascii") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '.../.git/refs/remotes/origin/main'

The underlying problem in this particular case appears to be #4, as refs/remotes/origin/main is present in .git/packed-refs, but in general we should be resilient to missing upstream refs.