Commit 2ab41747b5
Unsigned
Layout: unified · split
Hutch/Views/Repositories/CommitRowView.swift +14
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import SwiftUI |
| 2 | import UIKit | |
| 2 | 3 | |
| 3 | 4 | struct CommitRowView: View { |
| 4 | 5 | let commit: CommitSummary |
| @@ -26,5 +27,18 @@ struct CommitRowView: View { | ||
| 26 | 27 | } |
| 27 | 28 | } |
| 28 | 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 @@ | ||
| 1 | 1 | import SwiftUI |
| 2 | import UIKit | |
| 2 | 3 | |
| 3 | 4 | struct RepositoryRowView: View { |
| 4 | 5 | let repository: RepositorySummary |
| @@ -54,9 +55,35 @@ struct RepositoryRowView: View { | ||
| 54 | 55 | } |
| 55 | 56 | } |
| 56 | 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 | |
| 74 | private 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 | ||
| 80 | private 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 | ||
| 60 | 87 | private struct RepositoryBuildStatusIndicator: View { |
| 61 | 88 | let status: RepositoryBuildStatus |
| 62 | 89 | |