summaryrefslogtreecommitdiff
path: root/Hutch/Views/Repositories/RepositoryRowView.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-03-22 20:42:58 -0500
committerChristian Cleberg <[email protected]>2026-03-22 20:42:58 -0500
commitcbf5f669abe126d4d508a8826c64b922963700c1 (patch)
treea77a483b71723d7ec51cbe4feb5786956283b885 /Hutch/Views/Repositories/RepositoryRowView.swift
parent82e54ad018ae5fa5cdf90c0d763e09e99bc0e933 (diff)
downloadhutch-cbf5f669abe126d4d508a8826c64b922963700c1.tar.gz
hutch-cbf5f669abe126d4d508a8826c64b922963700c1.tar.bz2
hutch-cbf5f669abe126d4d508a8826c64b922963700c1.zip
feat: context menus to copy clone URLs and commit SHAs
Diffstat (limited to 'Hutch/Views/Repositories/RepositoryRowView.swift')
-rw-r--r--Hutch/Views/Repositories/RepositoryRowView.swift27
1 files changed, 27 insertions, 0 deletions
diff --git a/Hutch/Views/Repositories/RepositoryRowView.swift b/Hutch/Views/Repositories/RepositoryRowView.swift
index f8fd205..f791494 100644
--- a/Hutch/Views/Repositories/RepositoryRowView.swift
+++ b/Hutch/Views/Repositories/RepositoryRowView.swift
@@ -1,4 +1,5 @@
import SwiftUI
+import UIKit
struct RepositoryRowView: View {
let repository: RepositorySummary
@@ -54,9 +55,35 @@ struct RepositoryRowView: View {
}
}
.padding(.vertical, 2)
+ .contextMenu {
+ Button {
+ UIPasteboard.general.string = httpsCloneURL(for: repository)
+ } label: {
+ Label("Copy HTTPS URL", systemImage: "doc.on.doc")
+ }
+
+ Button {
+ UIPasteboard.general.string = sshCloneURL(for: repository)
+ } label: {
+ Label("Copy SSH URL", systemImage: "terminal")
+ }
+ }
}
}
+private func httpsCloneURL(for repository: RepositorySummary) -> String {
+ let host = "\(repository.service.rawValue).sr.ht"
+ let owner = repository.owner.canonicalName
+ return "https://\(host)/\(owner)/\(repository.name)"
+}
+
+private func sshCloneURL(for repository: RepositorySummary) -> String {
+ let host = "\(repository.service.rawValue).sr.ht"
+ let user = repository.service == .hg ? "hg" : "git"
+ let owner = repository.owner.canonicalName
+ return "\(user)@\(host):\(owner)/\(repository.name)"
+}
+
private struct RepositoryBuildStatusIndicator: View {
let status: RepositoryBuildStatus