Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git commit #128

Merged
merged 9 commits into from
May 4, 2018
Merged

Git commit #128

merged 9 commits into from
May 4, 2018

Conversation

tengyifei
Copy link
Member

Okay this one works but is definitely not as clean as I wanted. And there are way too many levels of nesting. Thoughts?

@mdiep
Copy link
Contributor

mdiep commented May 2, 2018

Would you mind rebasing or merging in master? 🙏


/// Return an unsafe pointer to the `git_signature` struct.
/// Caller is responsible for freeing it with `git_signature_free`.
var unsafeSignature: Result<UnsafeMutablePointer<git_signature>, NSError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It think we should probably make this a makeX function. That'd be more in line with the Swift API guidelines. makeUnsafeSignature(). Or maybe even makeGitSignature().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeUnsafeSignature() sounds more consistent with our current unsafe-prefix stuff

@tengyifei
Copy link
Member Author

@mdiep done

let lookupResult = git_commit_lookup(&parent, self.pointer, &oid)
guard lookupResult == GIT_OK.rawValue else {
let err = NSError(gitError: lookupResult, pointOfFailure: "git_commit_lookup")
return .failure(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would leak parentGitCommits. We need a defer above that frees them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't a defer free the commit as soon as it goes out of scope i.e. the for loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm I think I found a way

// should be clean now
let newStatus = repo.status()
expect(newStatus.value?.count).to(equal(0))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test. 👍

@mdiep
Copy link
Contributor

mdiep commented May 4, 2018

Looks good apart from this.

@tengyifei
Copy link
Member Author

Thanks for taking the time to review!

@mdiep mdiep merged commit 4111097 into SwiftGit2:master May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants