2017-08-21 21:16:07 +00:00
|
|
|
#!/bin/bash
|
2011-06-16 14:46:56 +00:00
|
|
|
# A script to check whether there have been any string changes.
|
2011-06-16 15:35:46 +00:00
|
|
|
# If it finds some, it commits the new po files and then updates
|
|
|
|
# the stats.
|
2011-06-16 14:46:56 +00:00
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
# We need bash because we use a select loop.
|
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
# The script expects an environment variable FARM that will provide
|
|
|
|
# it with the location of the LyX www tree.
|
2011-06-16 14:46:56 +00:00
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
DEBUG="";
|
2011-06-20 14:47:21 +00:00
|
|
|
COMMIT="";
|
2011-06-16 15:35:46 +00:00
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
# shellcheck disable=SC2086
|
2011-06-20 14:47:21 +00:00
|
|
|
while getopts ":cdh" options $ARGS; do
|
2011-06-16 15:35:46 +00:00
|
|
|
case $options in
|
2011-06-20 14:47:21 +00:00
|
|
|
c) COMMIT="TRUE";;
|
2011-06-16 15:35:46 +00:00
|
|
|
d) DEBUG="echo";;
|
2011-10-29 19:03:43 +00:00
|
|
|
h) echo "update-po.sh [-c] [-d]";
|
|
|
|
echo "-c: Commit any changes we find.";
|
|
|
|
echo "-d: Debugging mode.";
|
2011-06-16 15:35:46 +00:00
|
|
|
echo "You must also point the FARM variable to LyX's www tree.";
|
|
|
|
exit 0;;
|
|
|
|
esac
|
|
|
|
done
|
2011-06-16 14:46:56 +00:00
|
|
|
|
|
|
|
if [ -z "$FARM" ]; then
|
|
|
|
echo "You must set the FARM variable to run this script, e.g.:";
|
|
|
|
echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
FARM=${FARM%/};
|
|
|
|
FARM="$FARM/farm/cookbook/LyX";
|
|
|
|
# Sanity check
|
|
|
|
if [ ! -f "$FARM/i18n.php" ]; then
|
|
|
|
echo "$FARM does not look like LyX's www tree!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get us to the root of the tree we are in.
|
2011-06-20 14:47:21 +00:00
|
|
|
MYDIR=${0%update-po.sh};
|
2011-06-16 14:46:56 +00:00
|
|
|
if [ -n "$MYDIR" ]; then
|
2017-08-21 21:16:07 +00:00
|
|
|
if ! cd "$MYDIR"; then
|
2011-06-20 14:47:21 +00:00
|
|
|
echo "Couldn't cd to $MYDIR!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
2011-06-16 14:46:56 +00:00
|
|
|
fi
|
|
|
|
cd ../../;
|
|
|
|
LYXROOT=$(pwd);
|
|
|
|
|
2012-07-02 21:48:24 +00:00
|
|
|
# We need to make sure that we have a tree without any unstaged
|
|
|
|
# commits. Otherwise commit will fail.
|
|
|
|
if git status --porcelain -uno | grep -q .; then
|
|
|
|
echo "Your git tree is not clean. Please correct the situation and re-run.";
|
|
|
|
echo;
|
|
|
|
git status --porcelain -uno;
|
|
|
|
exit 10;
|
|
|
|
fi
|
|
|
|
|
2011-06-16 14:46:56 +00:00
|
|
|
# Are we in trunk or branch?
|
|
|
|
TRUNK="TRUE";
|
2017-08-21 21:16:07 +00:00
|
|
|
if ls status.* 2>/dev/null; then
|
2011-06-16 14:46:56 +00:00
|
|
|
TRUNK="";
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Sanity check
|
|
|
|
if ! cd po/; then
|
|
|
|
echo "Cannot cd to po/ directory!";
|
|
|
|
pwd
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Remerging...
|
|
|
|
make update-po >/dev/null 2>&1;
|
|
|
|
echo
|
|
|
|
|
|
|
|
if [ -n "$TRUNK" ]; then
|
|
|
|
I18NFILE=i18n_trunk.inc;
|
|
|
|
else
|
|
|
|
I18NFILE=i18n.inc;
|
|
|
|
fi
|
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
# make sure things are clean
|
|
|
|
rm -f i18n.inc;
|
2017-08-21 21:16:07 +00:00
|
|
|
svn revert "$FARM/$I18NFILE";
|
2011-06-16 15:35:46 +00:00
|
|
|
|
|
|
|
echo Running make i18n.inc...
|
|
|
|
make i18n.inc >/dev/null 2>&1;
|
|
|
|
if [ -n "$TRUNK" ]; then
|
|
|
|
mv -f i18n.inc i18n_trunk.inc
|
|
|
|
fi
|
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
if diff -w -q "$I18NFILE $FARM/$I18NFILE" >/dev/null 2>&1; then
|
2011-06-16 14:46:56 +00:00
|
|
|
echo No string differences found.
|
2017-08-21 21:16:07 +00:00
|
|
|
git checkout ./*.po;
|
2011-06-16 14:46:56 +00:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
# So there are differences.
|
2011-06-20 14:47:21 +00:00
|
|
|
if [ -z "$COMMIT" ]; then
|
|
|
|
echo "Differences found!";
|
2017-08-21 21:16:07 +00:00
|
|
|
diff -wu "$FARM/$I18NFILE $I18NFILE" | less;
|
|
|
|
git checkout ./*.po ./*.gmo;
|
2011-06-20 14:47:21 +00:00
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
$DEBUG git commit ./*.po ./*.gmo -m "Remerge strings.";
|
2012-07-02 21:48:24 +00:00
|
|
|
COMMITS=$(git push -n 2>&1 | tail -n 1 | grep -v "Everything" | sed -e 's/^ *//' -e 's/ .*//');
|
|
|
|
|
|
|
|
if [ -z "$COMMITS" ]; then
|
|
|
|
echo "We seem to be missing the commit of the po files!";
|
|
|
|
exit 1;
|
2011-06-16 14:46:56 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
# there may be multiple commits here
|
|
|
|
# shellcheck disable=SC2086
|
2012-07-02 21:48:24 +00:00
|
|
|
git log $COMMITS;
|
|
|
|
|
|
|
|
#Do we want to go ahead?
|
|
|
|
echo
|
|
|
|
echo "Do you want to push these commits?"
|
|
|
|
select answer in Yes No; do
|
|
|
|
if [ "$answer" != "Yes" ]; then
|
|
|
|
echo "You will need to push that commit manually, then.";
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
git push;
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
echo
|
|
|
|
|
2017-08-21 21:16:07 +00:00
|
|
|
if ! cd "$FARM"; then
|
2011-06-16 14:46:56 +00:00
|
|
|
echo "Unable to cd to $FARM!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
2011-06-16 15:35:46 +00:00
|
|
|
|
2011-06-16 14:46:56 +00:00
|
|
|
echo Updating the www-user tree...
|
2011-06-16 15:35:42 +00:00
|
|
|
# note that we're assuming this one is svn.
|
2011-06-16 15:35:46 +00:00
|
|
|
svn up;
|
2011-06-16 14:46:56 +00:00
|
|
|
|
2011-06-16 15:35:46 +00:00
|
|
|
echo Moving $I18NFILE...;
|
2017-08-21 21:16:07 +00:00
|
|
|
mv "$LYXROOT/po/$I18NFILE" .;
|
2011-06-16 14:46:56 +00:00
|
|
|
|
|
|
|
echo Committing...;
|
2011-06-16 15:35:46 +00:00
|
|
|
$DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
|