Handle deleted files in pre-commit hook
This commit is contained in:
parent
2073c5e907
commit
97eae24225
1 changed files with 5 additions and 0 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue