diff --git a/hooks/pre-commit b/hooks/pre-commit index 7fcd482..cf15ca1 100644 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import sys +import os import subprocess from pathlib import Path @@ -8,6 +9,10 @@ staged_fnames = subprocess.check_output(["git", "diff", "--name-only", "--cached contains_gps = [] for fname in staged_fnames: + try: + os.stat(fname) + except FileNotFoundError: # deleted in this commit + continue cont = subprocess.check_output(["exiftool", "-gpslatitude", "-gpslongitude", "-T", fname]).decode() if cont != "-\t-\n": # output where there is no result contains_gps.append((fname, cont))