Skip to content

A repo with no forge host checks gh auth against every host, about 6 s per PR lookup #172

Closed

Description

@eharriett0

Shape

In a repo whose origin is a local path (a scratch or test repo), RepoHost() returns "", so Authed() runs a bare gh auth status. That validates every host gh is logged in to. With github.com plus one enterprise host configured, it takes about 6 s here, against 0.2 s for gh auth status --hostname github.com.

Authed() is not cached, and PRForBranch calls it on every lookup. So wt clean in a scratch repo with two worktrees took 17 s, and a 17-step smoke of wt clean <name> (#171) took about 4 minutes per run.

A real repo is not affected in the same way: there the check is host-scoped (#100), and wt clean over 9 worktrees took 10 s.

Why it matters

Only a repo with no forge host hits this, but that is where wt's own e2e smokes run: the CLAUDE.md ship gate asks for a smoke against a scratch repo, and a bare local origin is the natural way to build one.

Suggestion

  • When RepoHost() is "", there is no forge to ask. Treat PR state as unresolvable without calling gh. Every lookup reaches that result anyway, because gh cannot resolve a repo from a local-path remote.
  • Cache Authed() for the process; it cannot change during one run.

⚠ If the first is done, check what wt doctor says for such a repo. Reporting "not authenticated" there would be the #100 shape again: a warning that cannot tell "you are broken" from "the check does not apply".

Measured on vHEAD-ce1002f

call time
gh auth status (bare, 2 hosts, rc 0) 6 s
gh auth status --hostname github.com 0.20 to 0.29 s
gh pr list --head <b> --state all 0.36 s
wt clean, scratch repo, 2 worktrees, local-path origin 17 s
wt clean, real repo, 9 worktrees 10 s

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions