Skip to content

Commit

Permalink
Updated to GitReader 0.12.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Jun 11, 2023
1 parent 4614b87 commit 636f6e5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
9 changes: 5 additions & 4 deletions CenterCLR.RelaxVersioner.Core/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using GitReader.Structures;
Expand All @@ -35,9 +36,9 @@ public override string ToString() =>
}

public static async Task<Version> LookupVersionLabelAsync(
Branch targetBranch)
Branch targetBranch, CancellationToken ct)
{
var topCommit = targetBranch.Head;
var topCommit = await targetBranch.GetHeadCommitAsync(ct);

var reached = new HashSet<Commit>();
var scheduled = new Stack<TargetCommit>();
Expand All @@ -62,7 +63,7 @@ public static async Task<Version> LookupVersionLabelAsync(
}

// If found be applied tags at this commit:
if (currentCommit.Tags.Length >= 1)
if (currentCommit.Tags.Count >= 1)
{
var filteredTags = currentCommit.Tags.
Select(tag => Version.TryParse(tag.Name, out var version) ? (Version?)version : null).
Expand All @@ -78,7 +79,7 @@ public static async Task<Version> LookupVersionLabelAsync(
}

// Found parents.
if (await currentCommit.GetParentCommitsAsync() is { Length: >= 1 } parents)
if (await currentCommit.GetParentCommitsAsync(ct) is { Length: >= 1 } parents)
{
// Dive parent commit.
currentDepth++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitReader" Version="0.7.0" />
<PackageReference Include="GitReader" Version="0.12.0" />
<PackageReference Include="NamingFormatter" Version="2.2.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="RelaxVersioner" Version="2.14.0" PrivateAssets="all" />
Expand Down
18 changes: 12 additions & 6 deletions CenterCLR.RelaxVersioner.Core/Processor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using GitReader.Structures;

using RelaxVersioner.Writers;
using System.Threading;

namespace RelaxVersioner;

Expand Down Expand Up @@ -78,12 +79,15 @@ private static async Task<Result> WriteVersionSourceFileAsync(
Branch targetBranch,
DateTimeOffset generated,
IEnumerable<Rule> ruleSet,
IEnumerable<string> importSet)
IEnumerable<string> importSet,
CancellationToken ct)
{
Debug.Assert(ruleSet != null);
Debug.Assert(importSet != null);

var commit = targetBranch?.Head;
var commit = targetBranch != null ?
await targetBranch.GetHeadCommitAsync(ct) :
null;

var commitId = commit?.Hash.ToString() ?? string.Empty;

Expand All @@ -110,7 +114,7 @@ static string FormatSignature(Signature? sig) => sig is { } s ?
var epochIntDateVersion = Utilities.GetEpochIntDateVersionFromDate(commitDate);

var versionLabelTask = targetBranch is { } ?
Analyzer.LookupVersionLabelAsync(targetBranch) :
Analyzer.LookupVersionLabelAsync(targetBranch, ct) :
Task.FromResult(Version.Default);
var keyValues =
(!string.IsNullOrWhiteSpace(context.PropertiesPath) &&
Expand Down Expand Up @@ -173,7 +177,8 @@ static string FormatSignature(Signature? sig) => sig is { } s ?
commit.Body);
}

public async Task<Result> RunAsync(ProcessorContext context)
public async Task<Result> RunAsync(
ProcessorContext context, CancellationToken ct)
{
var writer = writers[context.Language];

Expand All @@ -195,10 +200,11 @@ public async Task<Result> RunAsync(ProcessorContext context)
logger,
writer,
context,
repository.GetHead(),
repository.Head,
DateTimeOffset.Now,
ruleSet,
importSet);
importSet,
ct);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion CenterCLR.RelaxVersioner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static async Task<int> Main(string[] args)

context.ProjectDirectory = trails[0];

var result = await processor.RunAsync(context);
var result = await processor.RunAsync(context, default);

var dryrunDisplay = string.IsNullOrWhiteSpace(context.OutputPath) ?
" (dryrun)" : string.Empty;
Expand Down

0 comments on commit 636f6e5

Please sign in to comment.