Files
libloot/scripts/git/pre-commit
T
Frederik “Freso” S. Olesen abd79707af Make the git-commit hook script POSIX compliant.
On a lot of systems using bashisms in /bin/sh scripts will be fine,
since /bin/sh is a symlink to /bin/bash, but some systems symlink it to
the more lightweight (and more strictly POSIX) /bin/dash or some other
shell. Safest thing is to not assume a bashism will work.

What has been changed:
1) `[[ … ]]` is a bashism. Replaced with `[ … ]`.
2) `-eq` is for numeric operations. When a variable is quoted, it
   becomes a string and uses `=` for comparison.
3) `&&` is a shell thing, but does not exist in `test`'s syntax.
   (`[ … ]` is shorthand for `test …`.) `-a` is the "and" when
   talking `test`.
2016-08-04 21:46:52 +02:00

20 lines
948 B
Bash
Executable File

#!/bin/sh
# This is a Git pre-commit hook. Install it to `.git/hooks`.
#
# Run xgettext to write a new resources/l10n/template.pot, then add it to the
# commit if more than one line in it has changed, otherwise discard any changes
# to it.
xgettext -k"translate:1,1t" -k"translate:1c,2,t" --add-location=full --from-code=utf-8 --package-name=LOOT --package-version=0.9.2 --copyright-holder="WrinklyNinja" --msgid-bugs-address="https://github.com/loot/loot/issues" -o resources/l10n/template.pot src/gui/html/js/*.* src/gui/*.cpp src/backend/*/*.* src/backend/*.*
sed -i 's|charset=CHARSET|charset=UTF-8|' resources/l10n/template.pot
LINES_ADDED=$(git diff --numstat resources/l10n/template.pot | cut -f 1)
LINES_REMOVED=$(git diff --numstat resources/l10n/template.pot | cut -f 2)
if [ "$LINES_ADDED" = "$LINES_REMOVED" -a "$LINES_ADDED" = "1" ]; then
git checkout -- resources/l10n/template.pot
else
git add resources/l10n/template.pot
fi