Skip to content

fix(branches): correct branch name in protection log and nop label#1017

Open
tdabasinskas wants to merge 2 commits into
github-community-projects:main-enterprisefrom
datolabs-io:fix/branch-protection-log-and-label
Open

fix(branches): correct branch name in protection log and nop label#1017
tdabasinskas wants to merge 2 commits into
github-community-projects:main-enterprisefrom
datolabs-io:fix/branch-protection-log-and-label

Conversation

@tdabasinskas

@tdabasinskas tdabasinskas commented Jul 11, 2026

Copy link
Copy Markdown

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.js builds its params with Object.assign(this.repo, { branch: branch.name }), so params.branch is already a string. The diff message then reads params.branch.name, which is always undefined. Every branch-protection diff in the logs and in dry-run reports says "for undefined branch". Fixed to use params.branch.

Dry-run plans label protection updates as "Add Branch Protection"

In NOP mode, the code path that runs after getBranchProtection succeeds (protection already exists, so this is an update) pushes a NopCommand labeled Add 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 says Update 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 that eslint --fix flags (padded-blocks).

- 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
Copilot AI review requested due to automatic review settings July 11, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 than params.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.

Comment thread lib/plugins/branches.js Outdated
Comment thread lib/plugins/branches.js Outdated
Comment thread test/unit/lib/plugins/branches.test.js Outdated
- 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants