Skip to content

Commit 1dea1ff

Browse files
committed
fix bug in git notebook hook where deleted files would cause an error
1 parent 59b4963 commit 1dea1ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git-hooks/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ for filename in staged_files:
1717
if filename.endswith(".ipynb"):
1818
# Load notebook as it looks in the staging area using 'git show :filename' (note the colon)
1919
completed_process = subprocess.run(["git", "show", ":" + filename], capture_output=True)
20+
if completed_process.returncode != 0:
21+
# This probably means that the file is staged for deletion
22+
continue
23+
2024
notebook = json.loads(completed_process.stdout.decode("utf-8"))
2125

2226
# If any cell contains output, warn and set abort flag

0 commit comments

Comments
 (0)