Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit b792539

Browse files
palminrnystrom
authored andcommitted
Allow showing/cloning repository in Working Copy when installed (#2366)
.../more button when looking at repository has extra action when Working Copy is installed to show or clone this repository in this app.
1 parent 0cf43b8 commit b792539

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Classes/Repository/RepositoryViewController.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ ContextMenuDelegate {
159159
.newIssue(issueController: newIssueViewController)
160160
}
161161

162+
func workingCopyAction() -> UIAlertAction? {
163+
guard let remote = self.repoUrl.absoluteString.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics) else { return nil}
164+
165+
guard let url = URL(string: "working-copy://show?remote=\(remote)") else { return nil }
166+
guard UIApplication.shared.canOpenURL(url) else { return nil }
167+
168+
let title = NSLocalizedString("Working Copy", comment: "")
169+
let action = UIAlertAction(title: title, style: .default,
170+
handler: { _ in
171+
UIApplication.shared.open(url)
172+
})
173+
return action
174+
}
175+
162176
@objc func onMore(sender: UIButton) {
163177
let alertTitle = "\(repo.owner)/\(repo.name):\(branch)"
164178
let alert = UIAlertController.configured(title: alertTitle, preferredStyle: .actionSheet)
@@ -173,6 +187,7 @@ ContextMenuDelegate {
173187
$0.popoverPresentationController?.setSourceView(sender)
174188
},
175189
switchBranchAction,
190+
workingCopyAction(),
176191
AlertAction.cancel()
177192
])
178193
alert.popoverPresentationController?.setSourceView(sender)

Resources/Info.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<key>LSApplicationQueriesSchemes</key>
5353
<array>
5454
<string>org-appextension-feature-password-management</string>
55+
<string>working-copy</string>
5556
</array>
5657
<key>LSRequiresIPhoneOS</key>
5758
<true/>

0 commit comments

Comments
 (0)