import Foundation /// `repo settings show` — admin-only view of the repo's control knobs. /// Every field is omitted at its zero value, so absent means default. nonisolated struct RepoSettings: Decodable, Sendable, Hashable { let protectedBranches: [String]? /// `path.Match` globs; a matching tag is created once and then /// refuses moves and deletion (v1.16.0). let protectedTags: [String]? let requireSignedCommits: Bool? let requireChecks: Bool? /// The checks the checks gate waits on by name; with none, every /// check reported on the head must pass (v1.37.0). let requiredContexts: [String]? let requireApprovals: Int? let requireResolved: Bool? let requireCodeowners: Bool? /// Protected branches take changes through merge requests only (v1.16.0). let requireMR: Bool? let gitDaemon: Bool? let archived: Bool? let website: String? enum CodingKeys: String, CodingKey { case protectedBranches = "protected_branches" case protectedTags = "protected_tags" case requireMR = "require_mr" case requireSignedCommits = "require_signed_commits" case requireChecks = "require_checks" case requiredContexts = "required_contexts" case requireApprovals = "require_approvals" case requireResolved = "require_resolved" case requireCodeowners = "require_codeowners" case gitDaemon = "git_daemon" case archived, website } var branches: [String] { protectedBranches ?? [] } var tags: [String] { protectedTags ?? [] } var contexts: [String] { requiredContexts ?? [] } } /// One row of `repo access list`: an account and its effective role. /// Since v1.16.0 the row says where the access comes from — owner, /// direct, org admin, org member, or team; only a direct grant can be /// revoked here. An older server lists direct grants and says nothing. nonisolated struct AccessGrant: Decodable, Sendable, Hashable, Identifiable { let user: String let role: String let source: String? var id: String { user } var isDirect: Bool { source == nil || source == "direct" } }