Skip to content

Commit 9858adf

Browse files
Andaristemmatown
authored andcommitted
Skip commenting on release PRs (#4)
1 parent 687ed8b commit 9858adf

File tree

3 files changed

+488
-6
lines changed

3 files changed

+488
-6
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ module.exports = app => {
6464
});
6565

6666
app.on(["pull_request.opened", "pull_request.synchronize"], async context => {
67+
if (context.payload.pull_request.head.ref === 'changeset-release') {
68+
return;
69+
}
70+
6771
try {
6872
let number = context.payload.number;
6973

index.test.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const changesetBot = require('.');
66

77
const pullRequestOpen = require('./test/fixtures/pull_request.opened');
88
const pullRequestSynchronize = require('./test/fixtures/pull_request.synchronize');
9+
const releasePullRequestOpen = require('./test/fixtures/release_pull_request.opened');
910

1011
nock.disableNetConnect();
1112

@@ -102,11 +103,11 @@ describe('changeset-bot', () => {
102103
.post('/repos/pyu/testing-things/issues/1/comments', ({ body }) => {
103104
expect(body).toEqual(outdent`
104105
### 🦋 Changeset is good to go
105-
106+
106107
Latest commit: ABCDE
107-
108+
108109
**We got this.**
109-
110+
110111
Not sure what this means? [Click here to learn what changesets are](https://github.com/Noviny/changesets/blob/master/docs/adding-a-changeset.md).`);
111112
return true;
112113
})
@@ -137,11 +138,11 @@ describe('changeset-bot', () => {
137138
### 💥 No Changeset
138139
139140
Latest commit: ABCDE
140-
141+
141142
Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂
142-
143+
143144
**If these changes should be published to npm, you need to add a changeset.**
144-
145+
145146
[Click here to learn what changesets are, and how to add one](https://github.com/Noviny/changesets/blob/master/docs/adding-a-changeset.md).`);
146147
return true;
147148
})
@@ -152,4 +153,17 @@ describe('changeset-bot', () => {
152153
payload: pullRequestOpen,
153154
});
154155
});
156+
157+
it("shouldn't add a comment to a release pull request", async () => {
158+
nock('https://api.github.com')
159+
.reply(() => {
160+
// shouldn't reach this, but if it does - let it fail
161+
expect(true).toBe(false)
162+
});
163+
164+
await probot.receive({
165+
name: 'pull_request',
166+
payload: releasePullRequestOpen,
167+
});
168+
});
155169
});

0 commit comments

Comments
 (0)