#!/bin/sh
#
# Copyright © 2008 Mike O'Connor <stew@vireo.org>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
set -e
$bn command [options]
$bn init
+ $bn ls
+ $bn list
$bn add repository_name
$bn new repository_name file1 [file2 file3...]
+ $bn login repository_name
COMMANDS
init
create ~/.mrconfig
+ ls
+ list
+ show a list of repositories
+
add repository_name
checkout the repository from the remote host and add it to
mr's configuration
create a new repository on the remote host, and checkin the
listed files to the new repository. Add the new repository
to mr's configuration
+
+ login repository_name
+ start a subshell in repository_name
+
EOF
exit 1
}
-GIT_HOST=flounder.vireo.org
+GIT_HOST=git.vireo.org
REMOTE_REPOS=~/git
-LOCAL_REPOS=~/.fgits
+LOCAL_REPOS=~/.movein
MRCONFIG=~/.mrconfig
+MOVEINRC=~/.moveinrc
+[ -e "$MOVEINRC" ] && . "$MOVEINRC"
init() {
echo $MRCONFIG already exists
exit 1
fi
+
+ if [ -e $MOVEINRC ]; then
+ echo $MOVEINRC already exists
+ exit 1
+ fi
+
+ echo -n "git server hostname? [git.vireo.org] "
+ read GIT_HOST
+ if [ -z "$GIT_HOST" ]; then
+ GIT_HOST=git.vireo.org
+ fi
+
+ echo -n "path to remote repositories? [~/git] "
+ read REMOTE_REPOS
+ if [ -z "$REMOTE_REPOS" ]; then
+ REMOTE_REPOS=~/git
+ fi
+
+ echo -n "Local repository directory? [~/.movein] "
+ read LOCAL_REPOS
+ if [ -z "$LOCAL_REPOS" ]; then
+ LOCAL_REPOS=~/.movein
+ fi
+
+ echo -n "Location of .mrconfig file? [~/.mrconfig] "
+ read MRCONFIG
+ if [ -z "$MRCONFIG" ]; then
+ MRCONFIG=~/.mrconfig
+ fi
+
+ cat <<EOF > $MOVEINRC
+GIT_HOST=$GIT_HOST
+REMOTE_REPOS=$REMOTE_REPOS
+LOCAL_REPOS=$LOCAL_REPOS
+MRCONFIG=$MRCONFIG
+EOF
+
+ if [ ! -d "$LOCAL_REPOS" ]; then
+ mkdir -p "$LOCAL_REPOS"
+ fi
- mkdir $LOCAL_REPOS
cat <<END > $MRCONFIG
[DEFAULT]
include = cat /usr/share/mr/git-fake-bare
END
+
+
}
+login() {
+ if [ $# -ne 1 ]; then
+ usage
+ fi
+
+ export GIT_DIR="$LOCAL_REPOS/${1}.git"
+ export GIT_WORK_TREE="$GIT_DIR/$(git config --get core.worktree)"
+
+ $SHELL -i || :
+}
add() {
if [ $# -ne 1 ]; then
}
+list() {
+ find "${LOCAL_REPOS}" -mindepth 1 -maxdepth 1 -type d | sed 's,^.*/\([^/]*\).git$,\1,'
+}
+
new() {
if [ $# -lt 2 ]; then
usage
}
+
command=$1 ; shift
case "$command" in
init)
new)
new $@
;;
+ login)
+ login $@
+ ;;
+ ls)
+ list
+ ;;
+ list)
+ list
+ ;;
+
+ *)
+ usage
+ exit 1
+ ;;
esac