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 # The script expects an environment variable FARM that will provide
7 # it with the location of the LyX www tree.
11 while getopts ":dh" options $ARGS; do
14 h) echo "check-po.sh [-d]";
15 echo "You must also point the FARM variable to LyX's www tree.";
20 if [ -z "$FARM" ]; then
21 echo "You must set the FARM variable to run this script, e.g.:";
22 echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
27 FARM="$FARM/farm/cookbook/LyX";
29 if [ ! -f "$FARM/i18n.php" ]; then
30 echo "$FARM does not look like LyX's www tree!";
34 # Get us to the root of the tree we are in.
35 MYDIR=${0%check-po.sh};
36 if [ -n "$MYDIR" ]; then
42 # Are we in trunk or branch?
44 if ls status.* 2>/dev/null | grep -q status; then
50 if svn log >/dev/null 2>&1; then
52 elif git diff >/dev/null 2>&1; then
56 if [ -z "$VCS" ]; then
57 echo "Unable to determine version control system!";
63 echo "Cannot cd to po/ directory!";
69 make update-po >/dev/null 2>&1;
72 if [ -n "$TRUNK" ]; then
73 I18NFILE=i18n_trunk.inc;
78 # make sure things are clean
80 svn revert $FARM/$I18NFILE;
82 echo Running make i18n.inc...
83 make i18n.inc >/dev/null 2>&1;
84 if [ -n "$TRUNK" ]; then
85 mv -f i18n.inc i18n_trunk.inc
88 if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
89 echo No string differences found.
90 # So we will revert the changes to po files, which are probably
91 # just dates and such.
92 if [ "$VCS" = "svn" ]; then
100 # So there are differences.
101 if [ "$VCS" = "svn" ]; then
104 # We need to make sure that we have a tree without any unpushed
105 # commits. Otherwise git svn dcommit would commit more than we
108 if git status | grep -Pq 'Your branch is (?:ahead|behind)'; then
111 $DEBUG git commit *.po -m "Remerge strings.";
112 if [ -z "$NOTSAFE" ]; then
113 $DEBUG git svn dcommit;
120 echo "Unable to cd to $FARM!";
124 echo Updating the www-user tree...
125 # note that we're assuming this one is svn.
128 echo Moving $I18NFILE...;
129 mv $LYXROOT/po/$I18NFILE .;
132 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
134 if [ -n "$NOTSAFE" ]; then
136 echo "Your LyX tree was not clean.";
137 echo "Your will need to push changes to po files manually."