Skip to content

Commit

Permalink
Merge develop to master
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnon Keereena committed May 4, 2017
2 parents dfc2614 + 8d1aaa6 commit a58f849
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions SwiftGit2/CommitIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,25 @@ public class CommitIterator: IteratorProtocol, Sequence {
}

public func next() -> Element? {
var unsafeCommit: OpaquePointer? = nil
var oid = git_oid()
let revwalkGitResult = git_revwalk_next(&oid, revisionWalker)
let nextResult = Next(revwalkGitResult, name: "git_revwalk_next")
if case let .error(error) = nextResult {
switch nextResult {
case let .error(error):
return Result.failure(error)
} else if case .over = nextResult {
case .over:
return nil
case .ok:
var unsafeCommit: OpaquePointer? = nil
let lookupGitResult = git_commit_lookup(&unsafeCommit, repo.pointer, &oid)
guard lookupGitResult == GIT_OK.rawValue,
let unwrapCommit = unsafeCommit else {
return Result.failure(NSError(gitError: lookupGitResult, pointOfFailure: "git_commit_lookup"))
}
let result: Element = Result.success(Commit(unwrapCommit))
git_commit_free(unsafeCommit)
return result
}
let lookupGitResult = git_commit_lookup(&unsafeCommit, repo.pointer, &oid)
guard lookupGitResult == GIT_OK.rawValue,
let unwrapCommit = unsafeCommit else {
return Result.failure(NSError(gitError: lookupGitResult, pointOfFailure: "git_commit_lookup"))
}
let result: Element = Result.success(Commit(unwrapCommit))
git_commit_free(unsafeCommit)
return result
}

public func makeIterator() -> CommitIterator {
Expand Down
2 changes: 1 addition & 1 deletion SwiftGit2Tests/RepositorySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class RepositorySpec: QuickSpec {
}
}

fdescribe("Repository.allCommits(in:)") {
describe("Repository.allCommits(in:)") {
it("should return all (9) commits") {
let repo = Fixtures.simpleRepository
let branches = repo.localBranches().value!
Expand Down

0 comments on commit a58f849

Please sign in to comment.