From 54d037548261c1546555a89a6a803b542a769880 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 12 Apr 2026 22:30:22 -0500 Subject: feat: add repo settings management Implements: https://todo.sr.ht/~ccleberg/hutch/42 Implements: https://todo.sr.ht/~ccleberg/hutch/43 Implements: https://todo.sr.ht/~ccleberg/hutch/44 --- Hutch/Models/RepositorySummary.swift | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Hutch/Models') diff --git a/Hutch/Models/RepositorySummary.swift b/Hutch/Models/RepositorySummary.swift index f4ecc6e..3821aa2 100644 --- a/Hutch/Models/RepositorySummary.swift +++ b/Hutch/Models/RepositorySummary.swift @@ -55,3 +55,37 @@ struct RepositorySummary: Codable, Sendable, Identifiable, Hashable { self.head = try container.decodeIfPresent(Reference.self, forKey: .head) } } + +extension RepositorySummary { + var defaultBranchName: String? { + head?.name.replacingOccurrences(of: "refs/heads/", with: "") + } + + func updating( + name: String? = nil, + description: String? = nil, + visibility: Visibility? = nil, + updated: Date? = nil, + head: Reference? = nil + ) -> RepositorySummary { + RepositorySummary( + id: id, + rid: rid, + service: service, + name: name ?? self.name, + description: description ?? self.description, + visibility: visibility ?? self.visibility, + updated: updated ?? self.updated, + owner: owner, + head: head ?? self.head + ) + } + + static func displayBranchName(for reference: Reference) -> String { + displayBranchName(for: reference.name) + } + + static func displayBranchName(for referenceName: String) -> String { + referenceName.replacingOccurrences(of: "refs/heads/", with: "") + } +} -- cgit v1.2.3