Polish commit messages.
This commit is contained in:
parent
5ae6de8f23
commit
3d8c1c8478
2 changed files with 22 additions and 4 deletions
|
|
@ -10,6 +10,17 @@ import Foundation
|
||||||
import SwiftyUserDefaults
|
import SwiftyUserDefaults
|
||||||
|
|
||||||
extension PasswordEntity {
|
extension PasswordEntity {
|
||||||
|
|
||||||
|
var nameWithCategory: String {
|
||||||
|
get {
|
||||||
|
if let p = path, p.hasSuffix(".gpg") {
|
||||||
|
return p.substring(to: p.index(p.endIndex, offsetBy: -4))
|
||||||
|
} else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func decrypt(passphrase: String) throws -> Password? {
|
func decrypt(passphrase: String) throws -> Password? {
|
||||||
var password: Password?
|
var password: Password?
|
||||||
let encryptedDataPath = URL(fileURLWithPath: "\(Globals.repositoryPath)/\(path!)")
|
let encryptedDataPath = URL(fileURLWithPath: "\(Globals.repositoryPath)/\(path!)")
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,11 @@ class PasswordStore {
|
||||||
let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp")
|
let tempStoreURL = URL(fileURLWithPath: "\(Globals.repositoryPath)-temp")
|
||||||
var storeRepository: GTRepository?
|
var storeRepository: GTRepository?
|
||||||
var gitCredential: GitCredential?
|
var gitCredential: GitCredential?
|
||||||
|
var gitSignatureForNow: GTSignature {
|
||||||
|
get {
|
||||||
|
return GTSignature(name: Defaults[.gitRepositoryUsername]!, email: Defaults[.gitRepositoryUsername]!+"@passforios", time: Date())!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let pgp: ObjectivePGP = ObjectivePGP()
|
let pgp: ObjectivePGP = ObjectivePGP()
|
||||||
|
|
||||||
|
|
@ -425,7 +430,8 @@ class PasswordStore {
|
||||||
try commitEnum.pushSHA(headReference.targetOID.sha!)
|
try commitEnum.pushSHA(headReference.targetOID.sha!)
|
||||||
let parent = commitEnum.nextObject() as! GTCommit
|
let parent = commitEnum.nextObject() as! GTCommit
|
||||||
progressBlock(0.5)
|
progressBlock(0.5)
|
||||||
let commit = try storeRepository!.createCommit(with: newTree, message: message, parents: [parent], updatingReferenceNamed: headReference.name)
|
let signature = gitSignatureForNow
|
||||||
|
let commit = try storeRepository!.createCommit(with: newTree, message: message, author: signature, committer: signature, parents: [parent], updatingReferenceNamed: headReference.name)
|
||||||
progressBlock(0.7)
|
progressBlock(0.7)
|
||||||
return commit
|
return commit
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -444,7 +450,8 @@ class PasswordStore {
|
||||||
try commitEnum.pushSHA(headReference.targetOID.sha!)
|
try commitEnum.pushSHA(headReference.targetOID.sha!)
|
||||||
let parent = commitEnum.nextObject() as! GTCommit
|
let parent = commitEnum.nextObject() as! GTCommit
|
||||||
progressBlock(0.5)
|
progressBlock(0.5)
|
||||||
let commit = try storeRepository!.createCommit(with: newTree, message: message, parents: [parent], updatingReferenceNamed: headReference.name)
|
let signature = gitSignatureForNow
|
||||||
|
let commit = try storeRepository!.createCommit(with: newTree, message: message, author: signature, committer: signature, parents: [parent], updatingReferenceNamed: headReference.name)
|
||||||
progressBlock(0.7)
|
progressBlock(0.7)
|
||||||
return commit
|
return commit
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -493,7 +500,7 @@ class PasswordStore {
|
||||||
passwordEntity.isDir = false
|
passwordEntity.isDir = false
|
||||||
try context.save()
|
try context.save()
|
||||||
print(saveURL.path)
|
print(saveURL.path)
|
||||||
let _ = createAddCommitInRepository(message: "Add new password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
|
let _ = createAddCommitInRepository(message: "Add password for \(passwordEntity.nameWithCategory) to store using Pass for iOS.", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
|
||||||
progressBlock(1.0)
|
progressBlock(1.0)
|
||||||
} catch {
|
} catch {
|
||||||
print(error)
|
print(error)
|
||||||
|
|
@ -506,7 +513,7 @@ class PasswordStore {
|
||||||
let saveURL = storeURL.appendingPathComponent(passwordEntity.path!)
|
let saveURL = storeURL.appendingPathComponent(passwordEntity.path!)
|
||||||
try encryptedData.write(to: saveURL)
|
try encryptedData.write(to: saveURL)
|
||||||
progressBlock(0.3)
|
progressBlock(0.3)
|
||||||
let _ = createAddCommitInRepository(message: "Update password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
|
let _ = createAddCommitInRepository(message: "Edit password for \(passwordEntity.nameWithCategory) using Pass for iOS.", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
|
||||||
} catch {
|
} catch {
|
||||||
print(error)
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue