File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff 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
138148NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change @@ -125,4 +125,13 @@ - (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 = NO ;
130+ BOOL ignore = [self shouldFileBeIgnored: fileURL success: &success error: error];
131+ if (success) {
132+ return (ignore ? GTFileIgnoreStateShouldIgnore : GTFileIgnoreStateShouldNotIgnore);
133+ }
134+ return GTFileIgnoreStateIgnoreCheckFailed;
135+ }
136+
128137@end
Original file line number Diff line number Diff line change 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
110128afterEach (^{
You can’t perform that action at this time.
0 commit comments