fix: Add consistent debug logging to all branch condition attributes (#1553)#1711
Conversation
SummaryAdds debug logging to Git branch conditional attributes to help troubleshoot branch-based module execution. Critical IssuesNone found ✅ SuggestionsConsider logging at attribute initialization instead of evaluation The debug logging added to these attributes executes every time the condition is evaluated during the pipeline. This could result in duplicate log entries if the attributes are checked multiple times. Consider whether this logging belongs in:
The current placement is functional but may create verbose logs in pipelines with many conditional modules. Inconsistent log message wording
These messages have slightly different phrasing. Consider standardizing them for consistency:
This would make logs easier to parse and understand at a glance. Verdict✅ APPROVE - No critical issues The changes are straightforward and add helpful diagnostic information. The suggestions above are minor improvements for consideration but don't block the PR. |
There was a problem hiding this comment.
Pull request overview
This PR adds debug logging to four branch condition attributes to make them consistent with the existing RunOnlyOnBranchAttribute which already had logging. The changes help with troubleshooting pipeline execution when modules are skipped due to branch conditions.
- Adds debug logging that displays the current branch and the condition being evaluated
- Refactors the
Conditionmethods to extract the current branch name into a variable before logging - Uses consistent structured logging with template parameters
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/ModularPipelines.Git/Attributes/SkipIfBranchAttribute.cs | Adds debug logging showing current branch and the branch that triggers skipping |
| src/ModularPipelines.Git/Attributes/RunIfBranchAttribute.cs | Adds debug logging showing current branch and the expected branch for execution |
| src/ModularPipelines.Git/Attributes/RunIfBranchStartsWithAttribute.cs | Adds debug logging showing current branch and the expected branch prefix for execution |
| src/ModularPipelines.Git/Attributes/RunOnlyIfBranchStartsWithAttribute.cs | Adds debug logging showing current branch and the expected branch prefix for execution |
| 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); |
There was a problem hiding this comment.
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.
| pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Will skip on: {SkipBranch}", currentBranchName, BranchName); | |
| pipelineContext.Logger.LogDebug("Current Branch: {CurrentBranch} | Skip condition: branch == {SkipBranch}", currentBranchName, BranchName); |
Add debug logging to branch condition attributes that were missing it: - RunIfBranchAttribute - SkipIfBranchAttribute - RunIfBranchStartsWithAttribute - RunOnlyIfBranchStartsWithAttribute All branch condition attributes now log the current branch and the condition being evaluated, consistent with RunOnlyOnBranchAttribute. Fixes #1553 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2fe64e7 to
b1d4c0d
Compare
SummaryAdds debug logging to Git branch conditional attributes to show current branch and expected branch/prefix during condition evaluation. Critical IssuesNone found ✅ SuggestionsNone - the implementation is clean and follows consistent patterns across all four attributes. Verdict✅ APPROVE - No critical issues The debug logging will be helpful for troubleshooting module execution conditions. The structured logging format is correct and the changes are minimal and focused. |
Summary
Changes
Added debug logging to:
RunIfBranchAttributeSkipIfBranchAttributeRunIfBranchStartsWithAttributeRunOnlyIfBranchStartsWithAttributeThis makes them consistent with
RunOnlyOnBranchAttributewhich already had logging.Why This Change
When modules are skipped due to branch conditions, having consistent debug logging across all branch condition attributes helps with troubleshooting and debugging pipeline execution.
Fixes #1553
Test plan
🤖 Generated with Claude Code