]> git.lyx.org Git - lyx.git/blobdiff - development/tools/update-po.sh
Add some localized (Russian) cliparts, by Yuriy
[lyx.git] / development / tools / update-po.sh
old mode 100644 (file)
new mode 100755 (executable)
index 56a46f0..596c3fb
@@ -1,14 +1,17 @@
-#!/bin/sh
+#!/bin/bash
 # A script to check whether there have been any string changes.
 # If it finds some, it commits the new po files and then updates
 # the stats.
 
+# We need bash because we use a select loop.
+
 # The script expects an environment variable FARM that will provide 
 # it with the location of the LyX www tree.
 
 DEBUG="";
 COMMIT="";
 
+# shellcheck disable=SC2086
 while getopts ":cdh" options $ARGS; do
   case $options in
     c)  COMMIT="TRUE";;
@@ -38,7 +41,7 @@ fi
 # Get us to the root of the tree we are in.
 MYDIR=${0%update-po.sh};
 if [ -n "$MYDIR" ]; then
-  if ! cd $MYDIR; then
+  if ! cd "$MYDIR"; then
     echo "Couldn't cd to $MYDIR!";
     exit 1;
   fi
@@ -46,34 +49,21 @@ fi
 cd ../../;
 LYXROOT=$(pwd);
 
+# 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
+
 # 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
 
-# Git or SVN?
-VCS="";
-if svn log >/dev/null 2>&1; then
-  VCS="svn";
-elif git diff >/dev/null 2>&1; then
-  VCS="git";
-  # We need to make sure that we have a tree without any unpushed 
-  # commits. Otherwise git svn dcommit would commit more than we
-  # want.
-  if git status | grep -Pq 'Your branch is (?:ahead|behind)'; then
-    echo "Your git tree is not clean. Please correct the situation and re-run.";
-    echo;
-    git status;
-    exit 10;
-  fi
-fi
-
-if [ -z "$VCS" ]; then 
-  echo "Unable to determine version control system!";
-  exit 1;
-fi
-
 # Sanity check
 if ! cd po/; then 
   echo "Cannot cd to po/ directory!";
@@ -93,7 +83,7 @@ fi
 
 # make sure things are clean
 rm -f i18n.inc;
-svn revert $FARM/$I18NFILE;
+svn revert "$FARM/$I18NFILE";
 
 echo Running make i18n.inc...
 make i18n.inc  >/dev/null 2>&1;
@@ -101,41 +91,48 @@ if [ -n "$TRUNK" ]; then
   mv -f i18n.inc i18n_trunk.inc
 fi
 
-if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
+if diff -w -q "$I18NFILE $FARM/$I18NFILE" >/dev/null 2>&1; then
   echo No string differences found.
-  # So we will revert the changes to po files, which are probably
-  # just dates and such.
-  if [ "$VCS" = "svn" ]; then
-    svn revert *.po;
-  else
-    git checkout *.po;
-  fi
+  git checkout ./*.po;
   exit 0;
 fi
 
 # So there are differences.
-
 if [ -z "$COMMIT" ]; then
   echo "Differences found!";
-  diff -w $I18NFILE $FARM/$I18NFILE | less;
-  if [ "$VCS" = "svn" ]; then
-    svn revert *.po;
-  else
-    git checkout *.po;
-  fi
+  diff -wu "$FARM/$I18NFILE $I18NFILE" | less;
+  git checkout ./*.po ./*.gmo;
   exit 0;
 fi
 
-if [ "$VCS" = "svn" ]; then
-  $DEBUG svn ci *.po;
-else
-  $DEBUG git commit *.po -m "Remerge strings.";
-  $DEBUG git svn dcommit;
+$DEBUG git commit ./*.po ./*.gmo -m "Remerge strings.";
+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;
 fi
 
+# there may be multiple commits here
+# shellcheck disable=SC2086
+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
+
 echo
 
-if ! cd $FARM; then
+if ! cd "$FARM"; then
   echo "Unable to cd to $FARM!";
   exit 1;
 fi
@@ -145,13 +142,7 @@ echo Updating the www-user tree...
 svn up;
 
 echo Moving $I18NFILE...;
-mv $LYXROOT/po/$I18NFILE .;
+mv "$LYXROOT/po/$I18NFILE" .;
 
 echo Committing...;
 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
-
-if [ -n "$NOTSAFE" ]; then
-  echo
-  echo "Your LyX tree was not clean.";
-  echo "Your will need to push changes to po files manually."
-fi