Skip to content

Move some versions of Checkout to Commands #1294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
{
EnableRefLog(repo);

repo.Checkout(headCommitOrBranchSpec);
Commands.Checkout(repo, headCommitOrBranchSpec);

const string name = "unit_test";

Expand Down Expand Up @@ -154,7 +154,7 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
{
EnableRefLog(repo);

repo.Checkout(headCommitOrBranchSpec);
Commands.Checkout(repo, headCommitOrBranchSpec);

const string name = "unit_test";

Expand Down Expand Up @@ -1092,7 +1092,7 @@ public void DetachedHeadIsNotATrackingBranch()
repo.RemoveUntrackedFiles();

string headSha = repo.Head.Tip.Sha;
repo.Checkout(headSha);
Commands.Checkout(repo, headSha);

Assert.False(repo.Head.IsTracking);
Assert.Null(repo.Head.TrackedBranch);
Expand Down
112 changes: 56 additions & 56 deletions LibGit2Sharp.Tests/CheckoutFixture.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/CherryPickFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void CanCherryPick(bool fromDetachedHead)
{
if (fromDetachedHead)
{
repo.Checkout(repo.Head.Tip.Id.Sha);
Commands.Checkout(repo, repo.Head.Tip.Id.Sha);
}

Commit commitToMerge = repo.Branches["fast_forward"].Tip;
Expand All @@ -46,7 +46,7 @@ public void CherryPickWithConflictDoesNotCommit()
using (var repo = new Repository(path))
{
var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
AddFileCommitToRepo(repo, sharedBranchFileName);
Expand All @@ -56,7 +56,7 @@ public void CherryPickWithConflictDoesNotCommit()
AddFileCommitToRepo(repo, firstBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "The first branches comment"); // Change file in first branch

repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);
// Commit with ONE new file to second branch (FirstBranch and SecondBranch now point to separate commits that both have the same parent commit).
AddFileCommitToRepo(repo, secondBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "The second branches comment"); // Change file in second branch
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch()
repo.Reset(ResetMode.Hard);
repo.RemoveUntrackedFiles();

repo.Checkout("test");
Commands.Checkout(repo, "test");
Assert.Equal(2, repo.Commits.Count());
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", repo.Commits.First().Id.Sha);

repo.Checkout("master");
Commands.Checkout(repo, "master");
Assert.Equal(9, repo.Commits.Count());
Assert.Equal("32eab9cb1f450b5fe7ab663462b77d7f4b703344", repo.Commits.First().Id.Sha);
}
Expand Down Expand Up @@ -274,7 +274,7 @@ public void CanEnumerateFromDetachedHead()
repoClone.RemoveUntrackedFiles();

string headSha = repoClone.Head.Tip.Sha;
repoClone.Checkout(headSha);
Commands.Checkout(repoClone, headSha);

AssertEnumerationOfCommitsInRepo(repoClone,
repo => new CommitFilter { IncludeReachableFrom = repo.Head },
Expand Down Expand Up @@ -708,7 +708,7 @@ public void CanCommitALittleBit()
Assert.Equal(reflogEntry.To, repo.Refs.Log("HEAD").First().From);

Branch firstCommitBranch = repo.CreateBranch("davidfowl-rules", commit);
repo.Checkout(firstCommitBranch);
Commands.Checkout(repo, firstCommitBranch);

File.WriteAllText(filePath, "davidfowl commits!\n");

Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/DescribeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public void CanFollowFirstParent()
repo.ApplyTag("firstParentTag");

// Make a later tag on branch
repo.Checkout(branch);
Commands.Checkout(repo, branch);
repo.Commit("B", Constants.Signature, Constants.Signature, new CommitOptions { AllowEmptyCommit = true });
repo.ApplyTag("mostRecentTag");

repo.Checkout("master");
Commands.Checkout(repo, "master");
repo.Commit("C", Constants.Signature, Constants.Signature, new CommitOptions { AllowEmptyCommit = true });
repo.Merge(branch, Constants.Signature, new MergeOptions() { FastForwardStrategy = FastForwardStrategy.NoFastForward });

Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/FileHistoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void CanFollowBranches(string specificRepoPath)
dummy, master9);

repo.CreateBranch("master", master10);
repo.Checkout("master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
Commands.Checkout(repo, "master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });

// Test --date-order.
var timeHistory = repo.Commits.QueryBy(path,
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/FilterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void CanFilterLargeFiles()
Commands.Stage(repo, contentFile.Name);
repo.Commit("test", Constants.Signature, Constants.Signature);
contentFile.Delete();
repo.Checkout("HEAD", new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
Commands.Checkout(repo, "HEAD", new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });
}

contentFile = new FileInfo(filePath);
Expand Down Expand Up @@ -392,17 +392,17 @@ private FileInfo CheckoutFileForSmudge(string repoPath, string branchName, strin

expectedPath = CommitFileOnBranch(repo, branchName, content);

repo.Checkout("master");
Commands.Checkout(repo, "master");

repo.Checkout(branchName);
Commands.Checkout(repo, branchName);
}
return expectedPath;
}

private static FileInfo CommitFileOnBranch(Repository repo, string branchName, String content)
{
var branch = repo.CreateBranch(branchName);
repo.Checkout(branch.FriendlyName);
Commands.Checkout(repo, branch.FriendlyName);

FileInfo expectedPath = StageNewFile(repo, content);
repo.Commit("Commit", Constants.Signature, Constants.Signature);
Expand Down
12 changes: 6 additions & 6 deletions LibGit2Sharp.Tests/FilterSubstitutionCipherFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public void SmugdeIsNotCalledForFileWhichDoesNotMatchAnAttributeEntry()
Assert.Equal(0, filter.SmudgeCalledCount);

var branch = repo.CreateBranch("delete-files");
repo.Checkout(branch.FriendlyName);
Commands.Checkout(repo, branch.FriendlyName);

DeleteFile(repo, fileName);

repo.Checkout("master");
Commands.Checkout(repo, "master");

var fileContents = ReadTextFromFile(repo, fileName);
Assert.Equal(1, filter.SmudgeCalledCount);
Expand Down Expand Up @@ -73,11 +73,11 @@ public void CorrectlyEncodesAndDecodesInput()
Assert.Equal(0, filter.SmudgeCalledCount);

var branch = repo.CreateBranch("delete-files");
repo.Checkout(branch.FriendlyName);
Commands.Checkout(repo, branch.FriendlyName);

DeleteFile(repo, fileName);

repo.Checkout("master");
Commands.Checkout(repo, "master");

var fileContents = ReadTextFromFile(repo, fileName);
Assert.Equal(1, filter.SmudgeCalledCount);
Expand Down Expand Up @@ -176,11 +176,11 @@ public void SmudgeIsCalledIfAttributeEntryMatches(string filterAttribute, string
CommitOnBranchAndReturnDatabaseBlob(repo, fileName, decodedInput);

var branch = repo.CreateBranch("delete-files");
repo.Checkout(branch.FriendlyName);
Commands.Checkout(repo, branch.FriendlyName);

DeleteFile(repo, fileName);

repo.Checkout("master");
Commands.Checkout(repo, "master");

Assert.Equal(smudgeCount, filter.SmudgeCalledCount);
}
Expand Down
30 changes: 15 additions & 15 deletions LibGit2Sharp.Tests/MergeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void CanMergeRepoNonFastForward(bool shouldMergeOccurInDetachedHeadState)
using (var repo = new Repository(path))
{
var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);
var originalTreeCount = firstBranch.Tip.Tree.Count;

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
Expand All @@ -106,11 +106,11 @@ public void CanMergeRepoNonFastForward(bool shouldMergeOccurInDetachedHeadState)
if (shouldMergeOccurInDetachedHeadState)
{
// Detaches HEAD
repo.Checkout(secondBranch.Tip);
Commands.Checkout(repo, secondBranch.Tip);
}
else
{
repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);
}

// Commit with ONE new file to second branch (FirstBranch and SecondBranch now point to separate commits that both have the same parent commit).
Expand Down Expand Up @@ -142,14 +142,14 @@ public void IsUpToDateMerge()
using (var repo = new Repository(path))
{
var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
AddFileCommitToRepo(repo, sharedBranchFileName);

var secondBranch = repo.CreateBranch("SecondBranch");

repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);

MergeResult mergeResult = repo.Merge(repo.Branches["FirstBranch"].Tip, Constants.Signature);

Expand All @@ -175,7 +175,7 @@ public void CanFastForwardRepos(bool shouldMergeOccurInDetachedHeadState)
repo.RemoveUntrackedFiles();

var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
AddFileCommitToRepo(repo, sharedBranchFileName);
Expand All @@ -188,11 +188,11 @@ public void CanFastForwardRepos(bool shouldMergeOccurInDetachedHeadState)
if (shouldMergeOccurInDetachedHeadState)
{
// Detaches HEAD
repo.Checkout(secondBranch.Tip);
Commands.Checkout(repo, secondBranch.Tip);
}
else
{
repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);
}

Assert.Equal(shouldMergeOccurInDetachedHeadState, repo.Info.IsHeadDetached);
Expand Down Expand Up @@ -226,7 +226,7 @@ public void ConflictingMergeRepos()
using (var repo = new Repository(path))
{
var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
AddFileCommitToRepo(repo, sharedBranchFileName);
Expand All @@ -236,7 +236,7 @@ public void ConflictingMergeRepos()
AddFileCommitToRepo(repo, firstBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "The first branches comment"); // Change file in first branch

repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);
// Commit with ONE new file to second branch (FirstBranch and SecondBranch now point to separate commits that both have the same parent commit).
AddFileCommitToRepo(repo, secondBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "The second branches comment"); // Change file in second branch
Expand Down Expand Up @@ -266,7 +266,7 @@ public void ConflictingMergeReposBinary()
using (var repo = new Repository(path))
{
var firstBranch = repo.CreateBranch("FirstBranch");
repo.Checkout(firstBranch);
Commands.Checkout(repo, firstBranch);

// Commit with ONE new file to both first & second branch (SecondBranch is created on this commit).
AddFileCommitToRepo(repo, sharedBranchFileName);
Expand All @@ -276,7 +276,7 @@ public void ConflictingMergeReposBinary()
AddFileCommitToRepo(repo, firstBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "\0The first branches comment\0"); // Change file in first branch

repo.Checkout(secondBranch);
Commands.Checkout(repo, secondBranch);
// Commit with ONE new file to second branch (FirstBranch and SecondBranch now point to separate commits that both have the same parent commit).
AddFileCommitToRepo(repo, secondBranchFileName);
AddFileCommitToRepo(repo, sharedBranchFileName, "\0The second branches comment\0"); // Change file in second branch
Expand Down Expand Up @@ -325,7 +325,7 @@ public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fast
{
if(fromDetachedHead)
{
repo.Checkout(repo.Head.Tip.Id.Sha);
Commands.Checkout(repo, repo.Head.Tip.Id.Sha);
}

Commit commitToMerge = repo.Branches["fast_forward"].Tip;
Expand All @@ -351,7 +351,7 @@ public void CanNonFastForwardMergeCommit(bool fromDetachedHead, FastForwardStrat
{
if (fromDetachedHead)
{
repo.Checkout(repo.Head.Tip.Id.Sha);
Commands.Checkout(repo, repo.Head.Tip.Id.Sha);
}

Commit commitToMerge = repo.Branches["normal_merge"].Tip;
Expand Down Expand Up @@ -469,7 +469,7 @@ public void MergeCanDetectRenames()
string repoPath = SandboxMergeTestRepo();
using (var repo = new Repository(repoPath))
{
Branch currentBranch = repo.Checkout("rename_source");
Branch currentBranch = Commands.Checkout(repo, "rename_source");
Assert.NotNull(currentBranch);

Branch branchToMerge = repo.Branches["rename"];
Expand Down
Loading