From b00c9f18527042a81fb1ee5c31059d3c7de9dd49 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Mon, 29 Dec 2025 18:39:05 +0000 Subject: [PATCH 1/2] chore: Add .worktrees/ to .gitignore for parallel development MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 88f3ca33fc..6a72d69cea 100644 --- a/.gitignore +++ b/.gitignore @@ -399,4 +399,4 @@ FodyWeavers.xsd requirements .claude/settings.local.json -nul \ No newline at end of file +nul.worktrees/ From a22f95614ace23629edec22623291faf0b50b106 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 30 Dec 2025 02:41:20 +0000 Subject: [PATCH 2/2] refactor: Extract duplicate dotnet format logic into helper method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidates 4 nearly identical DotNetFormatOptions configurations into a single reusable RunDotNetFormat helper method with parameters for whitespaceOnly and verifyNoChanges variations. Fixes #1460 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../Modules/CodeFormattedNicelyModule.cs | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/src/ModularPipelines.Build/Modules/CodeFormattedNicelyModule.cs b/src/ModularPipelines.Build/Modules/CodeFormattedNicelyModule.cs index 4cc3644de3..e3e0ead7e1 100644 --- a/src/ModularPipelines.Build/Modules/CodeFormattedNicelyModule.cs +++ b/src/ModularPipelines.Build/Modules/CodeFormattedNicelyModule.cs @@ -44,21 +44,10 @@ public Task ShouldSkip(IPipelineContext context) try { - await context.DotNet().Format(new DotNetFormatOptions - { - Arguments = ["whitespace"], - WorkingDirectory = context.Git().RootDirectory, - VerifyNoChanges = true, - Severity = "info", - }, cancellationToken); + await RunDotNetFormat(context, whitespaceOnly: true, verifyNoChanges: true, cancellationToken); // The code hasn't been formatted nicely! - return await context.DotNet().Format(new DotNetFormatOptions - { - WorkingDirectory = context.Git().RootDirectory, - VerifyNoChanges = true, - Severity = "info", - }, cancellationToken); + return await RunDotNetFormat(context, whitespaceOnly: false, verifyNoChanges: true, cancellationToken); } catch (Exception) { @@ -70,20 +59,8 @@ await context.DotNet().Format(new DotNetFormatOptions ArgumentNullException.ThrowIfNull(_githubSettings.Value.StandardToken); - await context.DotNet().Format(new DotNetFormatOptions - { - WorkingDirectory = context.Git().RootDirectory, - VerifyNoChanges = false, - Severity = "info", - }, cancellationToken); - - await context.DotNet().Format(new DotNetFormatOptions - { - Arguments = ["whitespace"], - WorkingDirectory = context.Git().RootDirectory, - VerifyNoChanges = false, - Severity = "info", - }, cancellationToken); + await RunDotNetFormat(context, whitespaceOnly: false, verifyNoChanges: false, cancellationToken); + await RunDotNetFormat(context, whitespaceOnly: true, verifyNoChanges: false, cancellationToken); var branchTriggeringPullRequest = context.GitHub().EnvironmentVariables.HeadRef!; @@ -98,4 +75,21 @@ await GitHelpers.CommitAndPush(context, branchTriggeringPullRequest, DotnetForma throw new Exception("Formatting code. This run will abort. Another run will trigger with the formatted code."); } } + + private static Task RunDotNetFormat( + IModuleContext context, + bool whitespaceOnly, + bool verifyNoChanges, + CancellationToken cancellationToken) + { + var options = new DotNetFormatOptions + { + Arguments = whitespaceOnly ? ["whitespace"] : null, + WorkingDirectory = context.Git().RootDirectory, + VerifyNoChanges = verifyNoChanges, + Severity = "info", + }; + + return context.DotNet().Format(options, cancellationToken); + } } \ No newline at end of file