Fix #326: Do not assume 'master' as the default checked out branch
This commit is contained in:
parent
de88b27d1a
commit
4c47729a6e
4 changed files with 15 additions and 8 deletions
|
|
@ -78,8 +78,8 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
private func cloneAndSegueIfSuccess() {
|
||||
// try to clone
|
||||
let gitRepostiroyURL = gitURLTextField.text!.trimmed
|
||||
let username = usernameTextField.text!
|
||||
let branchName = branchNameTextField.text!
|
||||
let username = usernameTextField.text!.trimmed
|
||||
let branchName = branchNameTextField.text!.trimmed
|
||||
let auth = authenticationMethod
|
||||
|
||||
SVProgressHUD.setDefaultMaskType(.black)
|
||||
|
|
@ -121,7 +121,7 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
let error = error as NSError
|
||||
var message = error.localizedDescription
|
||||
if let underlyingError = error.userInfo[NSUnderlyingErrorKey] as? NSError {
|
||||
message = "\(message)\n\("UnderlyingError".localize()): \(underlyingError.localizedDescription)"
|
||||
message = "\(message)\n\("UnderlyingError".localize(underlyingError.localizedDescription))"
|
||||
}
|
||||
Utils.alert(title: "Error".localize(), message: message, controller: self, completion: nil)
|
||||
}
|
||||
|
|
@ -179,6 +179,11 @@ class GitServerSettingTableViewController: UITableViewController {
|
|||
return
|
||||
}
|
||||
|
||||
guard let branchName = branchNameTextField.text, !branchName.trimmed.isEmpty else {
|
||||
Utils.alert(title: "CannotSave".localize(), message: "SpecifyBranchName.".localize(), controller: self, completion: nil)
|
||||
return
|
||||
}
|
||||
|
||||
switch gitURL.scheme {
|
||||
case let val where val == "https":
|
||||
break
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@
|
|||
"FailedToDeletePasswordEntity" = "Entfernen des Passworts fehlgeschlagen: %@";
|
||||
"FailedToSavePasswordEntity" = "Speichern des Passworts fehlgeschlagen: %@";
|
||||
"FailureToSaveContext" = "Fehler beim Speichern des Kontexts: %@";
|
||||
"RepositoryRemoteMasterNotFoundError." = "Remote-Branch origin/master wurde nicht gefunden.";
|
||||
"RepositoryRemoteBranchNotFoundError." = "Der Remote-Branch %@ existiert nicht.";
|
||||
"RepositoryBranchNotFoundError." = "Der lokale Branch %@ existiert nicht.";
|
||||
"KeyImportError." = "Schlüssel kann nicht importiert werden.";
|
||||
"FileNotFoundError." = "Die Datei '%@' kann nicht gelesen werden.";
|
||||
"PasswordDuplicatedError." = "Passwort kann nicht hinzugefügt werden; es existiert bereits.";
|
||||
|
|
@ -94,6 +95,7 @@
|
|||
"SyncingPasswordStore" = "Password Store wird synchronisiert";
|
||||
"PullingFromRemoteRepository" = "Update lokales Repository";
|
||||
"PushingToRemoteRepository" = "Update Remote-Repository";
|
||||
"SpecifyBranchName." = "Der Name des zu verwendenden Branches muss angegeben werden.";
|
||||
|
||||
// SSH
|
||||
"FillInSshKeyPassphrase." = "Bitte gib das Passwort des SSH-Schlüssels ein.";
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@
|
|||
"SyncingPasswordStore" = "Syncing Password Store";
|
||||
"PullingFromRemoteRepository" = "Pulling from Remote Repository";
|
||||
"PushingToRemoteRepository" = "Pushing to Remote Repository";
|
||||
"SpecifyBranchName." = "Please specify the name of the branch to be used.";
|
||||
|
||||
// SSH
|
||||
"FillInSshKeyPassphrase." = "Please fill in the passphrase of your SSH key.";
|
||||
|
|
|
|||
|
|
@ -189,7 +189,9 @@ public class PasswordStore {
|
|||
storeRepository = try GTRepository.clone(from: remoteRepoURL, toWorkingDirectory: tempStoreURL, options: options, transferProgressBlock:transferProgressBlock)
|
||||
try fm.moveItem(at: tempStoreURL, to: storeURL)
|
||||
storeRepository = try GTRepository(url: storeURL)
|
||||
if (try? storeRepository?.currentBranch().name) != branchName {
|
||||
try checkoutAndChangeBranch(withName: branchName)
|
||||
}
|
||||
} catch {
|
||||
credential.delete()
|
||||
DispatchQueue.main.async {
|
||||
|
|
@ -207,9 +209,6 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
private func checkoutAndChangeBranch(withName localBranchName: String) throws {
|
||||
if (localBranchName == "master") {
|
||||
return
|
||||
}
|
||||
guard let storeRepository = storeRepository else {
|
||||
throw AppError.RepositoryNotSet
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue