diff options
author | Malf Furious <m@lfurio.us> | 2017-09-01 04:25:23 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-09-01 04:25:23 -0400 |
commit | 587bde913d67b67d6d7e1fcb8b133a35e0606125 (patch) | |
tree | 7fbcab9855d52b1eab11586a6a462ff7a506db96 | |
parent | 54a89c14243181e93881b5b88518681a3290b2d3 (diff) | |
download | systrunk-587bde913d67b67d6d7e1fcb8b133a35e0606125.tar.gz systrunk-587bde913d67b67d6d7e1fcb8b133a35e0606125.zip |
Rewrite repo-access mod to drop remote support
Also added init op
-rw-r--r-- | repo-access.sh | 96 |
1 files changed, 53 insertions, 43 deletions
diff --git a/repo-access.sh b/repo-access.sh index dbf1b58..6f6bf74 100644 --- a/repo-access.sh +++ b/repo-access.sh @@ -1,58 +1,47 @@ ## -# systr_repo_resolve_reference <symref> [<path>] +# systr_repo_resolve_reference <ref> # -# Resolve a revision to a commit ID. This function is polymorphic -# for both local and remote repositories. The result is printed to +# Resolve a revision name to a commit ID. The result is printed to # stdout. ## function systr_repo_resolve_reference { if [ $# -lt 1 ]; then - echo "Fatal: too few arguments to systr_repo_resolve_reference" + echo "Fatal: too few args to repo_resolve_reference" >&2 exit 1 fi - symref="$1" + ref="$1" - if [ $# -gt 1 ]; then - path="$2" - fi - - if [[ "$symref" == "BASE" ]]; then - cat ".systr/BASE" - elif [[ "$symref" == "TRAC" ]]; then - read trac <.systr/TRAC - systr_repo_resolve_reference "$trac" - elif [[ "$symref" == "NULL" ]]; then + if [[ "$ref" == "BASE" ]]; then + cat .systr/BASE + elif [[ "$ref" == "TRAC" ]]; then + systr_repo_resolve_reference "$TRAC" + elif [[ "$ref" == "NULL" ]]; then echo "NULL" - elif [[ "$remote" == "" ]]; then + else ( cd "$path" - if [[ "$symref" == "HEAD" ]]; then - cat "refs/HEAD" - elif [ -f "refs/$symref" ]; then - cat "refs/$symref" - elif [ -f "revs/$symref/.commit.systr" ]; then - echo "$symref" + if [ -f "refs/$ref" ]; then + cat "refs/$ref" + elif [ -f "revs/$ref/.commit.systr" ]; then + echo "$ref" else - echo "$symref not a revision" >&2 + echo "$ref is not a revision" >&2 exit 1 fi ) - else - ssh "$remote" "systrunk resv-ref \"$symref\" \"$path\"" fi } ## # systrunk log [<commit>=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. +# View commit history. Generate a dump of all commits reachable +# from the given commit, or BASE if no argument is given. ## -function systr_repo_generate_log +function systr_log { if [ $# -lt 1 ]; then commit="$BASE" @@ -60,23 +49,44 @@ function systr_repo_generate_log 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" + while [[ "$commit" != "NULL" ]] + do + ( + cd "$path/revs/$commit/" + + read date <.date.systr + read author <.author.systr + read email <.email.systr - printf '%s %s\n' "$commit" "$date" - printf '%s %s\n' "$author" "$email" - echo "" - cat "$path/revs/$commit/.mesg.systr" + printf '%s %s\n' "$commit" "$date" + printf '%s <%s>\n\n' "$author" "$email" + cat .mesg.systr echo "" echo "" + ) - read commit <"$path/revs/$commit/.commit.systr" - done - else - ssh "$remote" "systrunk log \"$commit\"" + read commit <"$path/revs/$commit/.commit.systr" + done +} + +## +# systrunk init <name> +# +# Initialize a repository called "<name>.systr" in the current +# directory. +## +function systr_init +{ + if [ $# -lt 1 ]; then + echo "Fatal: too few args to init" >&2 + exit 1 fi + + name="$1" + + mkdir "$name.systr" + cd "$name.systr" + + mkdir refs revs + echo "NULL" >refs/HEAD } |