summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commit.sh49
1 files changed, 26 insertions, 23 deletions
diff --git a/commit.sh b/commit.sh
index 1190715..b3d20f5 100644
--- a/commit.sh
+++ b/commit.sh
@@ -1,37 +1,40 @@
##
-# systr_record_commit_mesg <commit> [<mesg>]
+# systr_record_commit_mesg <commit> <branch> [<mesg>]
#
# Setup and present user with an editor to enter a commit message for
# the given commit ID. If <mesg> is given, that content will be the
-# default in the opened text file. Once user is finished, the file is
-# moved into the repository root, awaiting a call to systr_repo_finish_commit.
+# default in the opened file. If <branch> does not match TRAC, an
+# additional message will be given to the user, letting them know they
+# are committing to another branch. Once user is finished, the file
+# is moved into the repository root, awaiting a call to systr_repo_finish_commit.
##
function systr_record_commit_mesg
{
- if [ $# -eq 0 ]; then
- echo "Fatal: too few arguments to systr_record_commit_mesg"
+ if [ $# -lt 2 ]; then
+ echo "Fatal: too few args to record_commit_mesg" >&2
exit 1
fi
commit="$1"
+ branch="$2"
- if [ $# -gt 1 ]; then
- mesg="$2"
+ if [ $# -gt 2 ]; then
+ mesg="$3"
else
mesg=""
fi
echo "$mesg" >.systr/commit-edit-mesg.txt
echo "# --" >>.systr/commit-edit-mesg.txt
- systrunk status | sed 's/^/# /' >>.systr/commit-edit-mesg.txt
- vi .systr/commit-edit-mesg.txt
- sed '/^#/ d' <.systr/commit-edit-mesg.txt >.systr/commit.mesg
- if [[ "$remote" == "" ]]; then
- mv .systr/commit.mesg "$path/revs/$commit.mesg"
- else
- ssh "$remote" "systrunk message-commit \"$commit\"" <.systr/commit.mesg
+ if [[ "$branch" != "$TRAC" ]]; then
+ echo "# Committing to $branch" >>.systr/commit-edit-mesg.txt
+ echo "#" >>.systr/commit-edit-mesg.txt
fi
+
+ systrunk status | sed 's/^/# /' >>.systr/commit-edit-mesg.txt
+ vi .systr/commit-edit-mesg.txt
+ sed '/^#/ d' <.systr/commit-edit-mesg.txt >"$path/revs/$commit.mesg"
}
##
@@ -47,23 +50,23 @@ function systr_record_commit_mesg
##
function systr_commit
{
- if [ $# -ne 0 ]; then
+ if [ $# -gt 0 ]; then
branch="$1"
else
branch="$TRAC"
fi
if [[ "$branch" == "BASE" ]]; then
- echo "Fatal: bad branch name"
+ echo "Fatal: bad branch name BASE" >&2
exit 1
elif [[ "$branch" == "TRAC" ]]; then
- echo "Fatal: bad branch name"
+ echo "Fatal: bad branch name TRAC" >&2
exit 1
elif [[ "$branch" == "NULL" ]]; then
- echo "Fatal: bad branch name"
+ echo "Fatal: bad branch name NULL" >&2
exit 1
elif [[ "$branch" == "MERG" ]]; then
- echo "Fatal: bad branch name"
+ echo "Fatal: bad branch name MERG" >&2
exit 1
fi
@@ -71,18 +74,18 @@ function systr_commit
systr_repo_resolve_reference "$branch" >/dev/null 2>&1 || echo "Creating new branch $branch"
if [[ "$BASE" != "$branchcommit" ]]; then
- echo "Worktree is out-of-date, won't commit"
+ echo "Worktree is out-of-date, won't commit" >&2
exit 1
fi
commit=$(systr_repo_create_commit)
- systr_record_commit_mesg "$commit"
+ systr_record_commit_mesg "$commit" "$branch"
echo "Sending files..."
if [[ "$branchcommit" != "NULL" ]]; then
- systr_rsync_normal . "$path/revs/$commit" "../$branchcommit"
+ systr_rsync_normal . "$path/revs/$commit/" "../$branchcommit/"
else
- systr_rsync_normal . "$path/revs/$commit"
+ systr_rsync_normal . "$path/revs/$commit/"
fi
systr_repo_finish_commit "$commit" "$branchcommit"