Skip to content

Commit 233527d

Browse files
committed
Added shouldIgnoreFileURL:error: convenience wrapper to GTRepository+Status for compatibility with Swift; closes #541
1 parent 17e8896 commit 233527d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ObjectiveGit/GTRepository+Status.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ extern NSString *const GTRepositoryStatusOptionsPathSpecArrayKey;
133133
/// Returns YES if the file should be ignored; NO otherwise.
134134
- (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(nullable BOOL *)success error:(NSError **)error;
135135

136+
/// An enum for use with shouldIgnoreFileURL:error: below
137+
typedef NS_ENUM(NSInteger, GTFileIgnoreState) {
138+
GTFileIgnoreStateIgnoreCheckFailed = -1,
139+
GTFileIgnoreStateShouldNotIgnore = 0,
140+
GTFileIgnoreStateShouldIgnore = 1
141+
};
142+
143+
/// Convenience wrapper for shouldFileBeIgnored:success:error:
144+
- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error;
145+
136146
@end
137147

138148
NS_ASSUME_NONNULL_END

ObjectiveGit/GTRepository+Status.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,10 @@ - (BOOL)shouldFileBeIgnored:(NSURL *)fileURL success:(BOOL *)success error:(NSEr
125125
return (ignoreState == 1 ? YES : NO);
126126
}
127127

128+
- (GTFileIgnoreState)shouldIgnoreFileURL:(NSURL *)fileURL error:(NSError **)error {
129+
BOOL success = false;
130+
BOOL ignore = [self shouldFileBeIgnored:fileURL success:&success error:error];
131+
return ignore && success ? GTFileIgnoreStateShouldIgnore : (!ignore && success ? GTFileIgnoreStateShouldNotIgnore : GTFileIgnoreStateIgnoreCheckFailed);
132+
}
133+
128134
@end

0 commit comments

Comments
 (0)