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

Added shouldIgnoreFileURL:error: convenience wrapper #545

Merged
merged 3 commits into from
Jan 30, 2016

Conversation

onecrayon
Copy link
Contributor

Added to GTRepository+Status for compatibility with Swift; closes issue #541.

@pietbrauer
Copy link
Member

For my feeling this is a lot of bool comparison to go right the first time. Could you add a test for the new method?

@@ -125,4 +125,10 @@ - (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSEr
return (ignoreState == 1 ? YES : NO);
}

- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error {
BOOL success = false;
Copy link
Member

Choose a reason for hiding this comment

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

Conventionally this should be NO instead of false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha; guess it shows that I've been coding nothing but Swift for the past while...

@joshaber joshaber self-assigned this Jan 29, 2016
- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error {
BOOL success = false;
BOOL ignore = [self shouldFileBeIgnored:fileURL success:&success error:error];
return ignore && success ? GTFileIgnoreStateShouldIgnore : (!ignore && success ? GTFileIgnoreStateShouldNotIgnore : GTFileIgnoreStateIgnoreCheckFailed);
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit complex to squeeze into one ternary. How about splitting them up?

@joshaber
Copy link
Member

Thanks @onecrayon! This is close, just a couple comments.

Could you add a test for the new method?

Yup, a test or two would be great 👍

@onecrayon
Copy link
Contributor Author

I am not familiar with the testing framework being used here, and there does not appear to be any test associated with the method this is wrapping, so mimicking that is out (e.g. -statusForFile:success:error). I've been testing this locally, and the logic is fine (you'll note my previous pull request fixing the broken logic in the method I'm wrapping...), but if you still want a test added to the suite you'll need to point me in the direction of a good example that I can customize for this particular method.

@pietbrauer
Copy link
Member

True, the existing implementation is not being tested directly. There are some status specs here you could just copy paste one if them and check if your method returns the right enum value.

@onecrayon
Copy link
Contributor Author

Added a couple of tests: one for the original method and one for the wrapper; both are passing for me. Although FYI the testing suite as a whole is crashing and burning on a memory error for an unrelated test later on:

-[GTSignatureSpec should_keep_the_git_signature_alive_even_if_the_object_goes_out_of_scope]

@joshaber
Copy link
Member

Looks good, thanks!

joshaber added a commit that referenced this pull request Jan 30, 2016
Added shouldIgnoreFileURL:error: convenience wrapper
@joshaber joshaber merged commit 1a00686 into libgit2:master Jan 30, 2016
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.

3 participants