From 34a65b5ca381eca7360eb51f6299326af8e6956d Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 10 Jun 2025 12:19:45 +0200 Subject: [PATCH] more swag --- justfile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/justfile b/justfile index bd3cc27..7f61e8c 100644 --- a/justfile +++ b/justfile @@ -736,6 +736,23 @@ remote-branch $remote_ref=`just _a_remote_branch origin | cut -d/ -f2-`: # TODO: onto release-xx.yy doesn't work # TODO: python-updates +checkout-commit-in-worktree $commit=`just _a_commit`: + #!/usr/bin/env -S bash -euo pipefail + [[ -n "${commit:-}" ]] + if [[ -d tmp/commit-"$commit" ]]; then + echo >&2 "Commit already checked out, cd'ing there..." + else + ( + cd master + $GIT worktree prune + # TODO: fetch the commit from upstream if it doesn't exist? + # TODO: support github /commit/ urls? + $GIT worktree add ../tmp/commit-"$commit" "$commit" + ) + fi + cd tmp/commit-"$commit" + exec just _enter_interactive_shell + @new-worktree *args: cd "$(just _new_worktree "$@")"; exec just _enter_interactive_shell @@ -1408,9 +1425,10 @@ _enter_interactive_shell *_: builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD" fi fi + # TODO: skip if no tty? # TODO: -l ? exec "$SHELL" "$@" - # TODO: go back to the old PWD here + # TODO: somehow report the old PWD here, will require i rethink the use of [no-cd] and maybe instead accept the new working dir via an argument # maintenance