2 # A script to check whether there have been any string changes.
3 # If it finds some, it commits the new po files and then updates
6 # We need bash because we use a select loop.
8 # The script expects an environment variable FARM that will provide
9 # it with the location of the LyX www tree.
14 # shellcheck disable=SC2086
15 while getopts ":cdh" options $ARGS; do
19 h) echo "update-po.sh [-c] [-d]";
20 echo "-c: Commit any changes we find.";
21 echo "-d: Debugging mode.";
22 echo "You must also point the FARM variable to LyX's www tree.";
27 if [ -z "$FARM" ]; then
28 echo "You must set the FARM variable to run this script, e.g.:";
29 echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
34 FARM="$FARM/farm/cookbook/LyX";
36 if [ ! -f "$FARM/i18n.php" ]; then
37 echo "$FARM does not look like LyX's www tree!";
41 # Get us to the root of the tree we are in.
42 MYDIR=${0%update-po.sh};
43 if [ -n "$MYDIR" ]; then
44 if ! cd "$MYDIR"; then
45 echo "Couldn't cd to $MYDIR!";
52 # We need to make sure that we have a tree without any unstaged
53 # commits. Otherwise commit will fail.
54 if git status --porcelain -uno | grep -q .; then
55 echo "Your git tree is not clean. Please correct the situation and re-run.";
57 git status --porcelain -uno;
61 # Are we in trunk or branch?
63 if ls status.* 2>/dev/null; then
69 echo "Cannot cd to po/ directory!";
75 make update-po >/dev/null 2>&1;
78 if [ -n "$TRUNK" ]; then
79 I18NFILE=i18n_trunk.inc;
84 # make sure things are clean
86 svn revert "$FARM/$I18NFILE";
88 echo Running make i18n.inc...
89 make i18n.inc >/dev/null 2>&1;
90 if [ -n "$TRUNK" ]; then
91 mv -f i18n.inc i18n_trunk.inc
94 if diff -w -q "$I18NFILE $FARM/$I18NFILE" >/dev/null 2>&1; then
95 echo No string differences found.
100 # So there are differences.
101 if [ -z "$COMMIT" ]; then
102 echo "Differences found!";
103 diff -wu "$FARM/$I18NFILE $I18NFILE" | less;
104 git checkout ./*.po ./*.gmo;
108 $DEBUG git commit ./*.po ./*.gmo -m "Remerge strings.";
109 COMMITS=$(git push -n 2>&1 | tail -n 1 | grep -v "Everything" | sed -e 's/^ *//' -e 's/ .*//');
111 if [ -z "$COMMITS" ]; then
112 echo "We seem to be missing the commit of the po files!";
116 # there may be multiple commits here
117 # shellcheck disable=SC2086
120 #Do we want to go ahead?
122 echo "Do you want to push these commits?"
123 select answer in Yes No; do
124 if [ "$answer" != "Yes" ]; then
125 echo "You will need to push that commit manually, then.";
135 if ! cd "$FARM"; then
136 echo "Unable to cd to $FARM!";
140 echo Updating the www-user tree...
141 # note that we're assuming this one is svn.
144 echo Moving $I18NFILE...;
145 mv "$LYXROOT/po/$I18NFILE" .;
148 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;