Skip to content

Commit d69f926

Browse files
committed
Merge branch 'hotfix/0.13.1'
2 parents 7a50563 + faa75cb commit d69f926

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.13.1] / 2025-04-12
11+
### 🛠️ Fixes
12+
13+
- Fixed incorrect version number when creating a hotfix branch ([#96](https://github.com/candoumbe/Pipelines/issues/96))
14+
- Replaced commit number with branch name when submitting versioned mutation test reports ([#183](https://github.com/candoumbe/Pipelines/issues/183))
15+
1016
## [0.13.0] / 2025-04-11
1117
### 🚀 New features
1218

@@ -236,7 +242,8 @@ So now `{MutationTestDirectory}/[{framework}]` is now changed to `{MutationTestD
236242
## [0.1.0] / 2022-10-23
237243
- Initial release
238244

239-
[Unreleased]: https://github.com/candoumbe/Pipelines/compare/0.13.0...HEAD
245+
[Unreleased]: https://github.com/candoumbe/Pipelines/compare/0.13.1...HEAD
246+
[0.13.1]: https://github.com/candoumbe/Pipelines/compare/0.13.0...0.13.1
240247
[0.13.0]: https://github.com/candoumbe/Pipelines/compare/0.12.1...0.13.0
241248
[0.12.1]: https://github.com/candoumbe/Pipelines/compare/0.11.0...0.12.1
242249
[0.11.0]: https://github.com/candoumbe/Pipelines/compare/0.10.0...0.11.0
@@ -255,4 +262,4 @@ So now `{MutationTestDirectory}/[{framework}]` is now changed to `{MutationTestD
255262
[0.4.0]: https://github.com/candoumbe/Pipelines/compare/0.3.0...0.4.0
256263
[0.3.0]: https://github.com/candoumbe/Pipelines/compare/0.2.0...0.3.0
257264
[0.2.0]: https://github.com/candoumbe/Pipelines/compare/0.1.0...0.2.0
258-
[0.1.0]: https://github.com/candoumbe/Pipelines/tree/0.1.0
265+
[0.1.0]: https://github.com/candoumbe/Pipelines/tree/0.1.0

src/Candoumbe.Pipelines/Components/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static T Get<T>(this INukeBuild nukeBuild) where T : INukeBuild
4141
/// enabled and <see langword="false"/> otherwise</returns>
4242
#pragma warning disable RCS1175 // Unused 'this' parameter
4343
#pragma warning disable IDE0060 // Unused 'project' parameter
44-
public static bool IsSourceLinkEnabled(this Project project) => false;
44+
public static bool IsSourceLinkEnabled(this Project project) => project.HasPackageReference("Microsoft.SourceLink.GitHub");
4545
#pragma warning restore IDE0060 // Unused 'project' parameter
4646
#pragma warning restore RCS1175 // Unused 'this' parameter
4747
}

src/Candoumbe.Pipelines/Components/IMutationTest.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ void RunMutationTestsForTheProject(MutationProjectConfiguration mutationProject,
101101
strykerArgs = StrykerArgumentsSettingsBase.Invoke(strykerArgs);
102102
strykerArgs = StrykerArgumentsSettings.Invoke(strykerArgs);
103103

104-
strykerArgs = strykerArgs.SetTargetFramework(framework);
105-
strykerArgs = strykerArgs.SetOutput(MutationTestResultDirectory / sourceProject.Name / framework);
106-
strykerArgs = strykerArgs.SetProject($"{sourceProject.Name}{sourceProject.Path.Extension}");
104+
strykerArgs = strykerArgs.SetTargetFramework(framework)
105+
.SetOutput(MutationTestResultDirectory / sourceProject.Name / framework)
106+
.SetProject($"{sourceProject.Name}{sourceProject.Path.Extension}");
107107

108108
if (configFile is not null)
109109
{
@@ -116,7 +116,8 @@ void RunMutationTestsForTheProject(MutationProjectConfiguration mutationProject,
116116
{
117117
case IGitFlow { GitRepository: { } gitflowRepository } gitFlow:
118118
{
119-
strykerArgs = strykerArgs.SetProjectInfoVersion($"{gitflowRepository.Commit ?? gitflowRepository.Branch}");
119+
strykerArgs = strykerArgs.SetProjectInfoVersion( gitflowRepository.Branch ?? gitflowRepository.Commit);
120+
120121
switch (gitflowRepository.Branch)
121122
{
122123
case { } branchName when string.Equals(branchName, IHaveDevelopBranch.DevelopBranchName, StringComparison.InvariantCultureIgnoreCase):
@@ -151,7 +152,7 @@ void RunMutationTestsForTheProject(MutationProjectConfiguration mutationProject,
151152

152153
case IGitHubFlow { GitRepository: { } githubFlowRepository }:
153154
{
154-
strykerArgs = strykerArgs.SetProjectInfoVersion(githubFlowRepository.Commit ?? githubFlowRepository.Branch);
155+
strykerArgs = strykerArgs.SetProjectInfoVersion( githubFlowRepository.Branch ?? githubFlowRepository.Commit );
155156
if (githubFlowRepository.Branch is { Length: > 0 } branchName && !string.Equals(branchName, IHaveMainBranch.MainBranchName, StringComparison.InvariantCultureIgnoreCase))
156157
{
157158
strykerArgs = strykerArgs.SetWithBaseline(IHaveMainBranch.MainBranchName);
@@ -167,7 +168,7 @@ void RunMutationTestsForTheProject(MutationProjectConfiguration mutationProject,
167168
strykerArgs = this switch
168169
{
169170
IHaveGitVersion gitVersion => strykerArgs.SetProjectInfoVersion(gitVersion.MajorMinorPatchVersion),
170-
IHaveGitRepository gitRepository => strykerArgs.SetProjectInfoVersion(gitRepository.GitRepository?.Commit ?? gitRepository.GitRepository?.Branch),
171+
IHaveGitRepository gitRepository => strykerArgs.SetProjectInfoVersion(gitRepository.GitRepository?.Branch ?? gitRepository.GitRepository?.Commit),
171172
_ => strykerArgs
172173
};
173174
}

src/Candoumbe.Pipelines/Components/Workflows/IDoHotfixWorkflow.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text.RegularExpressions;
15
using System.Threading.Tasks;
26
using Nuke.Common;
37
using Nuke.Common.Git;
8+
using Nuke.Common.Tooling;
49
using Nuke.Common.Tools.GitVersion;
510
using static Nuke.Common.Tools.Git.GitTasks;
11+
using static Serilog.Log;
612

713
namespace Candoumbe.Pipelines.Components.Workflows;
814

@@ -41,12 +47,45 @@ public interface IDoHotfixWorkflow : IWorkflow, IHaveMainBranch
4147
{
4248
if (!GitRepository.IsOnHotfixBranch())
4349
{
44-
Checkout($"{HotfixBranchPrefix}/{GitVersion.Major}.{GitVersion.Minor}.{GitVersion.Patch + 1}", start: HotfixBranchSourceName);
50+
IReadOnlyCollection<Output> outputs = Git("tag --sort=-v:refname");
51+
if (outputs.Count == 0)
52+
{
53+
Warning("No version released found. No hotfix branch will be created");
54+
}
55+
else
56+
{
57+
(int Major, int Minor, int Patch) lastReleaseVersion = outputs.Select(output => ExtractFromText(output.Text))
58+
.Where(version => version is not null)
59+
.Select(version => (version.Value.Major, version.Value.Minor, version.Value.Patch))
60+
.First();
61+
62+
Checkout($"{HotfixBranchPrefix}/{lastReleaseVersion.Major}.{lastReleaseVersion.Minor}.{lastReleaseVersion.Patch + 1}", start: HotfixBranchSourceName);
63+
}
4564
}
4665
else
4766
{
4867
await FinishHotfix();
4968
}
69+
70+
(int Major, int Minor, int Patch)? ExtractFromText(string text)
71+
{
72+
const string semVerRegex = @"^(?<major>(0|[1-9]\d*)+)\.(?<minor>(0|[1-9]\d*))+\.(?<patch>(0|[1-9]\d*)+)$";
73+
74+
Match match = Regex.Match(text, semVerRegex, RegexOptions.None, TimeSpan.FromMilliseconds(100));
75+
76+
(int Major, int Minor, int Patch)? version = null;
77+
78+
if (match.Success)
79+
{
80+
int major = int.Parse(match.Groups["major"].Value);
81+
int minor = int.Parse(match.Groups["minor"].Value);
82+
int patch = int.Parse(match.Groups["patch"].Value);
83+
84+
version = (major, minor, patch);
85+
}
86+
87+
return version;
88+
}
5089
});
5190

5291
/// <summary>

0 commit comments

Comments
 (0)