Skip to content
Snippets Groups Projects
Commit 80a840ab authored by Kostas Vilkelis's avatar Kostas Vilkelis :flamingo:
Browse files

set up precommit hooks

parent de992983
No related branches found
No related tags found
1 merge request!5Release version
Pipeline #178555 failed
......@@ -53,3 +53,15 @@ pages:
paths:
- public
run pre-commit:
variables:
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.pre-commit-cache
script:
- micromamba install -c conda-forge -y mamba pip pre-commit git
- git config --global --add safe.directory $CI_PROJECT_DIR
- pre-commit run --all-files
cache:
key: "$CI_JOB_NAME"
paths:
- .pre-commit-cache
- micromamba
#!/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 --
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment