Skip to content

Commit

Permalink
Fix handle IndexError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
llugin authored and greenbonebot committed Aug 13, 2024
1 parent 4fdbe3d commit 66efb6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pontos/updateheader/updateheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@

def _get_modified_year(f: Path) -> str:
"""In case of the changed arg, update year to last modified year"""
return Git().log("-1", "--date=format:%Y", str(f), format="%ad")[0]
try:
ret = Git().log("-1", "--date=format:%Y", str(f), format="%ad")[0]
except IndexError:
raise PontosError(f"Empty \"git log -1\" output for {f}.")

return ret


@dataclass
Expand Down

0 comments on commit 66efb6d

Please sign in to comment.