From 864370bd3d42111ac039b81bbb166d05d60e494a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 1 Apr 2010 09:58:02 -0600 Subject: add commit bindings to the tag and comment plugins. this is totally untested --- rvs/plugins/comments/bin/comment.sh | 15 ++++---- rvs/plugins/comments/bin/commit.sh | 24 +++++++++++++ rvs/plugins/tags/bin/commit.sh | 0 rvs/wrapper/rvs.sh | 71 +++++++++++++++++++++++++------------ 4 files changed, 78 insertions(+), 32 deletions(-) create mode 100644 rvs/plugins/comments/bin/commit.sh create mode 100644 rvs/plugins/tags/bin/commit.sh (limited to 'rvs') diff --git a/rvs/plugins/comments/bin/comment.sh b/rvs/plugins/comments/bin/comment.sh index c3724db..fbe5689 100644 --- a/rvs/plugins/comments/bin/comment.sh +++ b/rvs/plugins/comments/bin/comment.sh @@ -1,7 +1,7 @@ #!/bin/sh -name='rvs @ID@ comment' +name='rvs @ID@ commit' ver=0.1 -# Copyright (C) 2010 Luke Shumaker +# Copyright (C) 2009-2010 Luke Shumaker # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -17,11 +17,8 @@ ver=0.1 # along with this program; see the file COPYING. # If not, see . -# comment ID -usage="usage: $RVS comment ID" -ID="${1?"$usage"}" - -file="$REPO/@ID@/$ID" -mkdir -p "`dirname "$file"`" -editor "$file" >> /dev/stderr +if [ "$RVS_LEVEL" = '0' ]; then + id=`cat $TMPDIR/commit/files` + "$RVS" tag "$id" wch +fi diff --git a/rvs/plugins/comments/bin/commit.sh b/rvs/plugins/comments/bin/commit.sh new file mode 100644 index 0000000..7a6e619 --- /dev/null +++ b/rvs/plugins/comments/bin/commit.sh @@ -0,0 +1,24 @@ +#!/bin/sh +name='rvs @ID@ commit' +ver=0.1 +# Copyright (C) 2009-2010 Luke Shumaker +# +# 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 of the +# License, 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; see the file COPYING. +# If not, see . + +if [ "$RVS_LEVEL" = '0' ]; then + id=`cat $TMPDIR/commit/files` + "$RVS" comment "$id" +fi + diff --git a/rvs/plugins/tags/bin/commit.sh b/rvs/plugins/tags/bin/commit.sh new file mode 100644 index 0000000..e69de29 diff --git a/rvs/wrapper/rvs.sh b/rvs/wrapper/rvs.sh index bac92e5..e2e94e6 100644 --- a/rvs/wrapper/rvs.sh +++ b/rvs/wrapper/rvs.sh @@ -19,7 +19,7 @@ ver='0.9' # If not, see . export RVS="$0" #RVS="@RVS@" -export BINDIR="@BINDIR@" + BINDIR="@BINDIR@" baseTMPDIR="@TMPDIR@" export LIBDIR="@LIBDIR@" export ETCDIR="@ETCDIR@" @@ -31,44 +31,56 @@ export ETCDIR="@ETCDIR@" # General ############################################################ _error() { - echo "$RVS: $@" >> /dev/stderr - exit 1 + echo "$RVS: $1" >> /dev/stderr + exit ${2-1} } # Repository ######################################################### _repo() { - repo=".$name" - owd="`pwd`" # old working directory - - # [----can ascend-----] && [-haven't found repo-] - while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do - pwd=`pwd` - cd .. - done - - if [ -e "`pwd`/$repo" ]; then - # we found a repository - echo "`pwd`/$repo" - else - # we didn't find a repository - _error "no $name repository found" + if [ -z "$REPO" ]; then # we aren't getting a value from then env + repo=".$name" + owd="`pwd`" # old working directory + + # [----can ascend-----] && [-haven't found repo-] + while [ "$pwd" != "`pwd`" ] && [ ! -e "`pwd`/$repo" ]; do + pwd=`pwd` + cd .. + done + + if [ -e "`pwd`/$repo" ]; then + # we found a repository + echo "`pwd`/$repo" + else + # we didn't find a repository + _error "no $name repository found" + fi + cd "$owd" fi - cd "$owd" } # Modules ############################################################ _runcom() { + # exit states + # 0 - fine + # 1 - could not find command + # 2 - could not run command usage="usage: $RVS runcom COMMAND" command=${1?"$usage"}; shift if [ ! -e "$BINDIR/$command" ]; then - _error "cannot find command \`$command" + exit 1 else mkdir -p "$baseTMPDIR" export TMPDIR=`mktemp -d --tmpdir="$baseTMPDIR"` + if [ -z "RVS_LEVEL" ]; then + export RVS_LEVEL=0; + else + export RVS_LEVEL=`expr $RVS_LEVEL + 1` + fi + if [ -f "$BINDIR/$command" ]; then exec "$BINDIR/$command" $@ | tee "$TMPDIR/$command" elif [ -d "$BINDIR/$command" ]; then @@ -79,7 +91,7 @@ _runcom() { done cat "$TMPDIR/$command/$id" else - _error "cannot run \`$command'" + exit 2 fi rm -rf "$TMPDIR" fi @@ -98,13 +110,22 @@ _nextpriority() { ################################################################################ _init() { + # exit states: + # 0 - fine + # 1 - repo already exists + # 2 - error running init commands REPO=`_repo 2> /dev/null` if [ -z "$REPO" ]; then export REPO="`pwd`/.$name" install -d "$REPO" _runcom init + case "$?" in + 0) exit 0;; + 1) exit 0;; + 2) _error 'error running init scripts' 2;; + esac else - _error "repository already exists at \`$REPO'" + _error "repository already exists at \`$REPO'" 1 fi } @@ -158,7 +179,11 @@ case "$com" in if [ "$?" = '0' ]; then export REPO _runcom $@ - exit $? + case "$?" in + 0) exit 0;; + 1) _error "could not find command \`$1'" 1;; + 2) _error "could not run command \`$1'" 2;; + esac else exit 1 fi -- cgit v1.2.3-2-g168b