fix(branches): correct branch name in protection log and nop label#1017
Open
tdabasinskas wants to merge 2 commits into
Open
Conversation
- Fix log message to use `params.branch` instead of undefined `params.branch.name` - Change NopCommand label from 'Add' to 'Update' when branch protection already exists - Update debug log to say 'Updating' instead of 'Adding' for consistency - Add tests to verify correct NopCommand labels and branch name in diff messages
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes two user-facing issues in the branch-protection plugin’s dry-run/log output so branch names and NOP plan labels accurately reflect what would happen during an update vs a create.
Changes:
- Fix branch-protection diff message to use
params.branch(string) rather thanparams.branch.name(undefined). - In NOP mode, label the “existing protection” path as Update Branch Protection (keeping Add Branch Protection for the 404/create path) and adjust the adjacent debug wording.
- Add NOP-mode unit tests covering the corrected branch name in the diff message and the add vs update labels; remove eslint-triggering padded blocks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/plugins/branches.js | Corrects branch name interpolation in diff message and distinguishes NOP update vs add labeling/log wording. |
| test/unit/lib/plugins/branches.test.js | Adds NOP-mode tests to assert correct plan labels and that the diff message names the actual branch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix typo in branch protection message: 'Followings' → 'The following' - Improve debug logging by stringifying results object instead of logging object reference - Update test to be more flexible by checking for message content rather than exact prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small fixes to the branch-protection plugin's log and dry-run output. No behavior change outside of messages and NOP labels.
"Followings changes will be applied to the branch protection for undefined branch"
lib/plugins/branches.jsbuilds its params withObject.assign(this.repo, { branch: branch.name }), soparams.branchis already a string. The diff message then readsparams.branch.name, which is alwaysundefined. Every branch-protection diff in the logs and in dry-run reports says "for undefined branch". Fixed to useparams.branch.Dry-run plans label protection updates as "Add Branch Protection"
In NOP mode, the code path that runs after
getBranchProtectionsucceeds (protection already exists, so this is an update) pushes aNopCommandlabeledAdd Branch Protection, the same label as the real add path that handles the 404 case. Plans can't distinguish creating protection from changing it. The update path now saysUpdate Branch Protection, and the adjacent debug message says "Updating" instead of "Adding". The 404 path keeps its label.The existing suite only exercised
nop = false, so neither message was covered. Added a NOP-mode describe block that asserts the update label when protection exists, the add label on 404, and that the diff message names the actual branch. Also removed two blank lines in the test file thateslint --fixflags (padded-blocks).