8000 Make `Rebase` a set of `Commands` · libgit2/libgit2sharp@75dad9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 75dad9b

Browse files
committed
Make Rebase a set of Commands
1 parent 13ed939 commit 75dad9b

File tree

4 files changed

+339
-42
lines changed

4 files changed

+339
-42
lines changed

LibGit2Sharp.Tests/RebaseFixture.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void CanRebase(string initialBranchName,
7878
},
7979
};
8080

81-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
81+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, options);
8282

8383
// Validation:
8484
Assert.True(afterRebaseStepCountCorrect, "Unexpected CompletedStepIndex value in RebaseStepCompleted");
@@ -130,7 +130,7 @@ public void CanRebaseBranchOntoItself()
130130
Commands.Checkout(repo, topicBranch2Name);
131131
Branch b = repo.Branches[topicBranch2Name];
132132

133-
RebaseResult result = repo.Rebase.Start(b, b, null, Constants.Identity, new RebaseOptions());
133+
RebaseResult result = Commands.Rebase.Start(repo, b, b, null, Constants.Identity, new RebaseOptions());
134134
Assert.Equal(0, result.TotalStepCount);
135135
Assert.Equal(RebaseStatus.Complete, result.Status);
136136
Assert.Equal(0, result.CompletedStepCount);
@@ -251,7 +251,7 @@ public void VerifyRebaseDetailed(string attributes, string lineEnding, string[]
251251

252252
};
253253

254-
repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
254+
Commands.Rebase.Start(repo, null, upstreamBranch, null, Constants.Identity2, options);
255255

256256
Assert.Equal(true, wasCheckoutNotifyCalledForResetingHead);
257257
Assert.Equal(true, wasCheckoutProgressCalledForResetingHead);
@@ -317,7 +317,7 @@ public void CanContinueRebase()
317317
CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
318318
};
319319

320-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
320+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, options);
321321

322322
// Verify that we have a conflict.
323323
Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
@@ -345,7 +345,7 @@ public void CanContinueRebase()
345345

346346
// Clear the flags:
347347
wasCheckoutProgressCalled = false; wasCheckoutNotifyCalled = false;
348-
RebaseResult continuedRebaseResult = repo.Rebase.Continue(Constants.Identity, options);
348+
RebaseResult continuedRebaseResult = Commands.Rebase.Continue(repo, Constants.Identity, options);
349349

350350
Assert.NotNull(continuedRebaseResult);
351351
Assert.Equal(RebaseStatus.Complete, continuedRebaseResult.Status);
@@ -377,7 +377,7 @@ public void ContinuingRebaseWithUnstagedChangesThrows()
377377
Branch upstream = repo.Branches[conflictBranch1Name];
378378
Branch onto = repo.Branches[conflictBranch1Name];
379379

380-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
380+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, null);
381381

382382
// Verify that we have a conflict.
383383
Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
@@ -388,7 +388,7 @@ public void ContinuingRebaseWithUnstagedChangesThrows()
388388
Assert.Equal(3, rebaseResult.TotalStepCount);
389389

390390
Assert.Throws<UnmergedIndexEntriesException>(() =>
391-
repo.Rebase.Continue(Constants.Identity, null));
391+
Commands.Rebase.Continue(repo, Constants.Identity, null));
392392

393393
// Resolve the conflict
394394
foreach (Conflict conflict in repo.Index.Conflicts)
@@ -404,7 +404,7 @@ public void ContinuingRebaseWithUnstagedChangesThrows()
404404
"Unstaged content");
405405

406406
Assert.Throws<UnmergedIndexEntriesException>(() =>
407-
repo.Rebase.Continue(Constants.Identity, null));
407+
Commands.Rebase.Continue(repo, Constants.Identity, null));
408408

409409
Assert.True(repo.Index.IsFullyMerged);
410410
}
@@ -431,7 +431,7 @@ public void CanSpecifyFileConflictStrategy()
431431
FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
432432
};
433433

434-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, options);
434+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, options);
435435

436436
// Verify that we have a conflict.
437437
Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
@@ -473,7 +473,7 @@ public void CanQueryRebaseOperation()
473473
Branch upstream = repo.Branches[conflictBranch1Name];
474474
Branch onto = repo.Branches[conflictBranch1Name];
475475

476-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
476+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, null);
477477

478478
// Verify that we have a conflict.
479479
Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
@@ -482,10 +482,10 @@ public void CanQueryRebaseOperation()
482482
Assert.Equal(0, rebaseResult.CompletedStepCount);
483483
Assert.Equal(3, rebaseResult.TotalStepCount);
484484

485-
RebaseStepInfo info = repo.Rebase.GetCurrentStepInfo();
485+
RebaseStepInfo info = Commands.Rebase.GetCurrentStepInfo(repo);
486486

487-
Assert.Equal(0, repo.Rebase.GetCurrentStepIndex());
488-
Assert.Equal(3, repo.Rebase.GetTotalStepCount());
487+
Assert.Equal(0, Commands.Rebase.GetCurrentStepIndex(repo));
488+
Assert.Equal(3, Commands.Rebase.GetTotalStepCount(repo));
489489
Assert.Equal(RebaseStepOperation.Pick, info.Type);
490490
}
491491
}
@@ -506,7 +506,7 @@ public void CanAbortRebase()
506506
Branch upstream = repo.Branches[conflictBranch1Name];
507507
Branch onto = repo.Branches[conflictBranch1Name];
508508

509-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
509+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, null);
510510

511511
// Verify that we have a conflict.
512512
Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
@@ -526,7 +526,7 @@ public void CanAbortRebase()
526526
CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
527527
};
528528

529-
repo.Rebase.Abort(options);
529+
Commands.Rebase.Abort(repo, options);
530530
Assert.False(repo.RetrieveStatus().IsDirty, "Repository workdir is dirty after Rebase.Abort.");
531531
Assert.True(repo.Index.IsFullyMerged, "Repository index is not fully merged after Rebase.Abort.");
532532
Assert.Equal(CurrentOperation.None, repo.Info.CurrentOperation);
@@ -552,15 +552,15 @@ public void RebaseWhileAlreadyRebasingThrows()
552552
Branch upstream = repo.Branches[conflictBranch1Name];
553553
Branch onto = repo.Branches[conflictBranch1Name];
554554

555-
RebaseResult rebaseResult = repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null);
555+
RebaseResult rebaseResult = Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, null);
556556

557557
// Verify that we have a conflict.
558558
Assert.Equal(RebaseStatus.Conflicts, rebaseResult.Status);
559559
Assert.True(repo.RetrieveStatus().IsDirty);
560560
Assert.Equal(CurrentOperation.RebaseMerge, repo.Info.CurrentOperation);
561561

562562
Assert.Throws<LibGit2SharpException>(() =>
563-
repo.Rebase.Start(branch, upstream, onto, Constants.Identity, null));
563+
Commands.Rebase.Start(repo, branch, upstream, onto, Constants.Identity, null));
564564
}
565565
}
566566

@@ -576,10 +576,10 @@ public void RebaseOperationsWithoutRebasingThrow()
576576
Commands.Checkout(repo, topicBranch1Name);
577577

578578
Assert.Throws<NotFoundException>(() =>
579-
repo.Rebase.Continue(Constants.Identity, new RebaseOptions()));
579+
Commands.Rebase.Continue(repo, Constants.Identity, new RebaseOptions()));
580580

581581
Assert.Throws<NotFoundException>(() =>
582-
repo.Rebase.Abort());
582+
Commands.Rebase.Abort(repo));
583583
}
584584
}
585585

@@ -593,7 +593,7 @@ public void CurrentStepInfoIsNullWhenNotRebasing()
593593
ConstructRebaseTestRepository(repo);
594594
Commands.Checkout(repo, topicBranch1Name);
595595

596-
Assert.Null(repo.Rebase.GetCurrentStepInfo());
596+
Assert.Null(Commands.Rebase.GetCurrentStepInfo(repo));
597597
}
598598
}
599599

@@ -642,7 +642,7 @@ public void CanRebaseHandlePatchAlreadyApplied(string attributes, string lineEnd
642642
}
643643
};
644644

645-
repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
645+
Commands.Rebase.Start(repo, null, upstreamBranch, null, Constants.Identity2, options);
646646
ObjectId secondCommitExpectedTreeId = new ObjectId(expectedShaText);
647647
Signature secondCommitAuthorSignature = Constants.Signature;
648648
Identity secondCommitCommiterIdentity = Constants.Identity2;
@@ -670,9 +670,9 @@ public void RebasingInBareRepositoryThrows()
670670
Branch rebaseUpstreamBranch = repo.Branches["refs/heads/test"];
671671

672672
Assert.NotNull(rebaseUpstreamBranch);
673-
Assert.Throws<BareRepositoryException>(() => repo.Rebase.Start(null, rebaseUpstreamBranch, null, Constants.Identity, new RebaseOptions()));
674-
Assert.Throws<BareRepositoryException>(() => repo.Rebase.Continue(Constants.Identity, new RebaseOptions()));
675-
Assert.Throws<BareRepositoryException>(() => repo.Rebase.Abort());
673+
Assert.Throws<BareRepositoryException>(() => Commands.Rebase.Start(repo, null, rebaseUpstreamBranch, null, Constants.Identity, new RebaseOptions()));
674+
Assert.Throws<BareRepositoryException>(() => Commands.Rebase.Continue(repo, Constants.Identity, new RebaseOptions()));
675+
Assert.Throws<BareRepositoryException>(() => Commands.Rebase.Abort(repo));
676676
}
677677
}
678678

0 commit comments

Comments
 (0)
0