diff options
author | Malf Furious <m@lfurio.us> | 2017-09-03 16:32:01 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2017-09-03 16:32:01 -0400 |
commit | fa68505117215d5a49fa0a13bbc1ec5e07020138 (patch) | |
tree | ccdc49a18d7140d28e83e56415bef9eba4d6291c /checkout.sh | |
parent | 2f69a3efcef8df278fb37e42153124e2a5858604 (diff) | |
download | systrunk-fa68505117215d5a49fa0a13bbc1ec5e07020138.tar.gz systrunk-fa68505117215d5a49fa0a13bbc1ec5e07020138.zip |
Rewrite checkout mod to drop remote support
Also, refactored repo check to the repo-access mod.
Diffstat (limited to 'checkout.sh')
-rw-r--r-- | checkout.sh | 79 |
1 files changed, 20 insertions, 59 deletions
diff --git a/checkout.sh b/checkout.sh index 59cc82e..a3f9f9f 100644 --- a/checkout.sh +++ b/checkout.sh @@ -1,90 +1,51 @@ ## -# systr_check_repo <path> +# systr_init_wktree <path> # -# Assert that the local repository path exists and is valid. -## -function systr_check_repo -{ - if [ $# -lt 1 ]; then - echo "Fatal: too few arguments to systr_check_repo" - exit 1 - fi - - path="$1" - - ( - cd "$path" - - if [ ! -f "refs/HEAD" ]; then - echo "Fatal: $path is not a repository" - exit 1 - fi - ) -} - -## -# systr_init_wktree [<remote>] <path> -# -# Assert that the repository at <remote>:<path> exists, then setup -# the .systr directory at the CWD. +# Assert that the repository exists, then setup the .systr directory +# at the CWD. ## function systr_init_wktree { if [ $# -lt 1 ]; then - echo "Fatal: too few arguments to systr_init_wktree" + echo "Fatal: too few args to init_wktree" >&2 exit 1 fi - if [ $# -gt 1 ]; then - remote="$1" - shift - else - remote="" - fi - path="$1" + systr_repo_check "$path" - if [[ "$remote" == "" ]]; then - systr_check_repo "$path" - else - ssh "$remote" "systrunk check-repo \"$path\"" - fi - - mkdir -p .systr/ - - echo "$remote" >.systr/remote - echo "$path" >.systr/path - echo "NULL" >.systr/BASE - echo "NULL" >.systr/TRAC + mkdir .systr + echo "$path" >.systr/path + echo "NULL" >.systr/BASE + echo "NULL" >.systr/TRAC + date >.systr/updated echo "Setup worktree at $(pwd)" } ## -# systrunk checkout <version> [[<remote>] <path>] +# systrunk checkout <commit> [<path>] # -# Reset a worktree to the state at <version>. If <path> is given, -# checkout also initializes a new worktree at the CWD. If <remote> -# is given, the path is assumed to be located on a remote machine. -# While resetting to the state at <version>, all local uncommitted -# changes are lost. +# Reset a worktree to the state at <commit>. If <path> is given, +# checkout also initializes a new worktree at the CWD. While +# resetting to <commit>, all local uncommitted changes are lost. # -# After checkout, BASE and TRAC will be set to <version>. +# After checkout, BASE and TRAC will be set to <commit>. ## function systr_checkout { if [ $# -lt 1 ]; then - echo "Fatal: too few arguments to systr_checkout" + echo "Fatal: too few arguments to systr_checkout" >&2 exit 1 fi version="$1" if [ $# -gt 1 ]; then - shift - systr_init_wktree "$@" - read remote <.systr/remote - read path <.systr/path + systr_init_wktree "$2" + read path <.systr/path + read BASE <.systr/BASE + read TRAC <.systr/TRAC fi if [[ "$version" == "NULL" ]]; then |