CI: tidy up txcheck.sh

- Add license header with SPDX info
 - Add usage header
 - Support --help
 - Document internals a little more
This commit is contained in:
Adriaan de Groot 2020-02-06 12:45:40 +01:00
parent 5d25719918
commit b8505dc621

View File

@ -1,5 +1,18 @@
#! /bin/sh #! /bin/sh
### LICENSE
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# This file is Free Software: you can redistribute it and/or modify
# it under the terms of the 2-clause BSD License.
# https://spdx.org/licenses/BSD-2-Clause.html
#
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: 2019-2020 Adriaan de Groot <groot@kde.org>
### END LICENSE
### USAGE
#
# Does the translation tag (from a previous txpush) exist? # Does the translation tag (from a previous txpush) exist?
# This assumes that the release host has also locally done # This assumes that the release host has also locally done
# a translations push, which works for the current development # a translations push, which works for the current development
@ -7,6 +20,13 @@
# the typical txpush log messages instead of the tag. # the typical txpush log messages instead of the tag.
# #
# Use --cleanup as an argument to clean things up. # Use --cleanup as an argument to clean things up.
#
# Normal use:
# $ sh ci/txcheck.sh
# If there are differences, fix them and then clean up:
# $ sh ci/txcheck.sh --cleanup
#
### END USAGE
# The files that are translated; should match the contents of .tx/config # The files that are translated; should match the contents of .tx/config
TX_FILE_LIST="lang/calamares_en.ts lang/python.pot src/modules/dummypythonqt/lang/dummypythonqt.pot calamares.desktop" TX_FILE_LIST="lang/calamares_en.ts lang/python.pot src/modules/dummypythonqt/lang/dummypythonqt.pot calamares.desktop"
@ -27,6 +47,9 @@ if test "x$1" = "x--cleanup" ; then
tx_cleanup tx_cleanup
exit 0 exit 0
fi fi
if test "x$1" = "x--help" ; then
sed -e '1,/USAGE/d' -e '/END.USAGE/,$d' < "$0"
fi
test -z "$1" || { echo "! Usage: txcheck.sh [--cleanup]" ; exit 1 ; } test -z "$1" || { echo "! Usage: txcheck.sh [--cleanup]" ; exit 1 ; }
@ -67,6 +90,8 @@ fi
if test `git describe` = `git describe --dirty` ; then if test `git describe` = `git describe --dirty` ; then
: :
else else
# Don't want any local changes, since those won't be
# reflected in the worktrees and we might miss a string change.
echo "! There are local changes." echo "! There are local changes."
exit 1 exit 1
fi fi
@ -75,13 +100,20 @@ DATE_PREV=$( git log -1 translation --date=unix | sed -e '/^Date:/s+.*:++p' -e d
DATE_HEAD=$( last_week ) DATE_HEAD=$( last_week )
test "$DATE_PREV" -le "$DATE_HEAD" || { echo "! Translation tag has not aged enough." ; git log -1 translation ; exit 1 ; } test "$DATE_PREV" -le "$DATE_HEAD" || { echo "! Translation tag has not aged enough." ; git log -1 translation ; exit 1 ; }
# Tag is good, do real work of checking strings: collect names of relevant files # Tag is good, check that necessary files exist. The list of
# files is hard-coded, but should match what is in the Transifex config.
test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; } test -f ".tx/config" || { echo "! No Transifex configuration is present." ; exit 1 ; }
for f in $TX_FILE_LIST ; do for f in $TX_FILE_LIST ; do
test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; } test -f $f || { echo "! Translation file '$f' does not exist." ; exit 1 ; }
done done
# The state of translations ### COMPARE TRANSLATIONS
#
#
# The state of translations; assume that sha256 is enough
# to distinguish changed translations when we cat all the
# string sources together.
tx_sum() tx_sum()
{ {
CURDIR=`pwd` CURDIR=`pwd`