Skip to content

Commit

Permalink
Revert "feat: support commit comments (#180)" (#182)
Browse files Browse the repository at this point in the history
This reverts commit a7dd869.
  • Loading branch information
jakebolam authored Mar 22, 2019
1 parent a7dd869 commit f1e10fe
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 353 deletions.
2 changes: 1 addition & 1 deletion app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
default_events:
# - check_run
# - check_suite
- commit_comment
# - commit_comment
# - create
# - delete
# - deployment
Expand Down
5 changes: 2 additions & 3 deletions src/serverless-webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ module.exports.handler = thundra(async (event, context) => {
}
}

const isComment = name === 'issue_comment' || name === 'commit_comment'
if (!isComment) {
if (name !== 'issue_comment') {
return {
statusCode: 201,
body: 'Not a comment, exiting',
body: 'Not an issue comment, exiting',
}
}

Expand Down
18 changes: 0 additions & 18 deletions src/tasks/processIssueComment/CommentReply/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ class CommentReply {
const fromUser = this.replyingToWho()
const body = `@${fromUser} ${this.message}`
this.context.log.info(`Sending comment: ${body}`)

const isCommitComment = !!this.context.payload.comment.commit_id
if (isCommitComment) {
const {
commit_id: sha,
path,
position,
} = this.context.payload.comment

return this.context.github.repos.createCommitComment({
...this.context.repo(),
sha,
body,
path: path ? path : undefined,
position: position ? position : undefined,
})
}

const issueComment = this.context.issue({ body })
return this.context.github.issues.createComment(issueComment)
}
Expand Down
5 changes: 0 additions & 5 deletions src/tasks/processIssueComment/probot-processIssueComment.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ function processIssueCommentApp(app) {
app.log.trace(context)
await probotProcessIssueCommentSafe({ context })
})

app.on('commit_comment.created', async context => {
app.log.trace(context)
await probotProcessIssueCommentSafe({ context })
})
}

module.exports = processIssueCommentApp
160 changes: 0 additions & 160 deletions test/fixtures/commit_comment.created.json

This file was deleted.

42 changes: 4 additions & 38 deletions test/serverless-webhook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,18 @@ describe('Serverless Webhook', () => {
// TODO: expect lambda.invoke TO NOT BE CALLED
})

test('If not a comment (or commit_comment), exit', async () => {
test('If not an issue comment, exit', async () => {
const mockEvent = {
headers: {
'x-github-event': 'lol',
},
}
const response = await serverlessWebhookHandler(mockEvent, mockContext)
expect(response.body).toEqual('Not a comment, exiting')
expect(response.body).toEqual('Not an issue comment, exiting')
// TODO: expect lambda.invoke TO NOT BE CALLED
})

test('If a comment, but not created, exit', async () => {
const mockEvent = {
headers: {
'x-github-event': 'issue_comment',
},
body: {
action: 'edited',
},
}
const response = await serverlessWebhookHandler(mockEvent, mockContext)
expect(response.body).toEqual('Not a comment creation, exiting')
// TODO: expect lambda.invoke TO NOT BE CALLED
})

test('If a commit comment, but not created, exit', async () => {
test('If an issue comment, but not created, exit', async () => {
const mockEvent = {
headers: {
'x-github-event': 'issue_comment',
Expand Down Expand Up @@ -82,7 +68,7 @@ describe('Serverless Webhook', () => {
// TODO: expect lambda.invoke TO NOT BE CALLED
})

test('Issue Comment, If not for us, exit', async () => {
test('If not for us, exit', async () => {
const mockEvent = {
headers: {
'x-github-event': 'issue_comment',
Expand All @@ -102,26 +88,6 @@ describe('Serverless Webhook', () => {
// TODO: expect lambda.invoke TO NOT BE CALLED
})

test('Commit Comment, If not for us, exit', async () => {
const mockEvent = {
headers: {
'x-github-event': 'commit_comment',
},
body: {
action: 'created',
sender: {
type: 'User',
},
comment: {
body: 'Message not for us, exiting',
},
},
}
const response = await serverlessWebhookHandler(mockEvent, mockContext)
expect(response.body).toEqual('Message not for us, exiting')
// TODO: expect lambda.invoke TO NOT BE CALLED
})

// test('If User and for us, take it', async () => {
// const mockEvent = {
// headers: {
Expand Down
Loading

0 comments on commit f1e10fe

Please sign in to comment.