diff options
author | Malf Furious <m@lfurio.us> | 2017-08-27 23:57:46 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-08-27 23:57:46 -0400 |
commit | dabb5901c5d635003c6f3fefc4afedfeee45dc05 (patch) | |
tree | de0db9a865800d7b9c5e49c9b8ae01135bd4ce38 | |
parent | 51ab1973315de06d71064b9fe6e2cc97ee4d3768 (diff) | |
download | systrunk-dabb5901c5d635003c6f3fefc4afedfeee45dc05.tar.gz systrunk-dabb5901c5d635003c6f3fefc4afedfeee45dc05.zip |
Rewrite commit module
Updated the commit command and brought it into the make script
-rw-r--r-- | commit.sh | 102 | ||||
-rwxr-xr-x | make.sh | 2 |
2 files changed, 47 insertions, 57 deletions
@@ -1,13 +1,37 @@ ## -# creat_commit_dir_local +# systr_record_commit_mesg <commit> [<mesg>] # -# Create new commit directory, and assign its commit ID. Commit ID is -# printed to stdout. +# 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. ## -function creat_commit_dir_local +function systr_record_commit_mesg { - cd "$path" - mktemp -d XXXXXXXX + if [ $# -eq 0 ]; then + echo "Fatal: too few arguments to systr_record_commit_mesg" + exit 1 + fi + + commit="$1" + + if [ $# -gt 1 ]; then + mesg="$2" + 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 + fi } ## @@ -23,67 +47,33 @@ function creat_commit_dir_local ## function systr_commit { - read remote <.systr/remote - read path <.systr/path - read BASE <.systr/BASE - read TRAC <.systr/TRAC - - if [ $# -gt 1 ]; then - branch=$2 + if [ $# -ne 0 ]; then + branch=$1 else branch="$TRAC" fi - branchcommit=$(get_commit "$branch") || branchcommit="$BASE" + branchcommit=$(systr_repo_resolve_reference "$branch") || branchcommit="$BASE" if [[ "$BASE" != "$branchcommit" ]]; then echo "Worktree is out-of-date, won't commit" - exit + exit 1 fi - # local repository # - if [[ "$remote" == "" ]]; then - newcommit=$(creat_commit_dir_local) - mesgfile=$(mktemp -t systr-edit-mesg.XXXXXX) - echo "" >$mesgfile - echo "# --" >>$mesgfile - systrunk status | sed 's/^/# /' >>$mesgfile - vi $mesgfile - - echo "Sending files..." - - rsync -az --info=progress2 --info=stats2 \ - --delete --exclude='*.systr' \ - --link-dest="$path/$branchcommit/" \ - . "$path/$newcommit/" - - sed '/^#/ d' <$mesgfile >"$path/$newcommit/.mesg.systr" - echo "$branchcommit" >"$path/$newcommit/.commit.systr" + commit=$(systr_repo_create_commit) + systr_record_commit_mesg "$commit" + echo "Sending files..." + systr_rsync_normal . "$path/revs/$commit" "../$branchcommit" + systr_repo_finish_commit "$commit" "$branchcommit" + echo "$commit" >.systr/BASE - if [ -f ".systr/author" ]; then - cat .systr/author >"$path/$newcommit/.author.systr" - else - echo "Anonymous" >"$path/$newcommit/.author.systr" - fi - - if [ -f ".systr/email" ]; then - cat .systr/email >"$path/$newcommit/.email.systr" - else - echo "<anon>" >"$path/$newcommit/.email.systr" - fi - - echo "$newcommit" >"$path/$branch" - echo "$newcommit" >.systr/BASE - - if [[ "$TRAC" == "$BASE" ]]; then - echo "$newcommit" >.systr/TRAC - else - echo "$branch" >.systr/TRAC - fi + if [[ "$branch" != "$branchcommit" ]]; then + systr_repo_set_reference "$branch" "$commit" + fi - # remote repository # + if [[ "$TRAC" == "$BASE" ]]; then + echo "$commit" >.systr/TRAC else - exit - + echo "$branch" >.systr/TRAC fi } @@ -1,4 +1,4 @@ #!/usr/bin/bash echo "#!/usr/bin/bash -e" >systrunk -cat rsync.sh repo-access.sh repo-mutate.sh checkout.sh status.sh main.sh >>systrunk +cat rsync.sh repo-access.sh repo-mutate.sh checkout.sh commit.sh status.sh main.sh >>systrunk chmod +x systrunk |