From d919e18488c196caf7a8ea7a8db9bd7dc75995d0 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Sat, 29 Apr 2017 20:39:25 -0400 Subject: Add status module --- main.sh | 2 ++ status.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 status.sh diff --git a/main.sh b/main.sh index e26e724..2de2582 100644 --- a/main.sh +++ b/main.sh @@ -15,6 +15,8 @@ function main if [[ "$1" == "checkout" ]]; then systr_checkout $@ + elif [[ "$1" == "status" ]]; then + systr_status $@ else echo "Error: $1 not recognized" fi diff --git a/status.sh b/status.sh new file mode 100644 index 0000000..893dde2 --- /dev/null +++ b/status.sh @@ -0,0 +1,44 @@ +## +# systrunk status +# +# View current information such as which branch your worktree is +# TRACking, which commit it is BASEd on, and how far out-of-date +# it is. Additionally, report whether a merge or update operation +# is currently in-progress. +## +function systr_status +{ + read remote <.systr/remote + read path <.systr/path + read BASE <.systr/BASE + read TRAC <.systr/TRAC + + if [ -f ".systr/MERG" ]; then + read MERG <.systr/MERG + mergcommit=$(get_commit "$MERG") + + if [[ "$MERG" == "TRAC" ]]; then + echo "Update in progress, to $mergcommit" + else + echo "Merge in progress, from $MERG ($mergcommit)" + fi + + echo "" + fi + + traccommit=$(get_commit "$TRAC") + + if [[ "$TRAC" == "$traccommit" ]]; then + echo "Not tracking any branch" + else + echo "Tracking $TRAC ($traccommit)" + fi + + if [[ "$BASE" == "NULL" ]]; then + echo "BASE unset" + else + echo "BASE at $BASE" + fi + + echo "# TODO # Possibly, Up-to-date" +} -- cgit v1.2.3