summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2017-09-04 15:57:13 -0400
committerMalf Furious <m@lfurio.us>2017-09-04 15:57:13 -0400
commit0ffd21d98bb9154007640ec01f843914792739c7 (patch)
tree2954fc19c55bf5fef22ba1d441f30f0fa6ef47a2
parentaac0803df3a8ac48400377756b74c830dc756c5d (diff)
downloadsystrunk-0ffd21d98bb9154007640ec01f843914792739c7.tar.gz
systrunk-0ffd21d98bb9154007640ec01f843914792739c7.zip
Move status op into repo-access mod
-rw-r--r--repo-access.sh45
-rw-r--r--status.sh44
2 files changed, 45 insertions, 44 deletions
diff --git a/repo-access.sh b/repo-access.sh
index b599dc8..477e7a9 100644
--- a/repo-access.sh
+++ b/repo-access.sh
@@ -191,3 +191,48 @@ function systr_init
mkdir refs revs
echo "NULL" >refs/HEAD
}
+
+##
+# 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
+{
+ if [[ "$MERG" != "NULL" ]]; then
+ mergcommit=$(systr_repo_resolve_reference "$MERG")
+
+ if [[ "$MERG" == "TRAC" ]]; then
+ echo "Update in progress, to $mergcommit"
+ else
+ echo "Merge in progress, from $MERG ($mergcommit)"
+ fi
+
+ echo ""
+ fi
+
+ traccommit=$(systr_repo_resolve_reference "$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
+
+ dist=$(systr_repo_commit_dist "$BASE" "$TRAC")
+
+ if [[ "$dist" == "0" ]]; then
+ echo "Up-to-date"
+ else
+ echo "Behind $dist commits"
+ fi
+}
diff --git a/status.sh b/status.sh
deleted file mode 100644
index 6b99eb5..0000000
--- a/status.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-##
-# 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=$(systr_repo_resolve_reference "$MERG")
-
- if [[ "$MERG" == "TRAC" ]]; then
- echo "Update in progress, to $mergcommit"
- else
- echo "Merge in progress, from $MERG ($mergcommit)"
- fi
-
- echo ""
- fi
-
- traccommit=$(systr_repo_resolve_reference "$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"
-}