summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 22:34:49 +0000
committertv <tv@krebsco.de>2026-11-21 22:34:49 +0000
commit7a9c9e3dc9739d786198d04538839a1cc711805b (patch)
tree896384cd8c0a07423b07edd4c89d5776d10e5836 /pkgs
parent6b1e7305c6f52705f817a024df136935ca88fa07 (diff)
pkgs/claude-inbox: REPO from the current directory, where one's needed
--push and --show without BRANCH (the graph) take the repository the current directory is in, when they get no REPO: by DIR as given, or else physically (cd -P), so symlinks don't matter, without git.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/claude-inbox.nix33
1 files changed, 30 insertions, 3 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix
index 6e0dd6e..2f1dc79 100644
--- a/pkgs/claude-inbox.nix
+++ b/pkgs/claude-inbox.nix
@@ -21,7 +21,9 @@ let
claude; BRANCH: one of claude's there, or without REPO, in the one
repository that has it (by the last fetch; --show fetches first). A
word that could be either is what makes sense of all the words, if
- exactly one reading does.
+ exactly one reading does. Where a command needs REPO and gets none
+ (--show without BRANCH, --push), it's the one the current directory
+ is in, if any.
--list [REPO] [--by-remote] fetches the repositories the VM has (ssh
HOST: its ~/src, but for symlinks), or just REPO, from their remote
claude, here in DIR, and shows the branches there with something
@@ -171,6 +173,28 @@ let
done
wait
}
+ # REPO, where a command needs one and got none: the one $PWD is in,
+ # in DIR, as given, or else physically (cd -P, pwd: builtins, no git)
+ repo_of_pwd() {
+ local here=$PWD p s n
+ for s in given physical; do
+ if test "$s" = given; then
+ s=$src p=$here
+ else
+ CDPATH= cd -P "$src" 2>/dev/null || return 1
+ s=$PWD
+ CDPATH= cd -P "$here" && p=$PWD
+ CDPATH= cd "$here"
+ fi
+ s=''${s%/}
+ case $p/ in
+ "$s"/?*)
+ n=''${p#"$s"/} n=''${n%%/*}
+ if is_repo "$n"; then name=$n; return 0; fi ;;
+ esac
+ done
+ return 1
+ }
# the words, as REPO (name) and BRANCH (b): every reading that exists,
# and it takes exactly one
resolve() {
@@ -227,11 +251,14 @@ let
test "$by" = repo || test "$cmd" = list || die "--by-remote is for --list"
case $cmd in
list) test -z "$b" || die "--list takes no BRANCH" ;;
- show) test -n "$name" || die "--show needs a REPO or BRANCH"
+ show) if test -z "$name"; then
+ repo_of_pwd || die "--show needs a REPO or BRANCH (or to be in a REPO)"
+ test -z "$fetch" || fetch_repos "$name"
+ fi
test -n "$b" || test -z "$diff" || die "--show --diff needs a BRANCH" ;;
take) test -n "$b" || die "--take needs a BRANCH"
test -z "$force" || test -z "$pick" || die "--take: --force or --pick, not both" ;;
- push) test -n "$name" || die "--push needs a REPO"
+ push) test -n "$name" || repo_of_pwd || die "--push needs a REPO (or to be in one)"
test -z "$b" || die "--push takes no BRANCH" ;;
esac
r=$src/$name