From 7b46c372149e7aca36cdb98fc8158ed04daf973d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Mon, 2 Sep 2019 18:57:43 +0200 Subject: dist-tools/git-commit-po-updates.sh updates - add copyright notice and license - add a terse documentation as header - add an option -n (dry-run) that only prints what would be done. --- dist-tools/git-commit-po-updates.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'dist-tools') diff --git a/dist-tools/git-commit-po-updates.sh b/dist-tools/git-commit-po-updates.sh index 1c2079fe..13e2bf5c 100755 --- a/dist-tools/git-commit-po-updates.sh +++ b/dist-tools/git-commit-po-updates.sh @@ -1,9 +1,33 @@ #!/bin/sh +# dist-tools/git-commit-po-updates.sh +# A helper script to commit translation updates into Git. +# Assumes translation updates are visible to git, +# and one directory above. +# +# © Copyright 2019 by Matthias Andree. +# Licensed under the GNU General Public License V2 or, +# at your choice, any later version. +# +# Supported options: +# -n: dry-run, only print commands, but do not run them. set -eu -# see if Perl has Carp::Always available: + +cd "$(realpath $(dirname $0))/.." + +# see if Perl has Carp::Always available, +# and implicitly fail (set -e) if it hasn't. perl -MCarp::Always -e '' +dryrun_pfx= +while getopts 'n' opt ; do + case $opt in + n) dryrun_pfx=: ;; + ?) printf 'Usage: %s [-n]\n' "$0" ; + exit 2 ; + esac +done + git diff -G ^.Project-Id-Version --name-only po/*.po \ | while read pofile ; do if ! cmd="$(perl -WT - "$pofile" <<'_EOF' @@ -39,5 +63,5 @@ _EOF fi cmd="$cmd '$pofile'" printf '+ %s\n' "$cmd" - eval "$cmd" + $dryrun_pfx eval "$cmd" done -- cgit v1.2.3