|
14 | 14 |
|
15 | 15 | QuickSpecBegin(GTRepositorySpec)
|
16 | 16 |
|
| 17 | +static NSString * const readmeFile = @"README.md"; |
| 18 | +static NSString * const readme1File = @"README1.txt"; |
| 19 | + |
| 20 | + |
17 | 21 | __block GTRepository *repository;
|
18 | 22 |
|
19 | 23 | beforeEach(^{
|
|
376 | 380 | });
|
377 | 381 | });
|
378 | 382 |
|
| 383 | +describe(@"-checkout:strategy:notifyFlags:error:notifyBlock:progressBlock:", ^{ |
| 384 | + it(@"should fail ref checkout with conflict and notify", ^{ |
| 385 | + NSError *error = nil; |
| 386 | + GTReference *ref = [repository lookUpReferenceWithName:@"refs/heads/other-branch" error:&error]; |
| 387 | + expect(ref).notTo(beNil()); |
| 388 | + expect(error.localizedDescription).to(beNil()); |
| 389 | + BOOL writeResult = [@"Conflicting data in README.md\n" writeToURL:[repository.fileURL URLByAppendingPathComponent:readmeFile] atomically:YES encoding:NSUTF8StringEncoding error:&error]; |
| 390 | + expect(@(writeResult)).to(beTruthy()); |
| 391 | + __block NSUInteger notifyCount = 0; |
| 392 | + __block BOOL readmeFileConflicted = NO; |
| 393 | + int (^notifyBlock)(GTCheckoutNotifyFlags, NSString *, GTDiffFile *, GTDiffFile *, GTDiffFile *); |
| 394 | + notifyBlock = ^(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir) { |
| 395 | + notifyCount++; |
| 396 | + if([path isEqualToString:readmeFile] && (why & GTCheckoutNotifyConflict)) { |
| 397 | + readmeFileConflicted = YES; |
| 398 | + } |
| 399 | + return 0; |
| 400 | + }; |
| 401 | + |
| 402 | + BOOL result = [repository checkoutReference:ref strategy:GTCheckoutStrategySafe notifyFlags:GTCheckoutNotifyConflict error:&error progressBlock:nil notifyBlock:notifyBlock]; |
| 403 | + expect(@(notifyCount)).to(equal(@(1))); |
| 404 | + expect(@(readmeFileConflicted)).to(beTruthy()); |
| 405 | + expect(@(result)).to(beFalsy()); |
| 406 | + expect(@(error.code)).to(equal(@(GIT_ECONFLICT))); |
| 407 | + }); |
| 408 | + |
| 409 | + it(@"should fail commit checkout with conflict and notify", ^{ |
| 410 | + NSError *error = nil; |
| 411 | + GTCommit *commit = [repository lookUpObjectBySHA:@"1d69f3c0aeaf0d62e25591987b93b8ffc53abd77" objectType:GTObjectTypeCommit error:&error]; |
| 412 | + expect(commit).notTo(beNil()); |
| 413 | + expect(error.localizedDescription).to(beNil()); |
| 414 | + BOOL writeResult = [@"Conflicting data in README1.txt\n" writeToURL:[repository.fileURL URLByAppendingPathComponent:readme1File] atomically:YES encoding:NSUTF8StringEncoding error:&error]; |
| 415 | + expect(@(writeResult)).to(beTruthy()); |
| 416 | + __block NSUInteger notifyCount = 0; |
| 417 | + __block BOOL readme1FileConflicted = NO; |
| 418 | + int (^notifyBlock)(GTCheckoutNotifyFlags, NSString *, GTDiffFile *, GTDiffFile *, GTDiffFile *); |
| 419 | + notifyBlock = ^(GTCheckoutNotifyFlags why, NSString *path, GTDiffFile *baseline, GTDiffFile *target, GTDiffFile *workdir) { |
| 420 | + notifyCount++; |
| 421 | + if([path isEqualToString:readme1File] && (why & GTCheckoutNotifyConflict)) { |
| 422 | + readme1FileConflicted = YES; |
| 423 | + } |
| 424 | + return 0; |
| 425 | + }; |
| 426 | + |
| 427 | + BOOL result = [repository checkoutCommit:commit strategy:GTCheckoutStrategySafe notifyFlags:GTCheckoutNotifyConflict error:&error progressBlock:nil notifyBlock:notifyBlock]; |
| 428 | + expect(@(notifyCount)).to(equal(@(1))); |
| 429 | + expect(@(readme1FileConflicted)).to(beTruthy()); |
| 430 | + expect(@(result)).to(beFalsy()); |
| 431 | + expect(@(error.code)).to(equal(@(GIT_ECONFLICT))); |
| 432 | + }); |
| 433 | +}); |
| 434 | + |
379 | 435 | describe(@"-remoteNamesWithError:", ^{
|
380 | 436 | it(@"allows access to remote names", ^{
|
381 | 437 | NSError *error = nil;
|
|
0 commit comments