Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Oct 27, 2023
2 parents f54309f + d01ebf1 commit da94e42
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 31 deletions.
2 changes: 2 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ nuspecファイルを使ってパッケージを生成する場合は、デフ

## 履歴

* 3.2.60:
* ビルド時に`ThisAssembly`シンボルが参照できない場合があるのを修正。
* 3.2.50:
* 同じコミットに複数のバージョンタグが含まれる場合に、最も大きいバージョン番号を使用するように改良。
* 3.2.40:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ When you are using a nuspec file to generate a NuGet package, there are addition

## History

* 3.2.60:
* Fixed the `ThisAssembly` symbol could not be referenced at build time.
* 3.2.50:
* Improved to use the highest version number when multiple version tags are included in the same commit.
* 3.2.40:
Expand Down
4 changes: 2 additions & 2 deletions RelaxVersioner.Core/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private static async Task<Version> LookupVersionLabelAsync(

// Detected mostly larger version tag.
var candidates = commit.Tags.
Collect(tag => Version.TryParse(tag.Name, out var v) ? v : null!).
Select(tag => Version.TryParse(tag.Name, out var v) ? v : null!).
Where(v => v != null).
OrderByDescending(v => v).
ToArray();
if (candidates.Length >= 1)
Expand All @@ -102,7 +103,6 @@ private static async Task<Version> LookupVersionLabelAsync(
break;
}

// Traverse next commits.
var parents = await commit.GetParentCommitsAsync(ct);
if (parents.Length == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion RelaxVersioner.Core/RelaxVersioner.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="NamingFormatter" Version="2.3.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="*" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 9 additions & 26 deletions RelaxVersioner.Core/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//
////////////////////////////////////////////////////////////////////////////////////////

#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -43,12 +41,12 @@ public static Dictionary<string, WriterBase> GetWriters()
return typeof(Utilities).Assembly.
GetTypes().
Where(type => type.IsSealed && type.IsClass && typeof(WriterBase).IsAssignableFrom(type)).
Select(type => (WriterBase)Activator.CreateInstance(type)!).
Select(type => (WriterBase)Activator.CreateInstance(type)).
ToDictionary(writer => writer.Language, StringComparer.InvariantCultureIgnoreCase);
}

private static async Task<T?> TraversePathToRootAsync<T>(
string candidatePath, Func<string, Task<T?>> action)
private static async Task<T> TraversePathToRootAsync<T>(
string candidatePath, Func<string, Task<T>> action)
where T : class
{
var path = Path.GetFullPath(candidatePath).
Expand Down Expand Up @@ -78,7 +76,7 @@ public static string GetDirectoryNameWithoutTrailingSeparator(string path) =>
public static string GetDirectoryNameWithTrailingSeparator(string path) =>
GetDirectoryNameWithoutTrailingSeparator(path) + Path.DirectorySeparatorChar;

public static async Task<StructuredRepository?> OpenRepositoryAsync(
public static async Task<StructuredRepository> OpenRepositoryAsync(
Logger logger, string candidatePath)
{
var repository = await TraversePathToRootAsync(candidatePath, async path =>
Expand All @@ -105,30 +103,15 @@ public static string GetDirectoryNameWithTrailingSeparator(string path) =>
return repository;
}

public static IEnumerable<U> Collect<T, U>(
this IEnumerable<T> enumerable,
Func<T, U?> selector)
where U : class
{
foreach (var item in enumerable)
{
if (selector(item) is { } value)
{
yield return value;
}
}
}

public static TValue GetValue<TKey, TValue>(
this Dictionary<TKey, TValue> dictionary,
TKey key,
TValue defaultValue)
where TKey : notnull
{
Debug.Assert(dictionary != null);
Debug.Assert(key != null);

if (dictionary!.TryGetValue(key!, out var value) == false)
if (dictionary.TryGetValue(key, out TValue value) == false)
{
value = defaultValue;
}
Expand Down Expand Up @@ -170,7 +153,7 @@ public static IEnumerable<XElement> LoadRuleSets(string candidatePath)
var rulePath = Path.Combine(path, "RelaxVersioner.rules");
if (File.Exists(rulePath))
{
XElement? element = null;
XElement element = null;
try
{
element = XElement.Load(rulePath);
Expand Down Expand Up @@ -227,15 +210,15 @@ public static IEnumerable<Rule> AggregateRules(XElement wrules)
return (from rule in wrules.Elements("Rule")
let name = rule.Attribute("name")
let key = rule.Attribute("key")
where !string.IsNullOrWhiteSpace(name?.Value) && !string.IsNullOrWhiteSpace(key?.Value)
select new Rule(name.Value.Trim(), key.Value.Trim(), rule.Value.Trim()));
where !string.IsNullOrWhiteSpace(name?.Value)
select new Rule(name.Value.Trim(), key?.Value.Trim(), rule.Value.Trim()));
}

public static XElement GetDefaultRuleSet()
{
var type = typeof(Utilities);
using (var stream = type.Assembly.GetManifestResourceStream(
type, "DefaultRuleSet.rules")!)
type, "DefaultRuleSet.rules"))
{
return XElement.Load(stream);
}
Expand Down
2 changes: 1 addition & 1 deletion RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="*" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion RelaxVersioner/RelaxVersioner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="*" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit da94e42

Please sign in to comment.