add function to get recent commits

This commit is contained in:
Bob Sun 2017-02-22 18:43:19 +08:00
parent 3e0ba8a1d5
commit af8cd536f1
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -259,6 +259,22 @@ class PasswordStore {
}
}
func getRecentCommits(count: Int) -> [GTCommit] {
var commits = [GTCommit]()
do {
let enumerator = try GTEnumerator(repository: storeRepository!)
try enumerator.pushSHA(storeRepository!.headReference().targetOID.sha!)
for _ in 0 ..< count {
let commit = try enumerator.nextObject(withSuccess: nil)
commits.append(commit)
}
} catch {
print(error)
return commits
}
return commits
}
func fetchPasswordEntityCoreData() -> [PasswordEntity] {
let passwordEntityFetch = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
do {