diff options
| author | Christian Cleberg <[email protected]> | 2026-03-17 23:19:43 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-03-17 23:19:43 -0500 |
| commit | 32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5 (patch) | |
| tree | ee36d421d704e508d5617d803b4c8cbdb4804fe1 /Hutch/Models/RepositorySummary.swift | |
| parent | 8f2057c53e9009c2529c9c4849c914666c0e4b40 (diff) | |
| download | hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.gz hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.tar.bz2 hutch-32ad6cab8d58d99ebd8a28e8fa6e6f4e587cb1e5.zip | |
v1.0
Diffstat (limited to 'Hutch/Models/RepositorySummary.swift')
| -rw-r--r-- | Hutch/Models/RepositorySummary.swift | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Hutch/Models/RepositorySummary.swift b/Hutch/Models/RepositorySummary.swift new file mode 100644 index 0000000..f4ecc6e --- /dev/null +++ b/Hutch/Models/RepositorySummary.swift @@ -0,0 +1,57 @@ +import Foundation + +/// Lightweight repository model matching the fields returned by the +/// repositories list query. Avoids optionalizing all fields on the full +/// `Repository` model. +struct RepositorySummary: Codable, Sendable, Identifiable, Hashable { + let id: Int + /// GraphQL resource identifier used by `repository(rid:)` queries. + let rid: String + let service: SRHTService + let name: String + let description: String? + let visibility: Visibility + let updated: Date + let owner: Entity + let head: Reference? + + enum CodingKeys: String, CodingKey { + case id, rid, service, name, description, visibility, updated, owner + case head = "HEAD" + } + + init( + id: Int, + rid: String, + service: SRHTService, + name: String, + description: String?, + visibility: Visibility, + updated: Date, + owner: Entity, + head: Reference? + ) { + self.id = id + self.rid = rid + self.service = service + self.name = name + self.description = description + self.visibility = visibility + self.updated = updated + self.owner = owner + self.head = head + } + + init(from decoder: any Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.id = try container.decode(Int.self, forKey: .id) + self.rid = try container.decode(String.self, forKey: .rid) + self.service = try container.decodeIfPresent(SRHTService.self, forKey: .service) ?? .git + self.name = try container.decode(String.self, forKey: .name) + self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.visibility = try container.decode(Visibility.self, forKey: .visibility) + self.updated = try container.decode(Date.self, forKey: .updated) + self.owner = try container.decode(Entity.self, forKey: .owner) + self.head = try container.decodeIfPresent(Reference.self, forKey: .head) + } +} |
