Skip to content

T-1: GitRemote value type + parser in SharedModels #215

@kirich1409

Description

@kirich1409

Description

Add MacApp/Packages/SharedModels/Sources/SharedModels/GitRemote.swift:

public struct GitRemote: Sendable, Equatable, Codable {
    public let host: String
    public let owner: String
    public let repo: String
    public let `protocol`: GitRemote.Protocol
}

public extension GitRemote {
    enum Protocol: Sendable, Equatable, Codable { case ssh, https, scp }
    static func parse(_ url: String) -> GitRemote?
}

public struct GitRemoteEntry: Sendable, Equatable {
    public let name: String
    public let url: String
}

parse supports:

  • https://github.com/owner/repo.git
  • https://github.com/owner/repo
  • git@github.com:owner/repo.git
  • ssh://git@github.com/owner/repo.git
  • https://<token>@github.com/owner/repo.git
  • Repo names with dots (my.repo)
  • GHE hostnames parsed as-is (classification is done by GitHubFeature, not here)

GitRemoteEntry — raw name+url pair from git remote -v parsing (before URL classification).

Spec reference

See swarm-report/github-integration-decomposition.md#t-1 on branch feature/github-integration.

Relationships

Acceptance criteria

  • GitRemote.parse("https://github.com/owner/repo.git") → host/owner/repo match, protocol == .https
  • GitRemote.parse("git@github.com:owner/repo.git") → host/owner/repo match
  • GitRemote.parse("https://github.com/owner/my.repo")repo == "my.repo"
  • GitRemote.parse("https://example.com"), "", "not a url"nil
  • GitRemote.parse("https://ghe.acme.corp/owner/repo.git") → parses, host == "ghe.acme.corp"
  • All types Sendable, pure Swift 6 (no @preconcurrency)
  • swiftlint lint --strict green
  • Unit tests in SharedModelsTests cover all formats + invalid inputs
  • xcodebuild build + xcodebuild test green for Relay scheme

Complexity

S

Suggested agent

developer-workflow:swift-engineer

Module / Layer

SharedModels / Value types

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions