]> git.lyx.org Git - lyx.git/blobdiff - development/tools/updatestats.sh
Amend b8502a3ea2735c4
[lyx.git] / development / tools / updatestats.sh
old mode 100644 (file)
new mode 100755 (executable)
index e64ee0a..92970ce
@@ -1,8 +1,17 @@
 #!/bin/sh
 # A script to update the LyX i18n.inc statistics
 
-FARM="/cvs/lyx-www/farm/cookbook/LyX";
+# The script expects an environment variable FARM that 
+# will provide it with the location of the LyX www tree.
 
+if [ -z "$FARM" ]; then
+  echo "You must set the FARM variable to run this script, e.g.:";
+  echo "# FARM=/cvs/lyx-www/ bash updatestats.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!";
@@ -12,14 +21,14 @@ fi
 # Get us to the root of the tree we are in.
 MYDIR=${0%updatestats.sh};
 if [ -n "$MYDIR" ]; then
-  cd $MYDIR;
+  cd "$MYDIR";
 fi
-LYXROOT=$(pwd);
 cd ../../;
+LYXROOT=$(pwd);
 
 # Are we in trunk or branch?
 TRUNK="TRUE";
-if ls status.* 2>/dev/null | grep -q status; then 
+if ls status.* 2>/dev/null; then 
   TRUNK="";
 fi
 
@@ -39,19 +48,28 @@ else
   I18NFILE=i18n.inc;
 fi
 
-if ! cd $FARM; then
+if ! cd "$FARM"; then
   echo "Unable to cd to $FARM!";
   exit 1;
 fi
 
+# Are we under svn or git?
+GIT="";
+if [ -d .git/ ]; then GIT="TRUE"; fi
+
 echo
 echo Updating the www-user tree...
 svn up
 
 echo Copying $I18NFILE...;
-cp $LYXROOT/po/$I18NFILE .;
+cp "$LYXROOT/po/$I18NFILE" .;
 
 echo Committing...;
-svn commit -m "* $I18NFILE: update stats" $I18NFILE;
+if [ -z "$GIT" ]; then
+  svn commit -m "* $I18NFILE: update stats" $I18NFILE;
+else
+  git commit -m "* $I18NFILE: update stats" $I18NFILE;
+  git svn dcommit;
+fi
 
 echo DONE!