diff options
author | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2018-04-10 00:54:47 +0200 |
---|---|---|
committer | Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> | 2018-04-10 00:56:36 +0200 |
commit | 069edebecab1731b3a278903c4b8f16703cf60b7 (patch) | |
tree | 722365fc2a6cfdfad5ce28c05e2b36c33949a04f /pre-commit | |
parent | 2fc299303680bb60b6567b9b6cb75a3a22d98de6 (diff) | |
download | elementary-xfce-069edebecab1731b3a278903c4b8f16703cf60b7.tar.gz |
Add pre-commit hook to vacuum svgs
Diffstat (limited to 'pre-commit')
-rwxr-xr-x | pre-commit | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pre-commit b/pre-commit new file mode 100755 index 00000000..0e3725b5 --- /dev/null +++ b/pre-commit @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Runs Inkscape vacuum (twice) to clean up svgs. +# The first run reorders the elements in the svg and pollutes the diffs, the second +# run cancels out this effect. + +CDIR=$(git rev-parse --show-toplevel) + +echo "Running Inkscape vacuum. This may take some time..." + +git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do + if [[ "$FILE" =~ ^.+(svg)$ ]]; then + inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE + inkscape --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE + fi +done + +exit 0 |