Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ModularPipelines.Git/Attributes/RunIfBranchAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Git.Extensions;
Expand All @@ -17,6 +18,10 @@ public RunIfBranchAttribute(string branchName)

public override Task<bool> Condition(IPipelineHookContext pipelineContext)
{
return Task.FromResult(pipelineContext.Git().Information.BranchName == BranchName);
var currentBranchName = pipelineContext.Git().Information.BranchName;

pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Can run on: {ExpectedBranch}", currentBranchName, BranchName);

return Task.FromResult(currentBranchName == BranchName);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Git.Extensions;
Expand All @@ -17,6 +18,10 @@ public RunIfBranchStartsWithAttribute(string branchNamePrefix)

public override Task<bool> Condition(IPipelineHookContext pipelineContext)
{
return Task.FromResult(pipelineContext.Git().Information.BranchName?.StartsWith(BranchNamePrefix) ?? false);
var currentBranchName = pipelineContext.Git().Information.BranchName;

pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Can run if starts with: {ExpectedPrefix}", currentBranchName, BranchNamePrefix);

return Task.FromResult(currentBranchName?.StartsWith(BranchNamePrefix) ?? false);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Git.Extensions;
Expand All @@ -17,6 +18,10 @@ public RunOnlyIfBranchStartsWithAttribute(string branchNamePrefix)

public override Task<bool> Condition(IPipelineHookContext pipelineContext)
{
return Task.FromResult(pipelineContext.Git().Information.BranchName?.StartsWith(BranchNamePrefix) ?? false);
var currentBranchName = pipelineContext.Git().Information.BranchName;

pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Can run if starts with: {ExpectedPrefix}", currentBranchName, BranchNamePrefix);

return Task.FromResult(currentBranchName?.StartsWith(BranchNamePrefix) ?? false);
}
}
7 changes: 6 additions & 1 deletion src/ModularPipelines.Git/Attributes/SkipIfBranchAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.Git.Extensions;
Expand All @@ -17,6 +18,10 @@ public SkipIfBranchAttribute(string branchName)

public override Task<bool> Condition(IPipelineHookContext pipelineContext)
{
return Task.FromResult(pipelineContext.Git().Information.BranchName != BranchName);
var currentBranchName = pipelineContext.Git().Information.BranchName;

pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Will skip on: {SkipBranch}", currentBranchName, BranchName);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message "Will skip on: {SkipBranch}" is misleading. This log is emitted every time the Condition method is called, regardless of whether the module will actually skip. The message should clarify what branch pattern causes skipping. Consider changing to "Will skip if on branch: {SkipBranch}" or "Skip condition: branch == {SkipBranch}" to make it clear this is describing the skip condition, not stating that a skip will occur.

Suggested change
pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Will skip on: {SkipBranch}", currentBranchName, BranchName);
pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Skip condition: branch == {SkipBranch}", currentBranchName, BranchName);

Copilot uses AI. Check for mistakes.

return Task.FromResult(currentBranchName != BranchName);
}
}
Loading