gitea: fix token-name collision that swallowed the GitHub token prompt

generate-access-token used a fixed --token-name "sync", which Gitea
rejects on a second call for the same user (e.g. a retry against an
already-existing admin account, now common after the readiness-wait
fix). The failure was silent: it fell through to a manually-labeled
"Paste the Gitea token here" prompt appearing immediately before the
real "GitHub token:" prompt, so a pasted GitHub PAT could land on the
wrong prompt and leave GITHUB_TOKEN empty with no clear reason why.

Token name now includes a timestamp so it's always unique, and the
fallback prompt is relabeled to make clear it wants a Gitea token, not
the GitHub one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YEQNc4NfBST1m9NtCZVYa8
This commit is contained in:
Claude
2026-08-17 17:19:01 +00:00
parent 240fc78244
commit def70ab4e2
+7 -2
View File
@@ -356,15 +356,20 @@ EOF
log_success "Admin account created: $GITEA_ADMIN_USER"
fi
# Token name includes a timestamp so a retry against an account that
# already has a "sync" token from an earlier partial run (see the
# already-exists branch above) never collides — Gitea rejects a second
# token with a name that's already taken for that user, which used to
# silently fall through to the manual-paste prompt below on every retry.
local GITEA_TOKEN=""
GITEA_TOKEN="$(docker exec -u git gitea gitea admin user generate-access-token \
--username "$GITEA_ADMIN_USER" --token-name sync \
--username "$GITEA_ADMIN_USER" --token-name "sync-$(date +%s)" \
--scopes write:repository,write:user --raw 2>/dev/null)"
if [[ -z "$GITEA_TOKEN" ]]; then
log_warning "Automatic token generation didn't work (older Gitea image?) — generate one"
log_warning "by hand: log into http://localhost:${WEB_PORT} as $GITEA_ADMIN_USER, then"
log_warning "Settings -> Applications -> Generate New Token (repo + user write access)."
prompt_text " Paste the Gitea token here:" "" GITEA_TOKEN
prompt_text " Paste the GITEA token here (not the GitHub one — that's next):" "" GITEA_TOKEN
fi
# ── GitHub token ─────────────────────────────────────────────────────────