auth: defer credential helper until 401, match git's behaviour
main·
Commit

git-sync used to call git credential fill proactively whenever an HTTP
endpoint had no explicit auth. Two problems with that:
- On hosts the user had never authenticated against, git fell back to
an interactive
Username:/Password:prompt — turning git-sync into an interactive command and breaking non-interactive runs (issue #63). - For hosts where the helper did have credentials, we'd send a token to public repos that didn't need one — leaking a credential to a request the server hadn't actually challenged.
This change makes git-sync follow git's own HTTP auth flow:
auth.Resolveno longer consults the credential helper. Anonymous (or explicit token / Entire DB token) is what comes back.HTTPConngains aCredentialHelperinterface. On a 401 it callsLookup, retries the request with the returned credentials, and stores the auth on the conn so follow-upPostRPCcalls reuse it.auth.GitCredentialHelpershells out togit credential fill / approve / rejectwithGIT_TERMINAL_PROMPT=0, so a misconfigured helper fails fast rather than blocking on a tty prompt.- On a successful retry we tell the helper
approve; on 401 or 403 (Cloudflare-style "Invalid or expired token") we tell itrejectso stale credentials self-heal across runs.
Tests cover the full lifecycle: anonymous success skips the helper, 401 triggers Lookup + retry + Approve, retry-still-401 and retry-403 both trigger Reject, helper-with-no-credentials surfaces the original 401 cleanly, and explicit auth disables the helper fallback entirely.
Closes #63.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com Entire-Checkpoint: 84b7af2c6388
Checkpoints
can you take a look at https://github.com/entireio/git-sync/issues/63
Claude CodeOpus 4.7[1m]
View sessionCheckpoint 1