]> ToastFreeware Gitweb - gregoa/movein.git/blobdiff - movein
Merge branch 'master' of git://git.vireo.org/movein
[gregoa/movein.git] / movein
diff --git a/movein b/movein
index ea98b73caef5ea50511eeccb99ab8d138adc1d74..7adf333287f4a0d6b22c7ebe04366118e819a7a9 100755 (executable)
--- a/movein
+++ b/movein
@@ -34,9 +34,12 @@ SYNOPSIS
   $bn init
   $bn ls
   $bn list
+  $bn ls-r
+  $bn list-remote
   $bn add repository_name
   $bn new repository_name file1 [file2 file3...]
   $bn login repository_name
+  $bn exec repository_name command [arg1 arg2...]
 
 COMMANDS
   init 
@@ -44,7 +47,11 @@ COMMANDS
 
   ls
   list
-      show a list of repositories
+      show a list of local repositories
+
+  ls-r
+  list-remote
+      show a list of remote repositories
 
   add repository_name
       checkout the repository from the remote host and add it to
@@ -58,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
@@ -83,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 
@@ -130,7 +148,21 @@ login() {
     export GIT_DIR="$LOCAL_REPOS/${1}.git"
     export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
 
-    $SHELL -i || :
+    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() {
@@ -166,6 +198,12 @@ list() {
     find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
 }
 
+listremote() {
+    ssh $GIT_HOST "
+        find '${REMOTE_REPOS}' -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
+    " </dev/null
+}
+
 new() {
     if [ $# -lt 2 ]; then 
        usage
@@ -217,19 +255,28 @@ case "$command" in
        init $@
        ;;
     add)
-        add $@
+       add $@
        ;;
     new)
-        new $@
+       new $@
        ;;
     login)
-        login $@
+       login $@
+       ;;
+    exec)
+       execin "$@"
        ;;
     ls)
-        list
+       list
        ;;
     list)
-        list
+       list
+       ;;
+    ls-r)
+       listremote
+       ;;
+    list-remote)
+       listremote
        ;;
 
     *)