1#!/bin/bash 2 3# Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org> 4# Copyright © 2019 by The qTox Project Contributors 5# 6# This file is part of qTox, a Qt-based graphical interface for Tox. 7# qTox is libre software: you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation, either version 3 of the License, or 10# (at your option) any later version. 11# 12# qTox is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with qTox. If not, see <http://www.gnu.org/licenses/> 19 20# Script to update the translations from Weblate. Works only if there are no 21# merge conflicts. Assumes that working dir is a qTox git repo. 22# 23# Requires a GPG key to sign merge commits. 24 25# usage: 26# ./$script 27 28 29set -e -o pipefail 30 31readonly COMMIT_NAME="chore(l10n): update translations from Weblate 32 33" 34 35source_functions() { 36 local fns_file="tools/lib/PR_bash.source" 37 source $fns_file 38} 39 40# If there's no qTox Weblate remote, add it 41add_remote_weblate() { 42 local remote_url="https://hosted.weblate.org/git/tox/qtox/" 43 local remote_name="weblate" 44 45 is_remote_present $remote_name \ 46 || git remote add $remote_name "${remote_url}" 47} 48 49do_merge() { 50 # update commits 51 git fetch upstream 52 git fetch weblate 53 54 git checkout upstream/master 55 56 local COMMIT_MESSAGE=`git shortlog upstream/master..weblate/master` 57 58 # squash and merge 59 git merge --squash --no-edit weblate/master 60 61 # update format for adapt to Qt translation format 62 ./tools/deweblate-translation-file.sh ./translations/*.ts || true 63 64 # commit 65 git commit --no-edit -S -m "$COMMIT_NAME" -m "$COMMIT_MESSAGE" 66} 67 68main() { 69 source_functions 70 add_remote 71 add_remote_weblate 72 73 do_merge 74 75 echo "You can now checkout the changes with:" 76 echo "" 77 echo " git checkout -b <branch-name>" 78 echo "" 79} 80main 81