Store password repository details only if we are sure to clone/overwrite it (#571)
This commit is contained in:
parent
ad105b3df1
commit
a6b05d20e0
1 changed files with 9 additions and 7 deletions
|
|
@ -122,7 +122,7 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let branchName = branchNameTextField.text, !branchName.trimmed.isEmpty else {
|
guard let branchName = branchNameTextField.text?.trimmed, !branchName.isEmpty else {
|
||||||
Utils.alert(title: "CannotSave".localize(), message: "SpecifyBranchName.".localize(), controller: self)
|
Utils.alert(title: "CannotSave".localize(), message: "SpecifyBranchName.".localize(), controller: self)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -146,16 +146,14 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.gitURL = gitURL
|
let username = (gitURL.user ?? usernameTextField.text ?? "git").trimmed
|
||||||
gitBranchName = branchName.trimmed
|
|
||||||
gitUsername = (gitURL.user ?? usernameTextField.text ?? "git").trimmed
|
|
||||||
|
|
||||||
if passwordStore.repositoryExists() {
|
if passwordStore.repositoryExists() {
|
||||||
let overwriteAlert: UIAlertController = {
|
let overwriteAlert: UIAlertController = {
|
||||||
let alert = UIAlertController(title: "Overwrite?".localize(), message: "OperationWillOverwriteData.".localize(), preferredStyle: .alert)
|
let alert = UIAlertController(title: "Overwrite?".localize(), message: "OperationWillOverwriteData.".localize(), preferredStyle: .alert)
|
||||||
alert.addAction(
|
alert.addAction(
|
||||||
UIAlertAction(title: "Overwrite".localize(), style: .destructive) { _ in
|
UIAlertAction(title: "Overwrite".localize(), style: .destructive) { _ in
|
||||||
self.cloneAndSegueIfSuccess()
|
self.cloneAndSegueIfSuccess(url: gitURL, branch: branchName, username: username)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
alert.addAction(UIAlertAction.cancel())
|
alert.addAction(UIAlertAction.cancel())
|
||||||
|
|
@ -163,11 +161,15 @@ class GitRepositorySettingsTableViewController: UITableViewController, PasswordA
|
||||||
}()
|
}()
|
||||||
present(overwriteAlert, animated: true)
|
present(overwriteAlert, animated: true)
|
||||||
} else {
|
} else {
|
||||||
cloneAndSegueIfSuccess()
|
cloneAndSegueIfSuccess(url: gitURL, branch: branchName, username: username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func cloneAndSegueIfSuccess() {
|
private func cloneAndSegueIfSuccess(url: URL, branch: String, username: String) {
|
||||||
|
gitURL = url
|
||||||
|
gitBranchName = branch
|
||||||
|
gitUsername = username
|
||||||
|
|
||||||
// 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.
|
||||||
Defaults.isRememberGitCredentialPassphraseOn = true
|
Defaults.isRememberGitCredentialPassphraseOn = true
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue