Allow the script to be run only in the origin directory
authorOleg Broytman <phd@phdru.name>
Tue, 20 May 2014 00:57:30 +0000 (04:57 +0400)
committerOleg Broytman <phd@phdru.name>
Tue, 20 May 2014 00:57:30 +0000 (04:57 +0400)
update

diff --git a/update b/update
index 9d996d8..552c1e5 100755 (executable)
--- a/update
+++ b/update
@@ -1,8 +1,23 @@
 #! /bin/sh
 
-current="`git config --get remote.current.url`" &&
+current="`git config --get --path remote.current.url`"
+origin="`git config --get --path remote.origin.url`"
 
-git pull --ff-only current master && git push web &&
+if [ -n "$origin" ]; then
+   if [ -n "$current" ]; then
+      echo "UNKNOWN ERROR"
+   else
+      echo "This script must be run in the origin directory: $origin"
+   fi >&2
+   exit 1
+elif [ -z "$current" ]; then
+   echo "UNKNOWN ERROR" >&2
+   exit 1
+fi
 
-cd "$current" &&
-exec git pull origin
+git pull --ff-only current master &&
+
+web="`git config --get --path remote.web.url`" &&
+[ -n "$web" ] && git push web
+
+cd "$current" && exec git pull origin