Skip to content
Snippets Groups Projects

Release version

Merged Kostas Vilkelis requested to merge release_version into main
All threads resolved!
Files
22
+ 0
32
#!/bin/sh
#
# strip output of IPython Notebooks
# add this as `.git/hooks/pre-commit`
# to run every time you commit a notebook
#
# requires `jupyter nbconvert` to be available on your PATH
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Find notebooks to be committed
(
IFS='
'
NBS=`git diff-index --cached $against --name-only | grep '.ipynb$' | uniq`
for NB in $NBS ; do
echo "Removing outputs from $NB"
cp "$NB" "$NB"_backup
jupyter nbconvert --to notebook --ClearOutputPreprocessor.enabled=True --ClearOutputPreprocessor.remove_metadata_fields="['deletable', 'editable', 'collapsed', 'scrolled']" "$NB" --output "$NB" --output-dir='.'
git add "$NB"
mv "$NB"_backup "$NB"
done
)
exec git diff-index --check --cached $against --
Loading