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.
12 while getopts ":cdh" options $ARGS; do
16 h) echo "check-po.sh [-d]";
17 echo "You must also point the FARM variable to LyX's www tree.";
22 if [ -z "$FARM" ]; then
23 echo "You must set the FARM variable to run this script, e.g.:";
24 echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
29 FARM="$FARM/farm/cookbook/LyX";
31 if [ ! -f "$FARM/i18n.php" ]; then
32 echo "$FARM does not look like LyX's www tree!";
36 # Get us to the root of the tree we are in.
37 MYDIR=${0%update-po.sh};
38 if [ -n "$MYDIR" ]; then
40 echo "Couldn't cd to $MYDIR!";
47 # Are we in trunk or branch?
49 if ls status.* 2>/dev/null | grep -q status; then
55 if svn log >/dev/null 2>&1; then
57 elif git diff >/dev/null 2>&1; then
59 # We need to make sure that we have a tree without any unpushed
60 # commits. Otherwise git svn dcommit would commit more than we
62 if git status | grep -Pq 'Your branch is (?:ahead|behind)'; then
63 echo "Your git tree is not clean. Please correct the situation and re-run.";
70 if [ -z "$VCS" ]; then
71 echo "Unable to determine version control system!";
77 echo "Cannot cd to po/ directory!";
83 make update-po >/dev/null 2>&1;
86 if [ -n "$TRUNK" ]; then
87 I18NFILE=i18n_trunk.inc;
92 # make sure things are clean
94 svn revert $FARM/$I18NFILE;
96 echo Running make i18n.inc...
97 make i18n.inc >/dev/null 2>&1;
98 if [ -n "$TRUNK" ]; then
99 mv -f i18n.inc i18n_trunk.inc
102 if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
103 echo No string differences found.
104 # So we will revert the changes to po files, which are probably
105 # just dates and such.
106 if [ "$VCS" = "svn" ]; then
114 # So there are differences.
116 if [ -z "$COMMIT" ]; then
117 echo "Differences found!";
118 diff -w $I18NFILE $FARM/$I18NFILE | less;
119 if [ "$VCS" = "svn" ]; then
127 if [ "$VCS" = "svn" ]; then
130 $DEBUG git commit *.po -m "Remerge strings.";
131 $DEBUG git svn dcommit;
137 echo "Unable to cd to $FARM!";
141 echo Updating the www-user tree...
142 # note that we're assuming this one is svn.
145 echo Moving $I18NFILE...;
146 mv $LYXROOT/po/$I18NFILE .;
149 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
151 if [ -n "$NOTSAFE" ]; then
153 echo "Your LyX tree was not clean.";
154 echo "Your will need to push changes to po files manually."