fix(dev): restore shared worktree identity from keyring (#2400)

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1067mpdna4vy22u9eltmmhtdfw56kww6ve2aze025dtfm4pxg07nqztjfhm <7ebdb0b67dab08a570b9faf7bbada97535673b4ccaba2cbd546ad3ba84c87fa6@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
Will Pfleger
2026-07-22 14:25:04 -04:00
committed by GitHub
co-authored by npub1067mpdna4vy22u9eltmmhtdfw56kww6ve2aze025dtfm4pxg07nqztjfhm
parent 25f631870e
commit d3757f5115
+27 -5
View File
@@ -47,14 +47,36 @@ if git rev-parse --is-inside-work-tree &>/dev/null; then
# identifier is kept so concurrent instances don't collide on
# tauri-plugin-single-instance or the app data directory.
if [[ "${BUZZ_SHARE_IDENTITY:-0}" == "1" ]]; then
KEYRING_SERVICE="buzz-desktop-dev"
KEYRING_BLOB=""
case "$(uname -s)" in
Darwin)
if command -v security &>/dev/null; then
KEYRING_BLOB="$(security find-generic-password -s "$KEYRING_SERVICE" -a secrets -w 2>/dev/null || true)"
fi
;;
Linux)
if command -v secret-tool &>/dev/null; then
KEYRING_BLOB="$(secret-tool lookup service "$KEYRING_SERVICE" username secrets target default 2>/dev/null || true)"
fi
;;
esac
KEYRING_IDENTITY="$(printf '%s' "$KEYRING_BLOB" | python3 -c 'import json, sys; value = json.load(sys.stdin).get("identity", ""); print(value if isinstance(value, str) else "")' 2>/dev/null || true)"
CANONICAL_KEY="$HOME/Library/Application Support/xyz.block.buzz.app.dev/identity.key"
LEGACY_CANONICAL_KEY="$HOME/Library/Application Support/xyz.block.sprout.app.dev/identity.key"
if [[ -f "$CANONICAL_KEY" ]]; then
export BUZZ_PRIVATE_KEY="$(cat "$CANONICAL_KEY")"
elif [[ -f "$LEGACY_CANONICAL_KEY" ]]; then
export BUZZ_PRIVATE_KEY="$(cat "$LEGACY_CANONICAL_KEY")"
SHARED_IDENTITY="$KEYRING_IDENTITY"
if [[ -z "$SHARED_IDENTITY" && -f "$CANONICAL_KEY" ]]; then
SHARED_IDENTITY="$(cat "$CANONICAL_KEY")"
elif [[ -z "$SHARED_IDENTITY" && -f "$LEGACY_CANONICAL_KEY" ]]; then
SHARED_IDENTITY="$(cat "$LEGACY_CANONICAL_KEY")"
fi
if [[ -n "$SHARED_IDENTITY" ]]; then
export BUZZ_PRIVATE_KEY="$SHARED_IDENTITY"
else
echo "⚠ BUZZ_SHARE_IDENTITY=1 but no identity found at $CANONICAL_KEY or $LEGACY_CANONICAL_KEY — run Buzz from repo root first" >&2
echo "⚠ BUZZ_SHARE_IDENTITY=1 but no identity found in keyring service $KEYRING_SERVICE, at $CANONICAL_KEY, or at $LEGACY_CANONICAL_KEY — run Buzz from repo root first" >&2
fi
fi