From e68266b28ba38ea0dc19da4f422a357ac14f8586 Mon Sep 17 00:00:00 2001 From: Kouji Matsui Date: Fri, 27 Oct 2023 12:12:16 +0900 Subject: [PATCH 1/4] Locked self-hosted versioning to 3.2.40. --- RelaxVersioner.Core/RelaxVersioner.Core.csproj | 2 +- RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj | 2 +- RelaxVersioner/RelaxVersioner.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/RelaxVersioner.Core/RelaxVersioner.Core.csproj b/RelaxVersioner.Core/RelaxVersioner.Core.csproj index 6721130..0076318 100644 --- a/RelaxVersioner.Core/RelaxVersioner.Core.csproj +++ b/RelaxVersioner.Core/RelaxVersioner.Core.csproj @@ -16,7 +16,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" /> diff --git a/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj b/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj index 58c0307..491d2e8 100644 --- a/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj +++ b/RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj @@ -29,7 +29,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" /> diff --git a/RelaxVersioner/RelaxVersioner.csproj b/RelaxVersioner/RelaxVersioner.csproj index 15c2bbd..beb7681 100644 --- a/RelaxVersioner/RelaxVersioner.csproj +++ b/RelaxVersioner/RelaxVersioner.csproj @@ -37,7 +37,7 @@ + Include="RelaxVersioner" Version="3.2.40" PrivateAssets="all" /> From f1e0d0fe471aad751ebf5e83fe22340d9700188f Mon Sep 17 00:00:00 2001 From: Kouji Matsui Date: Fri, 27 Oct 2023 12:09:14 +0900 Subject: [PATCH 2/4] Revert "Improved detection for mostly larger version tag." This reverts commit 63c79793f9e3a76a5506f90a216e308f0374bce6. --- README.ja.md | 2 -- README.md | 2 -- RelaxVersioner.Core/Analyzer.cs | 22 +++++++++++--------- RelaxVersioner.Core/Utilities.cs | 35 ++++++++------------------------ 4 files changed, 21 insertions(+), 40 deletions(-) diff --git a/README.ja.md b/README.ja.md index b76e74e..614ef4f 100644 --- a/README.ja.md +++ b/README.ja.md @@ -460,8 +460,6 @@ nuspecファイルを使ってパッケージを生成する場合は、デフ ## 履歴 -* 3.2.50: - * 同じコミットに複数のバージョンタグが含まれる場合に、最も大きいバージョン番号を使用するように改良。 * 3.2.40: * .NET 8.0 RC2に対応しました。恐らくそのまま正式な.NET 8.0バージョンにも使用できますが、 .NET 8.0がリリースされたのちに再ビルドしたバージョンをリリースします。 diff --git a/README.md b/README.md index 4f90e87..163a4da 100644 --- a/README.md +++ b/README.md @@ -439,8 +439,6 @@ When you are using a nuspec file to generate a NuGet package, there are addition ## History -* 3.2.50: - * Improved to use the highest version number when multiple version tags are included in the same commit. * 3.2.40: * .NET 8.0 RC2 is now supported. Although it can probably be used for the .NET 8.0 release without any modification, but will release a rebuilt version after .NET 8.0 is released. * 3.2.20: diff --git a/RelaxVersioner.Core/Analyzer.cs b/RelaxVersioner.Core/Analyzer.cs index ae59407..374e913 100644 --- a/RelaxVersioner.Core/Analyzer.cs +++ b/RelaxVersioner.Core/Analyzer.cs @@ -10,7 +10,6 @@ #nullable enable using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -90,19 +89,22 @@ private static async Task LookupVersionLabelAsync( break; } - // Detected mostly larger version tag. - var candidates = commit.Tags. - Collect(tag => Version.TryParse(tag.Name, out var v) ? v : null!). - OrderByDescending(v => v). - ToArray(); - if (candidates.Length >= 1) + var found = false; + foreach (var tag in commit.Tags) + { + if (Version.TryParse(tag.Name, out var v2)) + { + version = v2; + reached.Add(commit, version); + found = true; + break; + } + } + if (found) { - version = candidates[0]; - reached.Add(commit, version); break; } - // Traverse next commits. var parents = await commit.GetParentCommitsAsync(ct); if (parents.Length == 0) { diff --git a/RelaxVersioner.Core/Utilities.cs b/RelaxVersioner.Core/Utilities.cs index 57776fa..53d2a72 100644 --- a/RelaxVersioner.Core/Utilities.cs +++ b/RelaxVersioner.Core/Utilities.cs @@ -7,8 +7,6 @@ // //////////////////////////////////////////////////////////////////////////////////////// -#nullable enable - using System; using System.Collections.Generic; using System.Diagnostics; @@ -43,12 +41,12 @@ public static Dictionary 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 TraversePathToRootAsync( - string candidatePath, Func> action) + private static async Task TraversePathToRootAsync( + string candidatePath, Func> action) where T : class { var path = Path.GetFullPath(candidatePath). @@ -78,7 +76,7 @@ public static string GetDirectoryNameWithoutTrailingSeparator(string path) => public static string GetDirectoryNameWithTrailingSeparator(string path) => GetDirectoryNameWithoutTrailingSeparator(path) + Path.DirectorySeparatorChar; - public static async Task OpenRepositoryAsync( + public static async Task OpenRepositoryAsync( Logger logger, string candidatePath) { var repository = await TraversePathToRootAsync(candidatePath, async path => @@ -105,30 +103,15 @@ public static string GetDirectoryNameWithTrailingSeparator(string path) => return repository; } - public static IEnumerable Collect( - this IEnumerable enumerable, - Func selector) - where U : class - { - foreach (var item in enumerable) - { - if (selector(item) is { } value) - { - yield return value; - } - } - } - public static TValue GetValue( this Dictionary 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; } @@ -170,7 +153,7 @@ public static IEnumerable 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); @@ -227,15 +210,15 @@ public static IEnumerable 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); } From 03658017041bc463e827aede2b3d7e347b66718a Mon Sep 17 00:00:00 2001 From: Kouji Matsui Date: Fri, 27 Oct 2023 13:38:13 +0900 Subject: [PATCH 3/4] Improved detection for mostly larger version tag. --- RelaxVersioner.Core/Analyzer.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/RelaxVersioner.Core/Analyzer.cs b/RelaxVersioner.Core/Analyzer.cs index 374e913..214d33e 100644 --- a/RelaxVersioner.Core/Analyzer.cs +++ b/RelaxVersioner.Core/Analyzer.cs @@ -10,6 +10,7 @@ #nullable enable using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -89,19 +90,16 @@ private static async Task LookupVersionLabelAsync( break; } - var found = false; - foreach (var tag in commit.Tags) - { - if (Version.TryParse(tag.Name, out var v2)) - { - version = v2; - reached.Add(commit, version); - found = true; - break; - } - } - if (found) + // Detected mostly larger version tag. + var candidates = commit.Tags. + Select(tag => Version.TryParse(tag.Name, out var v) ? v : null!). + Where(v => v != null). + OrderByDescending(v => v). + ToArray(); + if (candidates.Length >= 1) { + version = candidates[0]; + reached.Add(commit, version); break; } From d01ebf144c392877a215dbdecff85745f3583fee Mon Sep 17 00:00:00 2001 From: Kouji Matsui Date: Fri, 27 Oct 2023 14:16:07 +0900 Subject: [PATCH 4/4] Updated readme. --- README.ja.md | 4 ++++ README.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.ja.md b/README.ja.md index 614ef4f..c46076b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -460,6 +460,10 @@ nuspecファイルを使ってパッケージを生成する場合は、デフ ## 履歴 +* 3.2.60: + * ビルド時に`ThisAssembly`シンボルが参照できない場合があるのを修正。 +* 3.2.50: + * 同じコミットに複数のバージョンタグが含まれる場合に、最も大きいバージョン番号を使用するように改良。 * 3.2.40: * .NET 8.0 RC2に対応しました。恐らくそのまま正式な.NET 8.0バージョンにも使用できますが、 .NET 8.0がリリースされたのちに再ビルドしたバージョンをリリースします。 diff --git a/README.md b/README.md index 163a4da..2ce3433 100644 --- a/README.md +++ b/README.md @@ -439,6 +439,10 @@ 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: * .NET 8.0 RC2 is now supported. Although it can probably be used for the .NET 8.0 release without any modification, but will release a rebuilt version after .NET 8.0 is released. * 3.2.20: