diff --git a/pass/Controllers/GitServerSettingTableViewController.swift b/pass/Controllers/GitServerSettingTableViewController.swift index d2645f2..b76630f 100644 --- a/pass/Controllers/GitServerSettingTableViewController.swift +++ b/pass/Controllers/GitServerSettingTableViewController.swift @@ -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 diff --git a/pass/de.lproj/Localizable.strings b/pass/de.lproj/Localizable.strings index bd37fd5..e065a19 100644 --- a/pass/de.lproj/Localizable.strings +++ b/pass/de.lproj/Localizable.strings @@ -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."; diff --git a/pass/en.lproj/Localizable.strings b/pass/en.lproj/Localizable.strings index d0deb43..0bdb7ab 100644 --- a/pass/en.lproj/Localizable.strings +++ b/pass/en.lproj/Localizable.strings @@ -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."; diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 35d5dd4..132b816 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -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) - try checkoutAndChangeBranch(withName: branchName) + 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 }