Skip to content

Fixes RebaseFixture tests by adding .gitattributes file to repo #1136

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

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 6 deletions LibGit2Sharp.Tests/FilterFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ private unsafe bool CharArrayAreEqual(char[] array1, char[] array2, int count)
return true;
}


private FileInfo CheckoutFileForSmudge(string repoPath, string branchName, string content)
{
FileInfo expectedPath;
Expand Down Expand Up @@ -350,11 +349,6 @@ private Repository CreateTestRepository(string path)
return repository;
}

private static void CreateAttributesFile(IRepository repo, string attributeEntry)
{
Touch(repo.Info.WorkingDirectory, ".gitattributes", attributeEntry);
}

class EmptyFilter : Filter
{
public EmptyFilter(string name, IEnumerable<FilterAttributeEntry> attributes)
Expand Down
30 changes: 17 additions & 13 deletions LibGit2Sharp.Tests/RebaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public void CanRebase(string initialBranchName,

RebaseOptions options = new RebaseOptions()
{
RebaseStepStarting = x =>
{
beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
totalStepCountCorrect &= (x.TotalStepCount == stepCount);
beforeStepCallCount++;
PreRebaseCommits.Add(x.StepInfo.Commit);
},
RebaseStepStarting = x =>
{
beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
totalStepCountCorrect &= (x.TotalStepCount == stepCount);
beforeStepCallCount++;
PreRebaseCommits.Add(x.StepInfo.Commit);
},
RebaseStepCompleted = x =>
{
afterRebaseStepCountCorrect &= (afterStepCallCount == x.CompletedStepIndex);
Expand Down Expand Up @@ -262,15 +262,15 @@ public void VerifyRebaseDetailed()

List<ObjectId> expectedTreeIds = new List<ObjectId>()
{
new ObjectId("447bad85bcc1882037848370620a6f88e8ee264e"),
new ObjectId("3b0fc846952496a64b6149064cde21215daca8f8"),
new ObjectId("a2d114246012daf3ef8e7ccbfbe91889a24e1e60"),
new ObjectId("e20530e760c7e3009e2a482d8bcb0cd69f1ffb65"),
new ObjectId("3a3b0dce3266801cf90eaa58f4b5b1f7955a49be"),
new ObjectId("27559b63dd0afcb93c2058b96e91d9266466c3c4"),
};

List<Commit> rebasedCommits = repo.Commits.QueryBy(commitFilter).ToList();

Assert.Equal(3, rebasedCommits.Count);
for(int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
Assert.Equal(expectedTreeIds[i], rebasedCommits[i].Tree.Id);
Assert.Equal(Constants.Signature.Name, rebasedCommits[i].Author.Name);
Expand Down Expand Up @@ -602,7 +602,7 @@ public void CanRebaseHandlePatchAlreadyApplied()

repo.Checkout(topicBranch1Name);

Branch topicBranch1Prime = repo.CreateBranch(topicBranch1PrimeName, masterBranch1Name);
Branch topicBranch1Prime = repo.CreateBranch(topicBranch1PrimeName, masterBranch1Name);

string newFileRelativePath = "new_file.txt";
Touch(repo.Info.WorkingDirectory, newFileRelativePath, "New Content");
Expand Down Expand Up @@ -631,7 +631,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
};

repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
ObjectId secondCommitExpectedTreeId = new ObjectId("ac04bf04980c9be72f64ba77fd0d9088a40ed681");
ObjectId secondCommitExpectedTreeId = new ObjectId("7845bcdf89faf2b1f992758962b333aff874ce51");
Signature secondCommitAuthorSignature = Constants.Signature;
Identity secondCommitCommiterIdentity = Constants.Identity2;

Expand Down Expand Up @@ -700,6 +700,10 @@ private void ConstructRebaseTestRepository(Repository repo)
string workdir = repo.Info.WorkingDirectory;
Commit commit = null;

CreateAttributesFile(repo, "* text=auto\n.gitattributes eol=lf");
repo.Stage(".gitattributes");
commit = repo.Commit("setup", Constants.Signature, Constants.Signature, new CommitOptions());

Touch(workdir, filePathA, fileContentA1);
repo.Stage(filePathA);
commit = repo.Commit("commit 1", Constants.Signature, Constants.Signature, new CommitOptions());
Expand Down
9 changes: 7 additions & 2 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static BaseFixture()
protected static DateTimeOffset TruncateSubSeconds(DateTimeOffset dto)
{
int seconds = dto.ToSecondsSinceEpoch();
return Epoch.ToDateTimeOffset(seconds, (int) dto.Offset.TotalMinutes);
return Epoch.ToDateTimeOffset(seconds, (int)dto.Offset.TotalMinutes);
}

private static void SetUpTestEnvironment()
Expand Down Expand Up @@ -258,7 +258,7 @@ protected void RequiresDotNetOrMonoGreaterThanOrEqualTo(System.Version minimumVe
throw new InvalidOperationException("Cannot access Mono.RunTime.GetDisplayName() method.");
}

var version = (string) displayName.Invoke(null, null);
var version = (string)displayName.Invoke(null, null);

System.Version current;

Expand Down Expand Up @@ -460,5 +460,10 @@ public void AssertBelongsToARepository<T>(IRepository repo, T instance)
{
Assert.Same(repo, ((IBelongToARepository)instance).Repository);
}

protected void CreateAttributesFile(IRepository repo, string attributeEntry)
{
Touch(repo.Info.WorkingDirectory, ".gitattributes", attributeEntry);
}
}
}