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