Skip to content

Commit cf70b9d

Browse files
author
J Wyman
committed
Fixes RebaseFixture tests by adding .gitattributes file to repo
1 parent 2587d57 commit cf70b9d

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

LibGit2Sharp.Tests/FilterFixture.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ private unsafe bool CharArrayAreEqual(char[] array1, char[] array2, int count)
304304
return true;
305305
}
306306

307-
308307
private FileInfo CheckoutFileForSmudge(string repoPath, string branchName, string content)
309308
{
310309
FileInfo expectedPath;
@@ -350,11 +349,6 @@ private Repository CreateTestRepository(string path)
350349
return repository;
351350
}
352351

353-
private static void CreateAttributesFile(IRepository repo, string attributeEntry)
354-
{
355-
Touch(repo.Info.WorkingDirectory, ".gitattributes", attributeEntry);
356-
}
357-
358352
class EmptyFilter : Filter
359353
{
360354
public EmptyFilter(string name, IEnumerable<FilterAttributeEntry> attributes)

LibGit2Sharp.Tests/RebaseFixture.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public void CanRebase(string initialBranchName,
6262

6363
RebaseOptions options = new RebaseOptions()
6464
{
65-
RebaseStepStarting = x =>
66-
{
67-
beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
68-
totalStepCountCorrect &= (x.TotalStepCount == stepCount);
69-
beforeStepCallCount++;
70-
PreRebaseCommits.Add(x.StepInfo.Commit);
71-
},
65+
RebaseStepStarting = x =>
66+
{
67+
beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
68+
totalStepCountCorrect &= (x.TotalStepCount == stepCount);
69+
beforeStepCallCount++;
70+
PreRebaseCommits.Add(x.StepInfo.Commit);
71+
},
7272
RebaseStepCompleted = x =>
7373
{
7474
afterRebaseStepCountCorrect &= (afterStepCallCount == x.CompletedStepIndex);
@@ -262,15 +262,15 @@ public void VerifyRebaseDetailed()
262262

263263
List<ObjectId> expectedTreeIds = new List<ObjectId>()
264264
{
265-
new ObjectId("447bad85bcc1882037848370620a6f88e8ee264e"),
266-
new ObjectId("3b0fc846952496a64b6149064cde21215daca8f8"),
267-
new ObjectId("a2d114246012daf3ef8e7ccbfbe91889a24e1e60"),
265+
new ObjectId("e20530e760c7e3009e2a482d8bcb0cd69f1ffb65"),
266+
new ObjectId("3a3b0dce3266801cf90eaa58f4b5b1f7955a49be"),
267+
new ObjectId("27559b63dd0afcb93c2058b96e91d9266466c3c4"),
268268
};
269269

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

272272
Assert.Equal(3, rebasedCommits.Count);
273-
for(int i = 0; i < 3; i++)
273+
for (int i = 0; i < 3; i++)
274274
{
275275
Assert.Equal(expectedTreeIds[i], rebasedCommits[i].Tree.Id);
276276
Assert.Equal(Constants.Signature.Name, rebasedCommits[i].Author.Name);
@@ -602,7 +602,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
602602

603603
repo.Checkout(topicBranch1Name);
604604

605-
Branch topicBranch1Prime = repo.CreateBranch(topicBranch1PrimeName, masterBranch1Name);
605+
Branch topicBranch1Prime = repo.CreateBranch(topicBranch1PrimeName, masterBranch1Name);
606606

607607
string newFileRelativePath = "new_file.txt";
608608
Touch(repo.Info.WorkingDirectory, newFileRelativePath, "New Content");
@@ -631,7 +631,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
631631
};
632632

633633
repo.Rebase.Start(null, upstreamBranch, null, Constants.Identity2, options);
634-
ObjectId secondCommitExpectedTreeId = new ObjectId("ac04bf04980c9be72f64ba77fd0d9088a40ed681");
634+
ObjectId secondCommitExpectedTreeId = new ObjectId("7845bcdf89faf2b1f992758962b333aff874ce51");
635635
Signature secondCommitAuthorSignature = Constants.Signature;
636636
Identity secondCommitCommiterIdentity = Constants.Identity2;
637637

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

703+
CreateAttributesFile(repo, "* text=auto\n.gitattributes eol=lf");
704+
repo.Stage(".gitattributes");
705+
commit = repo.Commit("setup", Constants.Signature, Constants.Signature, new CommitOptions());
706+
703707
Touch(workdir, filePathA, fileContentA1);
704708
repo.Stage(filePathA);
705709
commit = repo.Commit("commit 1", Constants.Signature, Constants.Signature, new CommitOptions());

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static BaseFixture()
4949
protected static DateTimeOffset TruncateSubSeconds(DateTimeOffset dto)
5050
{
5151
int seconds = dto.ToSecondsSinceEpoch();
52-
return Epoch.ToDateTimeOffset(seconds, (int) dto.Offset.TotalMinutes);
52+
return Epoch.ToDateTimeOffset(seconds, (int)dto.Offset.TotalMinutes);
5353
}
5454

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

261-
var version = (string) displayName.Invoke(null, null);
261+
var version = (string)displayName.Invoke(null, null);
262262

263263
System.Version current;
264264

@@ -460,5 +460,10 @@ public void AssertBelongsToARepository<T>(IRepository repo, T instance)
460460
{
461461
Assert.Same(repo, ((IBelongToARepository)instance).Repository);
462462
}
463+
464+
protected void CreateAttributesFile(IRepository repo, string attributeEntry)
465+
{
466+
Touch(repo.Info.WorkingDirectory, ".gitattributes", attributeEntry);
467+
}
463468
}
464469
}

0 commit comments

Comments
 (0)