fix: use Mosaic credential loader for Gitea API token resolution
The broken `tea login list | awk '{print $NF}'` pattern extracted
the table border character instead of a token, causing pr-metadata.sh
to return empty fields (baseRefName, etc.) and breaking pr-merge.sh.
Centralizes get_remote_host and get_gitea_token in detect-platform.sh
with a 3-tier resolution: Mosaic credential loader (host→service
mapping) → GITEA_TOKEN env var → ~/.git-credentials file.
Removes duplicate local copies from 5 scripts that already source
detect-platform.sh.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -68,11 +68,10 @@ elif [[ "$PLATFORM" == "gitea" ]]; then
|
||||
|
||||
DIFF_URL="https://${HOST}/api/v1/repos/${OWNER}/${REPO}/pulls/${PR_NUMBER}.diff"
|
||||
|
||||
# Use tea's auth token if available
|
||||
TEA_TOKEN=$(tea login list 2>/dev/null | grep "$HOST" | awk '{print $NF}' || true)
|
||||
GITEA_API_TOKEN=$(get_gitea_token "$HOST" || true)
|
||||
|
||||
if [[ -n "$TEA_TOKEN" ]]; then
|
||||
DIFF_CONTENT=$(curl -sS -H "Authorization: token $TEA_TOKEN" "$DIFF_URL")
|
||||
if [[ -n "$GITEA_API_TOKEN" ]]; then
|
||||
DIFF_CONTENT=$(curl -sS -H "Authorization: token $GITEA_API_TOKEN" "$DIFF_URL")
|
||||
else
|
||||
DIFF_CONTENT=$(curl -sS "$DIFF_URL")
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user