From cbf5f669abe126d4d508a8826c64b922963700c1 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Sun, 22 Mar 2026 20:42:58 -0500 Subject: feat: context menus to copy clone URLs and commit SHAs --- Hutch/Views/Repositories/RepositoryRowView.swift | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Hutch/Views/Repositories/RepositoryRowView.swift') 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 -- cgit v1.2.3