Skip to content

T-4: GitCLI.listRemotes + WorktreeFeature state.remotes (cap 20) #218

@kirich1409

Description

@kirich1409

Description

Add to MacApp/Packages/WorktreeManager/Sources/WorktreeManager/GitCLI.swift:

func listRemotes(in repoPath: URL) async throws -> [GitRemoteEntry]

Implementation: run git remote -v, parse lines of form <name><TAB><url> (fetch|push). Keep only (fetch) rows, deduplicate by name.

In WorktreeFeature.State:

public var remotes: [GitRemoteEntry] = []

In .loadProject reducer flow, after loading worktrees, call gitCLI.listRemotes(in: project.path) → write to state.remotes. On unload → state.remotes = [].

Cap (rate-limit guard): if parsed list contains more than 20 entries with host == "github.com" (via GitRemote.parse), truncate github entries to first 20; keep all non-github entries.

Unit tests: empty output, single origin, multiple remotes, fetch+push dedup, non-github preserved, cap behavior.

Spec reference

See swarm-report/github-integration-decomposition.md#t-4. Cap=20 is a BA-review-driven rate-limit guard.

Relationships

Acceptance criteria

  • git remote -v with origin (fetch) + origin (push) → single GitRemoteEntry
  • Two distinct remotes (origin + upstream) → 2 entries
  • 25 github.com remotes → result has 20 github entries + all non-github preserved
  • WorktreeFeature.State.remotes populated on .loadProject, cleared on unload
  • TestStore: .loadProjectstate.remotes == expectedEntries
  • Unit tests in WorktreeManagerTests cover all parse cases
  • All existing WorktreeManager tests still pass

Complexity

M

Suggested agent

developer-workflow:swift-engineer

Module / Layer

WorktreeManager / Git integration

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions