From 7440cf1b742cc16d22ec26bbe7b35af2462ff17e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 17 Sep 2015 19:18:18 -0700 Subject: [PATCH] Add script to pull+squash from weblate. Fixes #140 --- tools/pull-trans.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 tools/pull-trans.sh diff --git a/tools/pull-trans.sh b/tools/pull-trans.sh new file mode 100755 index 000000000..f98cfa473 --- /dev/null +++ b/tools/pull-trans.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +# This script pulls translations from weblate. +# +# It squashes all the changes into a single commit. This removes authorship +# from the changes, which is given to the Translatebot, so to keep the names +# they are grabbed from git log and added to the commit message. +# +# Note that this will apply changes and commit them! Make sure to not have +# uncommited changes when running this script. + +REMOTE="weblate" +REMOTE_URL="git://git.weblate.org/f-droid.git" +REMOTE_BRANCH="master" + +AUTHOR="F-Droid Translatebot " + +if ! git ls-remote --exit-code $REMOTE >/dev/null 2>/dev/null; then + echo "Remote doesn't exist! Try the following:" + echo " git remote add $REMOTE $REMOTE_URL" + echo " git fetch $REMOTE" + exit 1 +fi + +files=$(find . -wholename '*/values-*/strings.xml') + +ref="${REMOTE}/${REMOTE_BRANCH}" +diff="HEAD..$ref -- $files" + +authors=$(git log --format="%s %an" $diff | \ + sed 's/Translated using Weblate (\(.*\)) \(.*\)/\2||\1/' | sort -f -u | column -s '||' -t) + +git diff $diff | git apply + +git add $files + +git commit --author "$AUTHOR" -m "Pull translation updates from weblate + +Translators: + +$authors"