Skip to content

Commit 70eacf7

Browse files
committed
Merge refinements to GTRepository.shouldIgnoreFileURL from in-progress pull request
2 parents f3cd22e + 7b18b14 commit 70eacf7

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

ObjectiveGit/GTRepository+Status.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,12 @@ - (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSEr
126126
}
127127

128128
- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error {
129-
BOOL success = false;
129+
BOOL success = NO;
130130
BOOL ignore = [self shouldFileBeIgnored:fileURL success:&success error:error];
131-
return ignore && success ? GTFileIgnoreStateShouldIgnore : (!ignore && success ? GTFileIgnoreStateShouldNotIgnore : GTFileIgnoreStateIgnoreCheckFailed);
131+
if (success) {
132+
return (ignore ? GTFileIgnoreStateShouldIgnore : GTFileIgnoreStateShouldNotIgnore);
133+
}
134+
return GTFileIgnoreStateIgnoreCheckFailed;
132135
}
133136

134137
@end

ObjectiveGitTests/GTRepository+StatusSpec.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@
105105
expect(@(enumerationSuccessful)).to(beTruthy());
106106
expect(err).to(beNil());
107107
});
108+
109+
it(@"should report file should be ignored", ^{
110+
__block NSError *err = nil;
111+
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:@".DS_Store"];
112+
BOOL success = NO;
113+
BOOL shouldIgnore = [repository shouldFileBeIgnored:fileURL success:&success error:&err];
114+
expect(@(success)).to(beTrue());
115+
expect(@(shouldIgnore)).to(beTrue());
116+
expect(err).to(beNil());
117+
});
118+
119+
it(@"should report file should be ignored (convenience wrapper)", ^{
120+
__block NSError *err = nil;
121+
NSURL *fileURL = [repository.fileURL URLByAppendingPathComponent:@".DS_Store"];
122+
GTFileIgnoreState ignore = [repository shouldIgnoreFileURL:fileURL error:&err];
123+
expect(@(ignore)).to(equal(@(GTFileIgnoreStateShouldIgnore)));
124+
expect(err).to(beNil());
125+
});
108126
});
109127

110128
afterEach(^{

0 commit comments

Comments
 (0)