File: pre-commit

package info (click to toggle)
elementary-xfce 0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 58,332 kB
  • sloc: ansic: 94; sh: 68; makefile: 55
file content (18 lines) | stat: -rwxr-xr-x 560 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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