summaryrefslogtreecommitdiff
path: root/Hutch/Models
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-12 22:30:22 -0500
committerChristian Cleberg <[email protected]>2026-04-12 22:30:22 -0500
commit54d037548261c1546555a89a6a803b542a769880 (patch)
treec99bf489071d40e4acc0d99aae769abc8e614497 /Hutch/Models
parent7a875798fea9321bad2636040d9be2c30bc0fa8f (diff)
downloadhutch-54d037548261c1546555a89a6a803b542a769880.tar.gz
hutch-54d037548261c1546555a89a6a803b542a769880.tar.bz2
hutch-54d037548261c1546555a89a6a803b542a769880.zip
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
Diffstat (limited to 'Hutch/Models')
-rw-r--r--Hutch/Models/RepositorySummary.swift34
1 files changed, 34 insertions, 0 deletions
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: "")
+ }
+}