Fix #173
This commit is contained in:
parent
43ff63e01d
commit
5439ad0f5b
1 changed files with 21 additions and 17 deletions
|
|
@ -98,8 +98,9 @@ class GitServerSettingTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
// Remember git credential password/passphrase temporarily, ask whether users want this after a successful clone.
|
// Remember git credential password/passphrase temporarily, ask whether users want this after a successful clone.
|
||||||
SharedDefaults[.isRememberGitCredentialPassphraseOn] = true
|
SharedDefaults[.isRememberGitCredentialPassphraseOn] = true
|
||||||
|
let group = DispatchGroup()
|
||||||
let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
let dispatchQueue = DispatchQueue.global(qos: .userInitiated)
|
||||||
dispatchQueue.async {
|
dispatchQueue.async(group: group) {
|
||||||
do {
|
do {
|
||||||
try self.passwordStore.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
|
try self.passwordStore.cloneRepository(remoteRepoURL: URL(string: gitRepostiroyURL)!,
|
||||||
credential: gitCredential,
|
credential: gitCredential,
|
||||||
|
|
@ -111,16 +112,28 @@ class GitServerSettingTableViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
checkoutProgressBlock: { (path, completedSteps, totalSteps) in
|
checkoutProgressBlock: { (path, completedSteps, totalSteps) in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async { SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "CheckingOutBranch".localize(branchName))
|
||||||
SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "CheckingOutBranch".localize(branchName))
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} catch {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
SharedDefaults[.gitURL] = URL(string: gitRepostiroyURL)
|
let error = error as NSError
|
||||||
SharedDefaults[.gitUsername] = username
|
var message = error.localizedDescription
|
||||||
SharedDefaults[.gitBranchName] = branchName
|
if let underlyingError = error.userInfo[NSUnderlyingErrorKey] as? NSError {
|
||||||
SharedDefaults[.gitAuthenticationMethod] = auth
|
message = "\(message)\n\("UnderlyingError".localize()): \(underlyingError.localizedDescription)"
|
||||||
SVProgressHUD.dismiss()
|
}
|
||||||
|
Utils.alert(title: "Error".localize(), message: message, controller: self, completion: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group.notify(queue: dispatchQueue) {
|
||||||
|
NSLog("clone done")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
SharedDefaults[.gitURL] = URL(string: gitRepostiroyURL)
|
||||||
|
SharedDefaults[.gitUsername] = username
|
||||||
|
SharedDefaults[.gitBranchName] = branchName
|
||||||
|
SharedDefaults[.gitAuthenticationMethod] = auth
|
||||||
|
SVProgressHUD.dismiss {
|
||||||
let savePassphraseAlert = UIAlertController(title: "Done".localize(), message: "WantToSaveGitCredential?".localize(), preferredStyle: UIAlertController.Style.alert)
|
let savePassphraseAlert = UIAlertController(title: "Done".localize(), message: "WantToSaveGitCredential?".localize(), preferredStyle: UIAlertController.Style.alert)
|
||||||
// no
|
// no
|
||||||
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
|
savePassphraseAlert.addAction(UIAlertAction(title: "No".localize(), style: UIAlertAction.Style.default) { _ in
|
||||||
|
|
@ -136,15 +149,6 @@ class GitServerSettingTableViewController: UITableViewController {
|
||||||
})
|
})
|
||||||
self.present(savePassphraseAlert, animated: true, completion: nil)
|
self.present(savePassphraseAlert, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
let error = error as NSError
|
|
||||||
var message = error.localizedDescription
|
|
||||||
if let underlyingError = error.userInfo[NSUnderlyingErrorKey] as? NSError {
|
|
||||||
message = "\(message)\n\("UnderlyingError".localize()): \(underlyingError.localizedDescription)"
|
|
||||||
}
|
|
||||||
Utils.alert(title: "Error".localize(), message: message, controller: self, completion: nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue