diff --git a/pass/de.lproj/Localizable.strings b/pass/de.lproj/Localizable.strings index f4245e8..8cb12a9 100644 --- a/pass/de.lproj/Localizable.strings +++ b/pass/de.lproj/Localizable.strings @@ -67,6 +67,8 @@ "FileNotFoundError." = "Die Datei '%@' kann nicht gelesen werden."; "PasswordDuplicatedError." = "Passwort kann nicht hinzugefügt werden; es existiert bereits."; "GitResetError." = "Der zuletzt synchronisierte Commit kann nicht identifiziert werden."; +"GitCreateSignatureError." = "Es konnte keine valide Signatur für den Author/Committer angelegt werden."; +"GitPushNotSuccessfulError." = "Die Übertragung der lokalen Änderungen war nicht erfolgreich. Stelle bitte sicher, dass auf dem Remote-Repository alle Änderungen commitet sind."; "WrongPasswordFilenameError." = "Schreiben der Passwort-Datei nicht möglich ."; "DecryptionError." = "Passwort kann nicht entschlüsselt werden."; "EncodingError." = "Schlüssel ist nicht in ASCII kodiert."; diff --git a/pass/en.lproj/Localizable.strings b/pass/en.lproj/Localizable.strings index 487d277..668b580 100644 --- a/pass/en.lproj/Localizable.strings +++ b/pass/en.lproj/Localizable.strings @@ -67,6 +67,8 @@ "FileNotFoundError." = "File '%@' cannot be read."; "PasswordDuplicatedError." = "Cannot add the password; password is duplicated."; "GitResetError." = "Cannot identify the latest synced commit."; +"GitCreateSignatureError." = "Cannot create a valid author/committer signature."; +"GitPushNotSuccessfulError." = "Pushing local changes was not successful. Make sure there are no uncommitted changes on the remote repository."; "WrongPasswordFilenameError." = "Cannot write to the password file."; "DecryptionError." = "Cannot decrypt password."; "EncodingError." = "Key is not ASCII encoded."; diff --git a/passKit/Helpers/AppError.swift b/passKit/Helpers/AppError.swift index ad5ca64..e2ca7b7 100644 --- a/passKit/Helpers/AppError.swift +++ b/passKit/Helpers/AppError.swift @@ -14,7 +14,8 @@ public enum AppError: Error, Equatable { case ReadingFile(_: String) case PasswordDuplicated case GitReset - case GitCommit + case GitCreateSignature + case GitPushNotSuccessful case PasswordEntity case PgpPublicKeyNotFound(keyID: String) case PgpPrivateKeyNotFound(keyID: String) diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 256283c..7897772 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -448,7 +448,7 @@ public class PasswordStore { try commitEnum.pushSHA(headReference.targetOID!.sha) let parent = commitEnum.nextObject() as! GTCommit guard let signature = gitSignatureForNow else { - throw AppError.GitCommit + throw AppError.GitCreateSignature } let commit = try storeRepository.createCommit(with: newTree, message: message, author: signature, committer: signature, parents: [parent], updatingReferenceNamed: headReference.name) return commit @@ -467,15 +467,14 @@ public class PasswordStore { guard let storeRepository = storeRepository else { throw AppError.RepositoryNotSet } - do { - let credentialProvider = try credential.credentialProvider(requestCredentialPassword: requestCredentialPassword) - let options = [GTRepositoryRemoteOptionsCredentialProvider: credentialProvider] - if let branch = try getLocalBranch(withName: Defaults.gitBranchName) { - let remote = try GTRemote(name: "origin", in: storeRepository) - try storeRepository.push(branch, to: remote, withOptions: options, progress: transferProgressBlock) - } - } catch { - throw(error) + let credentialProvider = try credential.credentialProvider(requestCredentialPassword: requestCredentialPassword) + let options = [GTRepositoryRemoteOptionsCredentialProvider: credentialProvider] + if let branch = try getLocalBranch(withName: Defaults.gitBranchName) { + let remote = try GTRemote(name: "origin", in: storeRepository) + try storeRepository.push(branch, to: remote, withOptions: options, progress: transferProgressBlock) + } + if numberOfLocalCommits != 0 { + throw AppError.GitPushNotSuccessful } }