summaryrefslogtreecommitdiffstats
path: root/repo-mutate.sh
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-09-04 00:03:23 -0400
committerMalf Furious <m@lfurio.us>2017-09-04 00:03:23 -0400
commitaac0803df3a8ac48400377756b74c830dc756c5d (patch)
treea6a7989ab68a1b0551d162d3a7dc1258ad1347b2 /repo-mutate.sh
parentfa68505117215d5a49fa0a13bbc1ec5e07020138 (diff)
downloadsystrunk-aac0803df3a8ac48400377756b74c830dc756c5d.tar.gz
systrunk-aac0803df3a8ac48400377756b74c830dc756c5d.zip
Rewrite repo-mutate mod to drop remote support
Diffstat (limited to 'repo-mutate.sh')
-rw-r--r--repo-mutate.sh89
1 files changed, 31 insertions, 58 deletions
diff --git a/repo-mutate.sh b/repo-mutate.sh
index f2f90dd..aa71ca4 100644
--- a/repo-mutate.sh
+++ b/repo-mutate.sh
@@ -1,40 +1,29 @@
##
-# systr_repo_create_commit [<path>]
+# systr_repo_create_commit
#
-# Create a new commit directory within the repository. This function
-# is polymorphic for both local and remote repositories. The new
+# Create a new commit directory within the repository. The new
# commit ID is printed to stdout.
##
function systr_repo_create_commit
{
- if [ $# -gt 0 ]; then
- path="$1"
- fi
-
- if [[ "$remote" == "" ]]; then
- (
- cd "$path"
- cd "revs/"
- mktemp -d XXXXXXXX
- )
- else
- ssh "$remote" "systrunk create-commit \"$path\""
- fi
+ (
+ cd "$path/revs/"
+ mktemp -d XXXXXXXX
+ )
}
##
# systr_repo_finish_commit <commit> <parent> [<merge>]
#
# Finish writing a commit by adding meta-data to the commit directory.
-# The commit mesasge is taken from the file <commit>.mesg at the root
+# The commit message is taken from the file <commit>.mesg at the root
# of the repository directory. If <merge> is given, it is written to
-# .merge.systr in the commit. This function is polymorphic for both
-# local and remote repositories.
+# .merge.systr in the commit.
##
function systr_repo_finish_commit
{
if [ $# -lt 2 ]; then
- echo "Fatal: too few arguments to systr_repo_finish_commit"
+ echo "Fatal: too few args to repo_finish_commit" >&2
exit 1
fi
@@ -56,76 +45,60 @@ function systr_repo_finish_commit
if [ -f ".systr/email" ]; then
read email <.systr/email
else
- email="<anon>"
+ email="anon"
fi
- if [[ "$remote" == "" ]]; then
- (
- cd "$path"
- cd "revs/"
- cd "$commit"
+ (
+ cd "$path/revs/$commit/"
- echo "$parent" >.commit.systr
- echo "$author" >.author.systr
- echo "$email" >.email.systr
- date >.date.systr
+ echo "$parent" >.commit.systr
+ echo "$author" >.author.systr
+ echo "$email" >.email.systr
+ date >.date.systr
- mv "../$commit.mesg" ".mesg.systr"
+ mv "../$commit.mesg" .mesg.systr
- if [[ "$merge" != "" ]]; then
- echo "$merge" >.merge.systr
- fi
- )
- else
- ssh "$remote" "systrunk finish-commit \"$commit\" \"$parent\" \
- \"$author\" \"$email\" \"$merge\""
- fi
+ if [[ "$merge" != "" ]]; then
+ echo "$merge" >.merge.systr
+ fi
+ )
}
##
# systr_repo_set_reference <symref> <commit>
#
# Update <symref> to point to <commit>. If <symref> doesn't exist,
-# it is created. This function is polymorphic for both local and
-# remote repositories.
+# it is created. <commit> should not, itself, be a symbolic reference.
##
function systr_repo_set_reference
{
if [ $# -lt 2 ]; then
- echo "Fatal: too few arguments to systr_repo_set_reference"
+ echo "Fatal: too few args to repo_set_reference" >&2
exit 1
fi
symref="$1"
- commit="$2"
+ commit=$(systr_repo_resolve_reference "$2")
if [[ "$symref" == "BASE" ]]; then
- echo "Fatal: will not define BASE in the repository"
+ echo "Fatal: will not define BASE in the repository" >&2
exit 1
elif [[ "$symref" == "TRAC" ]]; then
- echo "Fatal: will not define TRAC in the repository"
+ echo "Fatal: will not define TRAC in the repository" >&2
exit 1
elif [[ "$symref" == "NULL" ]]; then
- echo "Fatal: will not define NULL in the repository"
+ echo "Fatal: will not define NULL in the repository" >&2
exit 1
elif [[ "$symref" == "MERG" ]]; then
- echo "Fatal: will not define MERG in the repository"
+ echo "Fatal: will not define MERG in the repository" >&2
exit 1
fi
- if [[ "$remote" == "" ]]; then
- (
- cd "$path"
- cd "refs/"
- echo "$commit" >"$symref"
- )
- else
- ssh "$remote" "systrunk set-ref \"$symref\" \"$commit\""
- fi
+ echo "$commit" >"$path/refs/$symref"
}
##
-# systr_repo_tag <name>
+# systrunk tag <name>
#
# Tag the current commit. This creates a new branch which references
# BASE.
@@ -133,7 +106,7 @@ function systr_repo_set_reference
function systr_repo_tag
{
if [ $# -lt 1 ]; then
- echo "Fatal: too few arguments to systr_repo_tag"
+ echo "Fatal: too few args to repo_tag" >&2
exit 1
fi