]> ToastFreeware Gitweb - gregoa/movein.git/blobdiff - movein
Check that mr is installed before using it
[gregoa/movein.git] / movein
diff --git a/movein b/movein
index 3e21387de67ee844fadaa76fd8b972a57e479484..7adf333287f4a0d6b22c7ebe04366118e819a7a9 100755 (executable)
--- a/movein
+++ b/movein
@@ -39,6 +39,7 @@ SYNOPSIS
   $bn add repository_name
   $bn new repository_name file1 [file2 file3...]
   $bn login repository_name
+  $bn exec repository_name command [arg1 arg2...]
 
 COMMANDS
   init 
@@ -64,11 +65,17 @@ COMMANDS
   login repository_name
       start a subshell in repository_name
 
+  exec repository_name command [arg1 arg2...]
+      execute a command in the context of repository_name, for example:
+        $bn exec myrepo git status
+        $bn exec myrepo git ls-files
+
 EOF
 
     exit 1
 }
 
+[ $# -ge 1 ] || usage
 
 GIT_HOST=git.vireo.org
 REMOTE_REPOS=~/git
@@ -89,6 +96,11 @@ init() {
        exit 1
     fi
 
+    if ! which mr > /dev/null; then
+        echo '"mr" not found in the PATH'
+        exit 1
+    fi
+
     echo -n "git server hostname? [git.vireo.org] " 
     read GIT_HOST
     if [ -z "$GIT_HOST" ]; then 
@@ -139,6 +151,20 @@ login() {
     GIT_PS1_SHOWUNTRACKEDFILES= PSMOVEIN="movein:${1}" $SHELL -i || :
 }
 
+execin() {
+    local REPO
+    if [ $# -lt 1 ]; then
+       usage
+    fi
+
+    REPO=$1;shift
+
+    export GIT_DIR="$LOCAL_REPOS/${REPO}.git"
+    export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
+
+    "$@"
+}
+
 add() {
     if [ $# -ne 1 ]; then 
        usage
@@ -237,6 +263,9 @@ case "$command" in
     login)
        login $@
        ;;
+    exec)
+       execin "$@"
+       ;;
     ls)
        list
        ;;