Skip to content

fix(branches): incorporate PR #1017 log/label fixes + mitigate integration appId harness - #1046

Open
decyjphr wants to merge 1 commit into
yadhav/fix-recent-issuesfrom
decyjphr-compare-pr-1017
Open

fix(branches): incorporate PR #1017 log/label fixes + mitigate integration appId harness#1046
decyjphr wants to merge 1 commit into
yadhav/fix-recent-issuesfrom
decyjphr-compare-pr-1017

Conversation

@decyjphr

@decyjphr decyjphr commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Why

PR #1017 fixes two long-standing cosmetic-but-confusing bugs in the branch-protection plugin's log and dry-run output, and those fixes were not present in this branch. This brings them in (adapted to this branch's this.github.repos convention rather than the PR's this.github.rest.repos). It also unblocks the integration test harness, which currently cannot even instantiate Probot.

What changed

Branch-protection log/label fixes (lib/plugins/branches.js)

  • The diff message read params.branch.name, but params.branch is already the branch string, so every branch-protection diff in logs and dry-run reports said "for undefined branch". Fixed to use params.branch, and the adjacent debug log now JSON.stringifys the results object instead of interpolating [object Object].
  • In NOP (dry-run) mode, the path that runs after getBranchProtection succeeds (protection already exists, so this is an update) pushed a NopCommand labeled Add Branch Protection, identical to the real 404/add path. Plans could not tell "create protection" from "change protection". The update path now says Update Branch Protection (debug "Updating"); the 404 path keeps its Add label.
  • Added an in nop mode unit block asserting the update label when protection exists, the add label on 404, and that the diff message names the actual branch (never undefined).

Integration harness appId mitigation (test/integration/common.js)

  • Under probot 13, createProbot only reads overrides/defaults/env, so the old positional { id, cert, githubToken } args were silently dropped, leaving no credentials and making @octokit/auth-app throw appId option is required before any test ran. The harness now passes dummy credentials via overrides (a githubToken, which selects token auth and avoids the app-auth JWT/installation-token calls the nock scopes don't mock).
  • The app also runs info() on load, which lists app installations. That startup call is stubbed with an empty list so the app loads cleanly under nock.disableNetConnect() without interfering with the per-test scopes.

Notes for reviewers

  • This branch uses this.github.repos.* (not this.github.rest.repos.*), so the incorporated code differs textually from PR fix(branches): correct branch name in protection log and nop label #1017 while preserving its intent.
  • The appId mitigation removes the harness blocker (the appId option is required error is fully gone). Some legacy per-plugin integration tests still fail for a separate, pre-existing reason: they predate this branch's org-level admin-config loading and expect an installation in the event payload. Fully greening them is a larger harness/fixture rewrite and is intentionally out of scope here.

Testing

  • Unit suite: all green, including the new NOP-mode branch tests. Lint clean on changed files.
  • Smoke test (live, real org): 181 passed / 11 failed, with all 11 failures environmental (GH_TOKEN PAT permissions on gh api drift-setup steps, and enterprise app-installation apply timeouts) and unrelated to this change.

…ation appId harness

Incorporate PR #1017 (absent from this
branch), adapted to this branch's `this.github.repos` convention:

- Branch-protection diff message read `params.branch.name` (always undefined,
  since `params.branch` is already the branch string) -> use `params.branch`,
  and JSON.stringify the results in the debug log.
- NOP update path (protection already exists) was mislabeled 'Add Branch
  Protection' -> 'Update Branch Protection' (debug 'Updating'); the 404/add
  path keeps its 'Add' label.
- Add NOP-mode unit tests asserting the update label when protection exists,
  the add label on 404, and that the diff message names the real branch.

Integration harness: `createProbot` in probot 13 only reads
overrides/defaults/env, so the old `{ id, cert, githubToken }` args were
dropped, making @octokit/auth-app throw "appId option is required". Pass dummy
credentials via `overrides` (token auth) and stub the startup `/app/installations`
call so the app loads under nock.disableNetConnect().

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c735bbe7-feb9-472f-827c-d56ddfe7fe6a

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 backports and adapts PR #1017’s branch-protection logging / dry-run (NOP) labeling fixes to this branch’s this.github.repos.* Octokit usage, and updates the integration test harness so Probot can instantiate under Probot 13 without failing on missing appId credentials.

Changes:

  • Fix branch-protection diff messaging to reference the actual branch string and improve debug output formatting.
  • Distinguish NOP-mode branch-protection “update” vs “add” actions via clearer NopCommand labels and logs.
  • Update the integration harness to pass credentials via createProbot({ overrides: ... }) and stub the startup /app/installations call to work under nock.disableNetConnect().
Show a summary per file
File Description
lib/plugins/branches.js Corrects branch name usage in protection diff messages; improves debug log formatting; fixes NOP-mode update labeling/logging.
test/unit/lib/plugins/branches.test.js Adds NOP-mode unit coverage asserting correct labels and that diff messages include the real branch name.
test/integration/common.js Updates Probot 13 harness initialization via overrides and stubs the app info() installations request to prevent startup failures under nock.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

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