diff options
author | Robert Adam <dev@robert-adam.de> | 2020-09-06 17:38:09 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2020-09-06 17:38:09 +0300 |
commit | 4f3f61e741a59df3dfd3aba64e1dea011c62e52d (patch) | |
tree | 2e48b08a722d089dff91dd99927b6cf8ff2acab6 /scripts | |
parent | fa2a42c40f37e93d6c49c22a6ad6a7d8a26367cb (diff) |
MAINT: Use rel paths in updatetranslations.sh
The script now uses relative paths (in order to not include information
about the committer's file tree in the commit message.
Furthermore the pushd/popd was removed as we don't have to restore the
path in a shell script as these run in a sub-shell anyways and therefore
can't change the calling shell's pwd.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/updatetranslations.sh | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/scripts/updatetranslations.sh b/scripts/updatetranslations.sh index 8c8412519..c27ec8b30 100755 --- a/scripts/updatetranslations.sh +++ b/scripts/updatetranslations.sh @@ -21,10 +21,12 @@ set -e set -o pipefail file="mumble_en.ts" -scriptPath="$(realpath $0)" -srcDir="$(dirname $scriptPath)/../src" -dir="$srcDir/mumble" -# Make sure we are using +rootDir="$(dirname $(realpath $0))/.." +filePath="./src/mumble/$file" + +cd "$rootDir" + +# Make sure we are using Qt5 export QT_SELECT=5 tmpfile="commitmessage.tmp" @@ -59,48 +61,42 @@ function main { checkRequirements - if ! [[ -f "$dir/$file" ]]; + if ! [[ -f "$filePath" ]]; then - printError "Could not find file '${file}'." + printError "Could not find file '$filePath'." exit 1 fi - pushd "$dir" >/dev/null - trap 'code=$? ; popd >/dev/null; exit $code' INT TERM EXIT - - if [[ -n $(git status --porcelain $file) ]] ; then - printError "The file $file has local changes." + if [[ -n $(git status --porcelain "$filePath") ]] ; then + printError "The file $filePath has local changes." exit 1 fi echo "TRANSLATION: Update translation files" > $tmpfile echo "" >> $tmpfile - lupdate -no-ui-lines -disable-heuristic similartext -locations none -no-obsolete -no-recursive "$srcDir" "$srcDir/mumble" -ts "$file" | tee -a $tmpfile || fatal "lupdate failed" - echo + lupdate -no-ui-lines -disable-heuristic similartext -locations none -no-obsolete -no-recursive "./src" "./src/mumble" -ts "$filePath" \ + | tee -a $tmpfile || fatal "lupdate failed" + echo "" # Duplicate single numerusform entries in mumble_en.ts to work around #1195 - perl -pi -e 's!(^\s*)(<numerusform></numerusform>)$!\1\2\2!' $file || (rm $tmpfile ; fatal "Workardound for #1195 failed - in-place replacement via perl.") + perl -pi -e 's!(^\s*)(<numerusform></numerusform>)$!\1\2\2!' $filePath || (rm $tmpfile ; fatal "Workardound for #1195 failed - in-place replacement via perl.") - if ! [[ -n $(git status --porcelain $file) ]] ; then + if ! [[ -n $(git status --porcelain $filePath) ]] ; then echo "No translation changes. Nothing to commit." rm $tmpfile exit 0 fi echo "Committing changes ..." - git commit -F $tmpfile $file || (rm $tmpfile ; fatal "Failed to commit the changes") + git commit -F $tmpfile $filePath || (rm $tmpfile ; fatal "Failed to commit the changes") rm $tmpfile || printError "Failed to remove temporary file '$tmpfile'" echo "Probably done." echo echo "Before pushing, _manually_ check the output above as well as the commits changes." echo "An lupdate warning about overriding TRANSLATIONS is expected, as well as \"removal of plural forms\". Any project errors (missing qt modules) however are not, and the resulting changes must not be pushed." - - popd >/dev/null - trap - INT TERM EXIT - } main |