Skip to content

Refactor away TemporaryCloneOfTestRepo #386

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 8, 2013
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
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/AttributesFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class AttributesFixture : BaseFixture
[Fact]
public void StagingHonorsTheAttributesFiles()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
CreateAttributesFile(repo);

Expand Down
90 changes: 42 additions & 48 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class BranchFixture : BaseFixture
[InlineData("Ångström")]
public void CanCreateBranch(string name)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
Assert.NotNull(newBranch);
Expand All @@ -35,8 +35,8 @@ public void CanCreateBranch(string name)
[Fact]
public void CanCreateBranchUsingAbbreviatedSha()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "be3563a");
Expand All @@ -48,8 +48,8 @@ public void CanCreateBranchUsingAbbreviatedSha()
[Fact]
public void CanCreateBranchFromImplicitHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name);
Expand All @@ -66,8 +66,8 @@ public void CanCreateBranchFromImplicitHead()
[Fact]
public void CanCreateBranchFromExplicitHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "HEAD");
Expand All @@ -79,8 +79,8 @@ public void CanCreateBranchFromExplicitHead()
[Fact]
public void CanCreateBranchFromCommit()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "unit_test";
var commit = repo.Lookup<Commit>("HEAD");
Expand All @@ -93,8 +93,8 @@ public void CanCreateBranchFromCommit()
[Fact]
public void CanCreateBranchFromRevparseSpec()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "revparse_branch";
var target = repo.Lookup<Commit>("master~2");
Expand All @@ -107,8 +107,8 @@ public void CanCreateBranchFromRevparseSpec()
[Fact]
public void CreatingABranchFromATagPeelsToTheCommit()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "i-peel-tag";
Branch newBranch = repo.CreateBranch(name, "refs/tags/test");
Expand All @@ -120,8 +120,8 @@ public void CreatingABranchFromATagPeelsToTheCommit()
[Fact]
public void CreatingABranchTriggersTheCreationOfADirectReference()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
Branch newBranch = repo.CreateBranch("clone-of-master");
Assert.False(newBranch.IsCurrentRepositoryHead);
Expand Down Expand Up @@ -193,9 +193,8 @@ public void CanListAllBranches()
[Fact]
public void CanListBranchesWithRemoteAndLocalBranchWithSameShortName()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
// Create a local branch with the same short name as a remote branch.
repo.Branches.Add("origin/master", repo.Branches["origin/test"].Tip);
Expand Down Expand Up @@ -316,8 +315,8 @@ public void CanLookupLocalBranch()
[Fact]
public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
const string name = "Ångström";
Branch newBranch = repo.CreateBranch(name, "be3563a");
Expand Down Expand Up @@ -368,8 +367,8 @@ public void CanGetInformationFromUnbornBranch()
[Fact]
public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBranch()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
repo.Refs.UpdateTarget("refs/remotes/origin/master", "origin/test");
Expand Down Expand Up @@ -460,9 +459,8 @@ public void CanSetUpstreamBranch()
const string testBranchName = "branchToSetUpstreamInfoFor";
const string upstreamBranchName = "refs/remotes/origin/master";

TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.CreateBranch(testBranchName);
Assert.False(branch.IsTracking);
Expand Down Expand Up @@ -494,9 +492,8 @@ public void CanSetUpstreamMergeBranch()
const string upstreamBranchName = "refs/remotes/origin/master";
const string upstreamRemoteName = "origin";

TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.CreateBranch(testBranchName);
Assert.False(branch.IsTracking);
Expand Down Expand Up @@ -524,9 +521,8 @@ public void CanSetLocalUpstreamBranch()
const string testBranchName = "branchToSetUpstreamInfoFor";
const string upstreamBranchName = "refs/heads/master";

TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.CreateBranch(testBranchName);
Assert.False(branch.IsTracking);
Expand Down Expand Up @@ -562,8 +558,8 @@ public void CanUnsetUpstreamBranch()
const string testBranchName = "branchToSetUpstreamInfoFor";
const string upstreamBranchName = "refs/remotes/origin/master";

TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo.CreateBranch(testBranchName);
Assert.False(branch.IsTracking);
Expand Down Expand Up @@ -594,9 +590,8 @@ public void CanWalkCommitsFromBranch()

private void AssertRemoval(string branchName, bool isRemote, bool shouldPreviouslyAssertExistence)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
if (shouldPreviouslyAssertExistence)
{
Expand All @@ -622,9 +617,8 @@ public void CanRemoveAnExistingNamedBranch(string branchName, bool isRemote)
[InlineData("origin/br2")]
public void CanRemoveAnExistingBranch(string branchName)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch curBranch = repo.Branches[branchName];

Expand Down Expand Up @@ -693,8 +687,8 @@ public void OnlyOneBranchIsTheHead()
[Fact]
public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["refs/heads/master"];

Expand All @@ -706,8 +700,8 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
[Fact]
public void CanMoveABranch()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
Assert.Null(repo.Branches["br3"]);

Expand All @@ -731,8 +725,8 @@ public void BlindlyMovingABranchOverAnExistingOneThrows()
[Fact]
public void CanMoveABranchWhileOverwritingAnExistingOne()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
using (var repo = new Repository(path.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
Branch test = repo.Branches["test"];
Assert.NotNull(test);
Expand All @@ -756,8 +750,8 @@ public void CanMoveABranchWhileOverwritingAnExistingOne()
[Fact]
public void DetachedHeadIsNotATrackingBranch()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.DirectoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
repo.Reset(ResetOptions.Hard);
repo.RemoveUntrackedFiles();
Expand Down
25 changes: 12 additions & 13 deletions LibGit2Sharp.Tests/CheckoutFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class CheckoutFixture : BaseFixture
[InlineData("diff-test-cases")]
public void CanCheckoutAnExistingBranch(string branchName)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
Expand Down Expand Up @@ -52,8 +52,8 @@ public void CanCheckoutAnExistingBranch(string branchName)
[InlineData("diff-test-cases")]
public void CanCheckoutAnExistingBranchByName(string branchName)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
Expand Down Expand Up @@ -82,8 +82,8 @@ public void CanCheckoutAnExistingBranchByName(string branchName)
[InlineData("refs/tags/lw")]
public void CanCheckoutAnArbitraryCommit(string commitPointer)
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
Expand Down Expand Up @@ -202,9 +202,8 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges()
// 4) Create conflicting change
// 5) Forcefully checkout master

TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);

using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
string fileFullPath = Path.Combine(repo.Info.WorkingDirectory, originalFilePath);
Branch master = repo.Branches["master"];
Expand Down Expand Up @@ -556,8 +555,8 @@ public void CheckoutBranchSnapshot()
[Fact]
public void CheckingOutRemoteBranchResultsInDetachedHead()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
Branch master = repo.Branches["master"];
Assert.True(master.IsCurrentRepositoryHead);
Expand All @@ -576,8 +575,8 @@ public void CheckingOutRemoteBranchResultsInDetachedHead()
[Fact]
public void CheckingOutABranchDoesNotAlterBinaryFiles()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
// $ git hash-object square-logo.png
// b758c5bc1c8117c2a4c545dae2903e36360501c5
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/CleanFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class CleanFixture : BaseFixture
[Fact]
public void CanCleanWorkingDirectory()
{
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
// Verify that there are the expected number of entries and untracked files
Assert.Equal(6, repo.Index.RetrieveStatus().Count());
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/CloneFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void AssertLocalClone(string path)
public void CanLocallyCloneAndCommitAndPush()
{
var scd = BuildSelfCleaningDirectory();
using (var originalRepo = new Repository(BuildTemporaryCloneOfTestRepo(BareTestRepoPath).RepositoryPath))
using (var originalRepo = new Repository(CloneBareTestRepo()))
using (Repository clonedRepo = Repository.Clone(originalRepo.Info.Path, scd.RootedDirectoryPath))
{
Remote remote = clonedRepo.Network.Remotes["origin"];
Expand Down
10 changes: 4 additions & 6 deletions LibGit2Sharp.Tests/CommitAncestorFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ public void CanFindCommonAncestorForSeveralCommits()
[Fact]
public void CannotFindAncestorForTwoCommmitsWithoutCommonAncestor()
{
var scd = BuildTemporaryCloneOfTestRepo();

using (var repo = new Repository(scd.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
var first = repo.Lookup<Commit>("4c062a6361ae6959e06292c1fa5e2822d9c96345");
var second = repo.Lookup<Commit>("be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
Expand All @@ -97,9 +96,8 @@ public void CannotFindAncestorForTwoCommmitsWithoutCommonAncestor()
[Fact]
public void CannotFindCommonAncestorForSeveralCommmitsWithoutCommonAncestor()
{
var scd = BuildTemporaryCloneOfTestRepo();

using (var repo = new Repository(scd.RepositoryPath))
string path = CloneBareTestRepo();
using (var repo = new Repository(path))
{
var first = repo.Lookup<Commit>("4c062a6361ae6959e06292c1fa5e2822d9c96345");

Expand Down
Loading