krz/hutch

an ios client for sourcehut

clone: git clone https://gitbay.org/krz/hutch.git

cbf5f669abe126d4d508a8826c64b922963700c1

verified · cmc

author: Christian Cleberg <hello@cleberg.net> · 2026-03-23T01:42:58Z

feat: context menus to copy clone URLs and commit SHAs
 Hutch/Views/Repositories/CommitRowView.swift     | 14 ++++++++++++
 Hutch/Views/Repositories/RepositoryRowView.swift | 27 ++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/Hutch/Views/Repositories/CommitRowView.swift b/Hutch/Views/Repositories/CommitRowView.swift
index b5eb31d..362ab4d 100644
--- a/Hutch/Views/Repositories/CommitRowView.swift
+++ b/Hutch/Views/Repositories/CommitRowView.swift
@@ -1,4 +1,5 @@
 import SwiftUI
+import UIKit
 
 struct CommitRowView: View {
     let commit: CommitSummary
@@ -26,5 +27,18 @@ struct CommitRowView: View {
             }
         }
         .padding(.vertical, 2)
+        .contextMenu {
+            Button {
+                UIPasteboard.general.string = commit.id
+            } label: {
+                Label("Copy Full SHA", systemImage: "doc.on.doc")
+            }
+
+            Button {
+                UIPasteboard.general.string = commit.shortId
+            } label: {
+                Label("Copy Short SHA", systemImage: "doc.on.doc.fill")
+            }
+        }
     }
 }
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