diff options
Diffstat (limited to 'Hutch/Views/Repositories/RepositoryRowView.swift')
| -rw-r--r-- | Hutch/Views/Repositories/RepositoryRowView.swift | 27 |
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 |
