File: pre-commit

package info (click to toggle)
elementary-icon-theme 8.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 34,008 kB
  • sloc: sh: 14; makefile: 7
file content (22 lines) | stat: -rwxr-xr-x 548 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
#
# Runs Inkscape vacuum to clean up svgs

CDIR=$(git rev-parse --show-toplevel)
echo "Running Inkscape vacuum. This may take some time..."

# Check if Inkscape is a flatpak or not
if [ $(which inkscape &>/dev/null; echo $?) == 0 ]; then
  INKSCAPE='inkscape'
else
  INKSCAPE='flatpak run org.inkscape.Inkscape'
fi

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
  fi
done

git add .
exit 0