diff --git a/pass/Controllers/PasswordDetailTableViewController.swift b/pass/Controllers/PasswordDetailTableViewController.swift
index 57ec55b..6b3e2ca 100644
--- a/pass/Controllers/PasswordDetailTableViewController.swift
+++ b/pass/Controllers/PasswordDetailTableViewController.swift
@@ -250,6 +250,21 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
return tableData[section].title
}
+ override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+ if section == tableData.count - 1 {
+ let view = UIView()
+ let footerLabel = UILabel(frame: CGRect(x: 8, y: 15, width: tableView.frame.width, height: 60))
+ footerLabel.numberOfLines = 0
+ footerLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
+ footerLabel.textColor = UIColor.lightGray
+ let dateString = DateFormatter.localizedString(from: passwordEntity?.commitDate as! Date, dateStyle: DateFormatter.Style.long, timeStyle: DateFormatter.Style.long)
+ footerLabel.text = "Latest commit: \(dateString)"
+ view.addSubview(footerLabel)
+ return view
+ }
+ return nil
+ }
+
override func tableView(_ tableView: UITableView, performAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) {
if action == #selector(copy(_:)) {
Utils.copyToPasteboard(textToCopy: tableData[indexPath.section].item[indexPath.row].content)
diff --git a/pass/Models/PasswordStore.swift b/pass/Models/PasswordStore.swift
index cba6012..5817791 100644
--- a/pass/Models/PasswordStore.swift
+++ b/pass/Models/PasswordStore.swift
@@ -243,6 +243,17 @@ class PasswordStore {
let endIndex = url.lastPathComponent.index(url.lastPathComponent.endIndex, offsetBy: -4)
passwordEntity.name = url.lastPathComponent.substring(to: endIndex)
passwordEntity.rawPath = "\(url.path)"
+ if let blameHunks = try? storeRepository?.blame(withFile: e, options: nil).hunks {
+ func GetHunkDate(hunk: GTBlameHunk) -> TimeInterval {
+ guard let date = hunk.finalSignature?.time?.timeIntervalSince1970 else {
+ print("Time is missing from GTSignature.")
+ return 0
+ }
+ return date
+ }
+ let dates = blameHunks?.map(GetHunkDate).max()
+ passwordEntity.commitDate = NSDate(timeIntervalSince1970: dates!)
+ }
let items = url.path.characters.split(separator: "/").map(String.init)
for i in 0 ..< items.count - 1 {
let passwordCategoryEntity = PasswordCategoryEntity(context: context)
@@ -439,7 +450,8 @@ class PasswordStore {
passwordEntity.synced = false
try context.save()
print(saveURL.path)
- let _ = createAddCommitInRepository(message: "Add new password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
+ let commit = createAddCommitInRepository(message: "Add new password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
+ passwordEntity.commitDate = commit?.commitDate as NSDate?
progressBlock(1.0)
} catch {
print(error)
@@ -452,7 +464,8 @@ class PasswordStore {
let saveURL = storeURL.appendingPathComponent(passwordEntity.rawPath!)
try encryptedData.write(to: saveURL)
progressBlock(0.3)
- let _ = createAddCommitInRepository(message: "Update password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
+ let commit = createAddCommitInRepository(message: "Update password by pass for iOS", fileData: encryptedData, filename: saveURL.lastPathComponent, progressBlock: progressBlock)
+ passwordEntity.commitDate = commit?.commitDate as NSDate?
} catch {
print(error)
}
diff --git a/pass/pass.xcdatamodeld/pass.xcdatamodel/contents b/pass/pass.xcdatamodeld/pass.xcdatamodel/contents
index ede2475..8d650b8 100644
--- a/pass/pass.xcdatamodeld/pass.xcdatamodel/contents
+++ b/pass/pass.xcdatamodeld/pass.xcdatamodel/contents
@@ -6,6 +6,7 @@
+
@@ -15,6 +16,6 @@
-
+
\ No newline at end of file