Skip to content

Commit

Permalink
chore: enhance logging of PR numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 committed Feb 5, 2025
1 parent 616624e commit 5ca9b27
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
},
"scripts": {
"build": "tsc",
"lint": "prettier --list-different \"src/**/*.{ts,tsx}\"",
"prettier:write": "prettier --write \"src/**/*.{ts,tsx}\"",
"lint": "prettier --list-different \"{src,test}/**/*.{ts,tsx}\"",
"prettier:write": "prettier --write \"{src,test}/**/*.{ts,tsx}\"",
"postinstall": "tsc",
"start": "DEBUG=* probot run ./lib/index.js",
"test": "vitest run",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ const submitFeedbackForPR = async (
export const probotRunner = (app: Probot) => {
app.on('pull_request', async (context) => {
const pr = context.payload.pull_request;
const repo = context.payload.repository.full_name;

if (context.payload.action === 'closed' && pr.merged) {
debug(`Checking release notes comment on PR #${pr.number}`);
debug(`Checking release notes comment on PR ${repo}#${pr.number}`);
await submitFeedbackForPR(context, pr, true);
} else if (!pr.merged && pr.state === 'open') {
// Only submit feedback for PRs that aren't merged and are open
debug(`Checking & posting release notes comment on PR #${pr.number}`);
debug(`Checking & posting release notes comment on PR ${repo}#${pr.number}`);
await submitFeedbackForPR(context, pr);
}
});
Expand Down
13 changes: 13 additions & 0 deletions test/comment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('probotRunner', () => {
repository: {
name: 'electron',
owner: { login: 'electron' },
full_name: 'electron/electron',
},
} as PullRequestOpenedEvent;

Expand Down Expand Up @@ -81,6 +82,11 @@ describe('probotRunner', () => {
login: 'dependabot[bot]',
},
},
repository: {
name: 'electron',
owner: { login: 'electron' },
full_name: 'electron/electron',
},
} as PullRequestOpenedEvent;

nock(GH_API)
Expand Down Expand Up @@ -109,6 +115,11 @@ describe('probotRunner', () => {
body: 'Fix something to do with GitHub Actions',
user: { login: 'codebytere' },
},
repository: {
name: 'electron',
owner: { login: 'electron' },
full_name: 'electron/electron',
},
} as PullRequestOpenedEvent;

nock(GH_API)
Expand Down Expand Up @@ -143,6 +154,7 @@ describe('probotRunner', () => {
repository: {
name: 'electron',
owner: { login: 'electron' },
full_name: 'electron/electron',
},
} as PullRequestOpenedEvent;

Expand Down Expand Up @@ -182,6 +194,7 @@ describe('probotRunner', () => {
repository: {
name: 'electron',
owner: { login: 'electron' },
full_name: 'electron/electron',
},
} as PullRequestClosedEvent;

Expand Down

0 comments on commit 5ca9b27

Please sign in to comment.