Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only re-add svg files which were already added #798

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 20 additions & 16 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
#
# 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
if [ "$(git diff --cached --name-only | grep '.svg$')" ]; then

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
done

git add .

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 diff --cached --name-only | grep '.svg$' | xargs git add

fi
exit 0