fix: secrets which prints full .secrets-store path (v0.1.0.1)
_find_secrets_store_file used to set _LAST_FOUND_AT inside the $(...) subshell that resolve_store invoked it from, so the parent shell never received the value and `secrets which` reported `source: .secrets-store file ()` with empty parens. Function now returns a tab-separated <dir>\t<source-path> tuple; resolve_store splits it in the parent shell. Caught by /land-and-deploy post-merge fresh-clone verification — the existing test grepped for the substring ".secrets-store file" which matched the broken truncated form. Tightened to assert the full file path appears in the parenthetical. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
09a7bdcc46
commit
1bb729f73b
4 changed files with 20 additions and 6 deletions
13
secrets
13
secrets
|
|
@ -159,7 +159,10 @@ _parse_secrets_store_file() {
|
|||
# Walk up from cwd looking for .secrets-store. Bounded by $HOME — never
|
||||
# walks INTO or PAST $HOME. If cwd is outside $HOME entirely (e.g. /tmp),
|
||||
# the walk does not run. Symlinks are resolved with `cd -P`.
|
||||
# On success: prints expanded store dir, sets _LAST_FOUND_AT, returns 0.
|
||||
# On success: prints "<expanded-store-dir>\t<source-file-path>" and returns 0.
|
||||
# The caller (resolve_store) splits the tab-separated tuple. We can't set a
|
||||
# parent-shell variable from here because we're typically called inside
|
||||
# `$(...)` command substitution, which runs in a subshell.
|
||||
_find_secrets_store_file() {
|
||||
local dir
|
||||
dir=$(pwd -P 2>/dev/null) || dir="$PWD"
|
||||
|
|
@ -183,8 +186,7 @@ _find_secrets_store_file() {
|
|||
if content=$(_parse_secrets_store_file "$dir/.secrets-store"); then
|
||||
local expanded
|
||||
expanded=$(_expand_store_path "$content")
|
||||
_LAST_FOUND_AT="$dir/.secrets-store"
|
||||
printf '%s\n' "$expanded"
|
||||
printf '%s\t%s\n' "$expanded" "$dir/.secrets-store"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
|
@ -204,7 +206,10 @@ resolve_store() {
|
|||
resolved=$(_expand_store_path "$STORE_OVERRIDE")
|
||||
source="--store flag"
|
||||
_LAST_FOUND_AT=""
|
||||
elif resolved=$(_find_secrets_store_file); then
|
||||
elif _find_result=$(_find_secrets_store_file); then
|
||||
# _find_secrets_store_file returns "<dir>\t<source-file-path>"
|
||||
resolved="${_find_result%%$'\t'*}"
|
||||
_LAST_FOUND_AT="${_find_result#*$'\t'}"
|
||||
source=".secrets-store file ($_LAST_FOUND_AT)"
|
||||
elif [ -n "${_USER_SECRETS_DIR:-}" ]; then
|
||||
resolved="$_USER_SECRETS_DIR"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue