Commit 2ab41747b5

2ab41747b5f3fa2c72858d531b6b1dc07ddc2164

parent: 1d2287143b

Unsigned

cmc <hello@cleberg.net> · 2026-03-23 01:42 UTC

feat: context menus to copy clone URLs and commit SHAs

Layout: unified · split

Hutch/Views/Repositories/CommitRowView.swift +14
@@ -1,4 +1,5 @@
1import SwiftUI 1import SwiftUI
2import UIKit
2 3
3struct CommitRowView: View { 4struct CommitRowView: View {
4 let commit: CommitSummary 5 let commit: CommitSummary
@@ -26,5 +27,18 @@ struct CommitRowView: View {
26 } 27 }
27 } 28 }
28 .padding(.vertical, 2) 29 .padding(.vertical, 2)
30 .contextMenu {
31 Button {
32 UIPasteboard.general.string = commit.id
33 } label: {
34 Label("Copy Full SHA", systemImage: "doc.on.doc")
35 }
36
37 Button {
38 UIPasteboard.general.string = commit.shortId
39 } label: {
40 Label("Copy Short SHA", systemImage: "doc.on.doc.fill")
41 }
42 }
29 } 43 }
30} 44}
Hutch/Views/Repositories/RepositoryRowView.swift +27
@@ -1,4 +1,5 @@
1import SwiftUI 1import SwiftUI
2import UIKit
2 3
3struct RepositoryRowView: View { 4struct RepositoryRowView: View {
4 let repository: RepositorySummary 5 let repository: RepositorySummary
@@ -54,9 +55,35 @@ struct RepositoryRowView: View {
54 } 55 }
55 } 56 }
56 .padding(.vertical, 2) 57 .padding(.vertical, 2)
58 .contextMenu {
59 Button {
60 UIPasteboard.general.string = httpsCloneURL(for: repository)
61 } label: {
62 Label("Copy HTTPS URL", systemImage: "doc.on.doc")
63 }
64
65 Button {
66 UIPasteboard.general.string = sshCloneURL(for: repository)
67 } label: {
68 Label("Copy SSH URL", systemImage: "terminal")
69 }
70 }
57 } 71 }
58} 72}
59 73
74private func httpsCloneURL(for repository: RepositorySummary) -> String {
75 let host = "\(repository.service.rawValue).sr.ht"
76 let owner = repository.owner.canonicalName
77 return "https://\(host)/\(owner)/\(repository.name)"
78}
79
80private func sshCloneURL(for repository: RepositorySummary) -> String {
81 let host = "\(repository.service.rawValue).sr.ht"
82 let user = repository.service == .hg ? "hg" : "git"
83 let owner = repository.owner.canonicalName
84 return "\(user)@\(host):\(owner)/\(repository.name)"
85}
86
60private struct RepositoryBuildStatusIndicator: View { 87private struct RepositoryBuildStatusIndicator: View {
61 let status: RepositoryBuildStatus 88 let status: RepositoryBuildStatus
62 89