Skip to content

Cache repo name with sync.Once to avoid extra gh subprocess on every fetch #95

@joshuacrass

Description

@joshuacrass

Problem:
Every call to FetchIssues and FetchIssue in internal/github/issues.go spawns a gh repo view --json nameWithOwner subprocess via repoOwnerName()FetchRepo(). At startup, with 3 parallel fetches (dashboard, issues, PRs), this fires 3–5 extra gh subprocesses beyond the actual data fetches. The repo name does not change during a hubcap session.

Solution:
Cache the result of repoOwnerName() / FetchRepo() after the first call using a sync.Once and package-level variables in the internal/github package. All subsequent calls return the cached value with no subprocess.

Acceptance Criteria:

  • gh repo view is called at most once per hubcap session
  • The cached value is used for all subsequent FetchIssues, FetchIssue, FetchPRs, and FetchPR calls
  • Concurrent callers are safe (no data race on the cached value)
  • go test -race ./... passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort:2Small effort (1-3 hours)priority:mediumMedium priority - fix when possibletype:performancePerformance improvement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions