From c62257add9d29964e628edd86d87101bead7b568 Mon Sep 17 00:00:00 2001
From: Mikolaj Rybinski <mikolaj.rybinski@id.ethz.ch>
Date: Fri, 17 Sep 2021 15:42:30 +0200
Subject: [PATCH] Pre-commit hook to filter-out output cells

---
 .hooks/pre-commit       | 10 ++++++++++
 binder/requirements.txt |  1 +
 2 files changed, 11 insertions(+)
 create mode 100755 .hooks/pre-commit

diff --git a/.hooks/pre-commit b/.hooks/pre-commit
new file mode 100755
index 0000000..82cb3a4
--- /dev/null
+++ b/.hooks/pre-commit
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+for U in "$(git diff --cached --name-only)"; do
+    # skip files staged for deletion
+    test -e "$U" || continue
+    if [[ "$U" =~ .ipynb$ ]]; then
+        jupyter nbconvert --debug --ClearOutputPreprocessor.enabled=True --inplace "$U"
+    fi
+    git add "$U"
+done
diff --git a/binder/requirements.txt b/binder/requirements.txt
index 30912f8..785c8f9 100644
--- a/binder/requirements.txt
+++ b/binder/requirements.txt
@@ -1,5 +1,6 @@
 black
 isort
+jupyter_contrib_nbextensions
 jupyterlab
 jupyterlab-code-formatter
 jupyterlab-execute-time
-- 
GitLab