From 54a89c14243181e93881b5b88518681a3290b2d3 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 30 Aug 2017 02:12:53 -0400 Subject: Add log op --- main.sh | 2 ++ repo-access.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/main.sh b/main.sh index 86fcaff..957cc24 100644 --- a/main.sh +++ b/main.sh @@ -36,6 +36,8 @@ function main systr_commit "$@" elif [[ "$cmd" == "tag" ]]; then systr_repo_tag "$@" + elif [[ "$cmd" == "log" ]]; then + systr_repo_generate_log "$@" else echo "Fatal: $cmd not recognized" fi diff --git a/repo-access.sh b/repo-access.sh index 6e5b481..dbf1b58 100644 --- a/repo-access.sh +++ b/repo-access.sh @@ -44,3 +44,39 @@ function systr_repo_resolve_reference ssh "$remote" "systrunk resv-ref \"$symref\" \"$path\"" fi } + +## +# systrunk log [=BASE] +# +# View commit history. Generates a dump of all commits reachable +# from the given commit, or BASE if no argument given. Works for +# either local/remote repository. +## +function systr_repo_generate_log +{ + if [ $# -lt 1 ]; then + commit="$BASE" + else + commit=$(systr_repo_resolve_reference "$1") + fi + + if [[ "$remote" == "" ]]; then + while [[ "$commit" != "NULL" ]] + do + read date <"$path/revs/$commit/.date.systr" + read author <"$path/revs/$commit/.author.systr" + read email <"$path/revs/$commit/.email.systr" + + printf '%s %s\n' "$commit" "$date" + printf '%s %s\n' "$author" "$email" + echo "" + cat "$path/revs/$commit/.mesg.systr" + echo "" + echo "" + + read commit <"$path/revs/$commit/.commit.systr" + done + else + ssh "$remote" "systrunk log \"$commit\"" + fi +} -- cgit v1.2.3