summaryrefslogtreecommitdiff
path: root/Hutch/Views/Repositories/RepositorySummarySupport.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-13 14:20:27 -0500
committerChristian Cleberg <[email protected]>2026-04-13 14:20:27 -0500
commit5e63048ab6a741ae947f7fe42efcb5206a3f3963 (patch)
treecf8eb2e3bc3b2edb20ef96a2599e684378120e5b /Hutch/Views/Repositories/RepositorySummarySupport.swift
parent0b84ecaf7ba0fb2cd3f3867da8dc732450b55b50 (diff)
downloadhutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.tar.gz
hutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.tar.bz2
hutch-5e63048ab6a741ae947f7fe42efcb5206a3f3963.zip
fix: mercurial parity and graphql handlingv3.0.4
- implements consistent UX between repo types - ensures centralized services and routes are used between repo types - graphql error handling is centralized - error messages are consistent Implements: https://todo.sr.ht/~ccleberg/hutch/58 Implements: https://todo.sr.ht/~ccleberg/hutch/59
Diffstat (limited to 'Hutch/Views/Repositories/RepositorySummarySupport.swift')
-rw-r--r--Hutch/Views/Repositories/RepositorySummarySupport.swift46
1 files changed, 46 insertions, 0 deletions
diff --git a/Hutch/Views/Repositories/RepositorySummarySupport.swift b/Hutch/Views/Repositories/RepositorySummarySupport.swift
index 7861b40..741ff39 100644
--- a/Hutch/Views/Repositories/RepositorySummarySupport.swift
+++ b/Hutch/Views/Repositories/RepositorySummarySupport.swift
@@ -46,6 +46,28 @@ func repositoryVisibilityLabel(_ visibility: Visibility) -> String {
}
}
+func repositoryForgeLabel(_ service: SRHTService) -> String {
+ switch service {
+ case .git:
+ return "GIT"
+ case .hg:
+ return "HG"
+ default:
+ return service.rawValue.uppercased()
+ }
+}
+
+func repositoryPrimaryBranchLabel(for repository: RepositorySummary, hgTipBranch: String? = nil) -> String? {
+ switch repository.service {
+ case .git:
+ return repository.defaultBranchName
+ case .hg:
+ return hgTipBranch ?? repository.defaultBranchName ?? "tip"
+ default:
+ return repository.defaultBranchName
+ }
+}
+
struct SummaryMetadataRow: View {
let icon: String
let title: String
@@ -85,3 +107,27 @@ struct SummaryDetailRow: View {
}
}
}
+
+struct RepositoryForgeBadge: View {
+ let service: SRHTService
+
+ var body: some View {
+ Text(repositoryForgeLabel(service))
+ .font(.caption2.weight(.medium))
+ .padding(.horizontal, 6)
+ .padding(.vertical, 2)
+ .background(color.opacity(0.15), in: Capsule())
+ .foregroundStyle(color)
+ }
+
+ private var color: Color {
+ switch service {
+ case .git:
+ .indigo
+ case .hg:
+ .cyan
+ default:
+ .secondary
+ }
+ }
+}