Skip to content

Commit

Permalink
Merge pull request #2086 from libgit2/native-binaries
Browse files Browse the repository at this point in the history
Update LibGit2Sharp.NativeBinaries to 2.0.322
  • Loading branch information
bording authored Mar 17, 2024
2 parents bfdb02a + a373623 commit 2b84c8e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
75 changes: 40 additions & 35 deletions LibGit2Sharp.Tests/CommitFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
using System.IO;
using System.Linq;
using System.Text;
using LibGit2Sharp.Core;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -150,10 +148,10 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
using (var repo = new Repository(path))
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}))
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}))
{
Assert.NotNull(commit);
Assert.StartsWith(reversedShas[count], commit.Sha);
Expand All @@ -170,10 +168,10 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
using (var repo = new Repository(path))
{
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}).ToList();
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time | CommitSortStrategies.Reverse
}).ToList();
foreach (Commit commit in commits)
{
Assert.NotNull(commit);
Expand Down Expand Up @@ -216,10 +214,10 @@ public void CanEnumerateCommitsWithTimeSorting()
using (var repo = new Repository(path))
{
foreach (Commit commit in repo.Commits.QueryBy(new CommitFilter
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time
}))
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Time
}))
{
Assert.NotNull(commit);
Assert.StartsWith(expectedShas[count], commit.Sha);
Expand All @@ -236,10 +234,10 @@ public void CanEnumerateCommitsWithTopoSorting()
using (var repo = new Repository(path))
{
List<Commit> commits = repo.Commits.QueryBy(new CommitFilter
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Topological
}).ToList();
{
IncludeReachableFrom = "a4a7dce85cf63874e984719f4fdd239f5145052f",
SortBy = CommitSortStrategies.Topological
}).ToList();
foreach (Commit commit in commits)
{
Assert.NotNull(commit);
Expand Down Expand Up @@ -331,9 +329,12 @@ public void CanEnumerateCommitsFromTwoHeads()
public void CanEnumerateCommitsFromMixedStartingPoints()
{
AssertEnumerationOfCommits(
repo => new CommitFilter { IncludeReachableFrom = new object[] { repo.Branches["br2"],
repo => new CommitFilter
{
IncludeReachableFrom = new object[] { repo.Branches["br2"],
"refs/heads/master",
new ObjectId("e90810b8df3e80c413d903f631643c716887138d") } },
new ObjectId("e90810b8df3e80c413d903f631643c716887138d") }
},
new[]
{
"4c062a6", "e90810b", "6dcf9bf", "a4a7dce",
Expand Down Expand Up @@ -389,9 +390,9 @@ public void CanEnumerateAllCommits()
{
AssertEnumerationOfCommits(
repo => new CommitFilter
{
IncludeReachableFrom = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
},
{
IncludeReachableFrom = repo.Refs.OrderBy(r => r.CanonicalName, StringComparer.Ordinal),
},
new[]
{
"44d5d18", "bb65291", "532740a", "503a16f", "3dfd6fd",
Expand Down Expand Up @@ -680,8 +681,12 @@ public void CanCommitALittleBit()
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);

var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, before, now);
// When verifying the timestamp range, give a little more room on the range.
// Git or file system datetime truncation seems to cause these stamps to jump up to a second earlier
// than we expect. See https://github.com/libgit2/libgit2sharp/issues/1764
var low = before - TimeSpan.FromSeconds(1);
var high = DateTimeOffset.Now.TruncateMilliseconds() + TimeSpan.FromSeconds(1);
Assert.InRange(reflogEntry.Committer.When, low, high);

Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Expand Down Expand Up @@ -859,21 +864,21 @@ public void CanRetrieveChildrenOfASpecificCommit()
const string parentSha = "5b5b025afb0b4c913b4c338a42934a3863bf3644";

var filter = new CommitFilter
{
/* Revwalk from all the refs (git log --all) ... */
IncludeReachableFrom = repo.Refs,
{
/* Revwalk from all the refs (git log --all) ... */
IncludeReachableFrom = repo.Refs,

/* ... and stop when the parent is reached */
ExcludeReachableFrom = parentSha
};
/* ... and stop when the parent is reached */
ExcludeReachableFrom = parentSha
};

var commits = repo.Commits.QueryBy(filter);

var children = from c in commits
from p in c.Parents
let pId = p.Id
where pId.Sha == parentSha
select c;
from p in c.Parents
let pId = p.Id
where pId.Sha == parentSha
select c;

var expectedChildren = new[] { "c47800c7266a2be04c571c04d5a6614691ea99bd",
"4a202b346bb0fb0db7eff3cffeb3c70babbd2045" };
Expand Down
23 changes: 15 additions & 8 deletions LibGit2Sharp.Tests/ReflogFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;

namespace LibGit2Sharp.Tests
{
Expand Down Expand Up @@ -59,7 +58,7 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference()

var identity = Constants.Identity;

using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = identity }))
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = identity }))
{
// setup refs as HEAD => unit_test => master
var newRef = repo.Refs.Add("refs/heads/unit_test", "refs/heads/master");
Expand All @@ -84,8 +83,12 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference()
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);

var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, before, now);
// When verifying the timestamp range, give a little more room on the range.
// Git or file system datetime truncation seems to cause these stamps to jump up to a second earlier
// than we expect. See https://github.com/libgit2/libgit2sharp/issues/1764
var low = before - TimeSpan.FromSeconds(1);
var high = DateTimeOffset.Now.TruncateMilliseconds() + TimeSpan.FromSeconds(1);
Assert.InRange(reflogEntry.Committer.When, low, high);

Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Expand All @@ -97,7 +100,7 @@ public void CommitShouldCreateReflogEntryOnHeadAndOnTargetedDirectReference()
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);

Assert.InRange(reflogEntry.Committer.When, before, now);
Assert.InRange(reflogEntry.Committer.When, low, high);

Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(ObjectId.Zero, reflogEntry.From);
Expand Down Expand Up @@ -160,8 +163,12 @@ public void CommitOnDetachedHeadShouldInsertReflogEntry()
Assert.Equal(identity.Name, reflogEntry.Committer.Name);
Assert.Equal(identity.Email, reflogEntry.Committer.Email);

var now = DateTimeOffset.Now;
Assert.InRange(reflogEntry.Committer.When, before, now);
// When verifying the timestamp range, give a little more room on the range.
// Git or file system datetime truncation seems to cause these stamps to jump up to a second earlier
// than we expect. See https://github.com/libgit2/libgit2sharp/issues/1764
var low = before - TimeSpan.FromSeconds(1);
var high = DateTimeOffset.Now.TruncateMilliseconds() + TimeSpan.FromSeconds(1);
Assert.InRange(reflogEntry.Committer.When, low, high);

Assert.Equal(commit.Id, reflogEntry.To);
Assert.Equal(string.Format("commit: {0}", commitMessage), repo.Refs.Log("HEAD").First().Message);
Expand Down Expand Up @@ -202,7 +209,7 @@ public void AppendingToReflogDependsOnCoreLogAllRefUpdatesSetting(bool isBare, b
public void UnsignedMethodsWriteCorrectlyToTheReflog()
{
var repoPath = InitNewRepository(true);
using (var repo = new Repository(repoPath, new RepositoryOptions{ Identity = Constants.Identity }))
using (var repo = new Repository(repoPath, new RepositoryOptions { Identity = Constants.Identity }))
{
EnableRefLog(repo);

Expand Down
6 changes: 4 additions & 2 deletions LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,12 @@ protected static void AssertRefLogEntry(IRepository repo, string canonicalName,

Assert.Equal(committer.Email, reflogEntry.Committer.Email);

// When verifying the timestamp range, give a little more room on the 'before' side.
// When verifying the timestamp range, give a little more room on the range.
// Git or file system datetime truncation seems to cause these stamps to jump up to a second earlier
// than we expect. See https://github.com/libgit2/libgit2sharp/issues/1764
Assert.InRange(reflogEntry.Committer.When, before - TimeSpan.FromSeconds(1), DateTimeOffset.Now);
var low = before - TimeSpan.FromSeconds(1);
var high = DateTimeOffset.Now.TruncateMilliseconds() + TimeSpan.FromSeconds(1);
Assert.InRange(reflogEntry.Committer.When, low, high);
}

protected static void EnableRefLog(IRepository repository, bool enable = true)
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp/LibGit2Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.321]" PrivateAssets="none" />
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.322]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="MinVer" Version="5.0.0" PrivateAssets="all" />
</ItemGroup>
Expand Down

0 comments on commit 2b84c8e

Please sign in to comment.