forked from mirrors/probot
Merge pull request #70 from bkeepers/delete-comment
Add deleteComment action
This commit is contained in:
commit
0b0aba805c
|
@ -85,6 +85,14 @@ Comments can be posted in response to any event performed on an Issue or Pull Re
|
|||
.comment("Hey @{{ user.login }}, thanks for the contribution!");
|
||||
```
|
||||
|
||||
### `deleteComment`
|
||||
|
||||
Deletes the comment for the `issue_comment`, `commit_comment`, and `pull_request_review_comment` events.
|
||||
|
||||
```
|
||||
.deleteComment();
|
||||
```
|
||||
|
||||
### `close`
|
||||
|
||||
Close an issue or pull request.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const process = require('process');
|
||||
const debug = require('debug')('PRobot');
|
||||
const GitHubApi = require('github');
|
||||
const jwt = require('./jwt');
|
||||
|
@ -5,6 +6,7 @@ const jwt = require('./jwt');
|
|||
module.exports = {auth};
|
||||
|
||||
const tokens = {};
|
||||
const enableDebug = process.env.DEBUG && process.env.DEBUG.includes('github');
|
||||
|
||||
// Authenticate as the given installation
|
||||
function auth(id) {
|
||||
|
@ -13,7 +15,7 @@ function auth(id) {
|
|||
if (!token || new Date(token.expires_at) < new Date()) {
|
||||
return createToken(id);
|
||||
} else {
|
||||
const github = new GitHubApi();
|
||||
const github = new GitHubApi({debug: enableDebug});
|
||||
github.authenticate({type: 'token', token: token.token});
|
||||
return Promise.resolve(github);
|
||||
}
|
||||
|
@ -21,7 +23,7 @@ function auth(id) {
|
|||
|
||||
// https://developer.github.com/early-access/integrations/authentication/#as-an-installation
|
||||
function createToken(id) {
|
||||
const github = new GitHubApi();
|
||||
const github = new GitHubApi({debug: enableDebug});
|
||||
github.authenticate({type: 'integration', token: jwt()});
|
||||
|
||||
debug('creating token for installation', id);
|
||||
|
|
|
@ -42,4 +42,16 @@ module.exports = class Issues extends Plugin {
|
|||
close(context) {
|
||||
return context.github.issues.edit(context.toIssue({state: 'closed'}));
|
||||
}
|
||||
|
||||
deleteComment(context) {
|
||||
const comment = context.payload.comment;
|
||||
const github = context.github;
|
||||
|
||||
const deleteFunction =
|
||||
(comment.pull_request_review_id && github.pullRequests.deleteComment) ||
|
||||
(comment.commit_id && github.repos.deleteCommitComment) ||
|
||||
github.issues.deleteComment;
|
||||
|
||||
return deleteFunction(context.toRepo({id: comment.id}));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
{
|
||||
"action": "created",
|
||||
"comment": {
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test/comments/20067099",
|
||||
"html_url": "https://github.com/bkeepers-inc/test/commit/e00ae761ea1e11e26d349bc23fb455a9105560db#commitcomment-20067099",
|
||||
"id": 20067099,
|
||||
"user": {
|
||||
"login": "bkeepers",
|
||||
"id": 173,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/173?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers",
|
||||
"html_url": "https://github.com/bkeepers",
|
||||
"followers_url": "https://api.github.com/users/bkeepers/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers/received_events",
|
||||
"type": "User",
|
||||
"site_admin": true
|
||||
},
|
||||
"position": null,
|
||||
"line": null,
|
||||
"path": null,
|
||||
"commit_id": "e00ae761ea1e11e26d349bc23fb455a9105560db",
|
||||
"created_at": "2016-12-05T05:04:46Z",
|
||||
"updated_at": "2016-12-05T05:04:46Z",
|
||||
"body": "👍 "
|
||||
},
|
||||
"repository": {
|
||||
"id": 68474533,
|
||||
"name": "test",
|
||||
"full_name": "bkeepers-inc/test",
|
||||
"owner": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"private": true,
|
||||
"html_url": "https://github.com/bkeepers-inc/test",
|
||||
"description": "personal botland",
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test",
|
||||
"forks_url": "https://api.github.com/repos/bkeepers-inc/test/forks",
|
||||
"keys_url": "https://api.github.com/repos/bkeepers-inc/test/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/bkeepers-inc/test/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/bkeepers-inc/test/teams",
|
||||
"hooks_url": "https://api.github.com/repos/bkeepers-inc/test/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/bkeepers-inc/test/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/bkeepers-inc/test/events",
|
||||
"assignees_url": "https://api.github.com/repos/bkeepers-inc/test/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/bkeepers-inc/test/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/bkeepers-inc/test/tags",
|
||||
"blobs_url": "https://api.github.com/repos/bkeepers-inc/test/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/bkeepers-inc/test/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/bkeepers-inc/test/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/bkeepers-inc/test/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/bkeepers-inc/test/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/bkeepers-inc/test/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/bkeepers-inc/test/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/bkeepers-inc/test/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/bkeepers-inc/test/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/bkeepers-inc/test/subscription",
|
||||
"commits_url": "https://api.github.com/repos/bkeepers-inc/test/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/bkeepers-inc/test/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/bkeepers-inc/test/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/bkeepers-inc/test/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/bkeepers-inc/test/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/bkeepers-inc/test/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/bkeepers-inc/test/merges",
|
||||
"archive_url": "https://api.github.com/repos/bkeepers-inc/test/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/bkeepers-inc/test/downloads",
|
||||
"issues_url": "https://api.github.com/repos/bkeepers-inc/test/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/bkeepers-inc/test/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/bkeepers-inc/test/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/bkeepers-inc/test/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/bkeepers-inc/test/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/bkeepers-inc/test/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/bkeepers-inc/test/deployments",
|
||||
"created_at": "2016-09-17T19:44:06Z",
|
||||
"updated_at": "2016-11-18T21:04:26Z",
|
||||
"pushed_at": "2016-12-05T05:04:36Z",
|
||||
"git_url": "git://github.com/bkeepers-inc/test.git",
|
||||
"ssh_url": "git@github.com:bkeepers-inc/test.git",
|
||||
"clone_url": "https://github.com/bkeepers-inc/test.git",
|
||||
"svn_url": "https://github.com/bkeepers-inc/test",
|
||||
"homepage": null,
|
||||
"size": 15,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "JavaScript",
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 16,
|
||||
"forks": 0,
|
||||
"open_issues": 16,
|
||||
"watchers": 0,
|
||||
"default_branch": "master"
|
||||
},
|
||||
"organization": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"url": "https://api.github.com/orgs/bkeepers-inc",
|
||||
"repos_url": "https://api.github.com/orgs/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/orgs/bkeepers-inc/events",
|
||||
"hooks_url": "https://api.github.com/orgs/bkeepers-inc/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/bkeepers-inc/issues",
|
||||
"members_url": "https://api.github.com/orgs/bkeepers-inc/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/bkeepers-inc/public_members{/member}",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"description": null
|
||||
},
|
||||
"sender": {
|
||||
"login": "bkeepers",
|
||||
"id": 173,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/173?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers",
|
||||
"html_url": "https://github.com/bkeepers",
|
||||
"followers_url": "https://api.github.com/users/bkeepers/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers/received_events",
|
||||
"type": "User",
|
||||
"site_admin": true
|
||||
},
|
||||
"installation": {
|
||||
"id": 1729
|
||||
}
|
||||
}
|
|
@ -0,0 +1,469 @@
|
|||
{
|
||||
"action": "created",
|
||||
"comment": {
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test/pulls/comments/90805181",
|
||||
"pull_request_review_id": 11320164,
|
||||
"id": 90805181,
|
||||
"diff_hunk": "@@ -1,4 +1,3 @@\n # test\n \n personal botland\n-2",
|
||||
"path": "README.md",
|
||||
"position": 4,
|
||||
"original_position": 4,
|
||||
"commit_id": "d90d08599501cec59c5682cfcd9c212aa48eb9a5",
|
||||
"original_commit_id": "d90d08599501cec59c5682cfcd9c212aa48eb9a5",
|
||||
"user": {
|
||||
"login": "bkeepers",
|
||||
"id": 173,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/173?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers",
|
||||
"html_url": "https://github.com/bkeepers",
|
||||
"followers_url": "https://api.github.com/users/bkeepers/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers/received_events",
|
||||
"type": "User",
|
||||
"site_admin": true
|
||||
},
|
||||
"body": "👍 ",
|
||||
"created_at": "2016-12-05T05:20:18Z",
|
||||
"updated_at": "2016-12-05T05:20:18Z",
|
||||
"html_url": "https://github.com/bkeepers-inc/test/pull/3#discussion_r90805181",
|
||||
"pull_request_url": "https://api.github.com/repos/bkeepers-inc/test/pulls/3",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/comments/90805181"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://github.com/bkeepers-inc/test/pull/3#discussion_r90805181"
|
||||
},
|
||||
"pull_request": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pull_request": {
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test/pulls/3",
|
||||
"id": 85685837,
|
||||
"html_url": "https://github.com/bkeepers-inc/test/pull/3",
|
||||
"diff_url": "https://github.com/bkeepers-inc/test/pull/3.diff",
|
||||
"patch_url": "https://github.com/bkeepers-inc/test/pull/3.patch",
|
||||
"issue_url": "https://api.github.com/repos/bkeepers-inc/test/issues/3",
|
||||
"number": 3,
|
||||
"state": "open",
|
||||
"locked": false,
|
||||
"title": "Update README.md",
|
||||
"user": {
|
||||
"login": "bkeepers",
|
||||
"id": 173,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/173?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers",
|
||||
"html_url": "https://github.com/bkeepers",
|
||||
"followers_url": "https://api.github.com/users/bkeepers/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers/received_events",
|
||||
"type": "User",
|
||||
"site_admin": true
|
||||
},
|
||||
"body": "",
|
||||
"created_at": "2016-09-17T20:18:17Z",
|
||||
"updated_at": "2016-12-05T05:20:18Z",
|
||||
"closed_at": null,
|
||||
"merged_at": null,
|
||||
"merge_commit_sha": "956f05ecb82e0572311e5185ee17ee4b0e84606e",
|
||||
"assignee": null,
|
||||
"assignees": [
|
||||
|
||||
],
|
||||
"milestone": null,
|
||||
"commits_url": "https://api.github.com/repos/bkeepers-inc/test/pulls/3/commits",
|
||||
"review_comments_url": "https://api.github.com/repos/bkeepers-inc/test/pulls/3/comments",
|
||||
"review_comment_url": "https://api.github.com/repos/bkeepers-inc/test/pulls/comments{/number}",
|
||||
"comments_url": "https://api.github.com/repos/bkeepers-inc/test/issues/3/comments",
|
||||
"statuses_url": "https://api.github.com/repos/bkeepers-inc/test/statuses/d90d08599501cec59c5682cfcd9c212aa48eb9a5",
|
||||
"head": {
|
||||
"label": "bkeepers-inc:bkeepers-patch-3",
|
||||
"ref": "bkeepers-patch-3",
|
||||
"sha": "d90d08599501cec59c5682cfcd9c212aa48eb9a5",
|
||||
"user": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"repo": {
|
||||
"id": 68474533,
|
||||
"name": "test",
|
||||
"full_name": "bkeepers-inc/test",
|
||||
"owner": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"private": true,
|
||||
"html_url": "https://github.com/bkeepers-inc/test",
|
||||
"description": "personal botland",
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test",
|
||||
"forks_url": "https://api.github.com/repos/bkeepers-inc/test/forks",
|
||||
"keys_url": "https://api.github.com/repos/bkeepers-inc/test/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/bkeepers-inc/test/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/bkeepers-inc/test/teams",
|
||||
"hooks_url": "https://api.github.com/repos/bkeepers-inc/test/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/bkeepers-inc/test/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/bkeepers-inc/test/events",
|
||||
"assignees_url": "https://api.github.com/repos/bkeepers-inc/test/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/bkeepers-inc/test/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/bkeepers-inc/test/tags",
|
||||
"blobs_url": "https://api.github.com/repos/bkeepers-inc/test/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/bkeepers-inc/test/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/bkeepers-inc/test/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/bkeepers-inc/test/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/bkeepers-inc/test/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/bkeepers-inc/test/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/bkeepers-inc/test/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/bkeepers-inc/test/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/bkeepers-inc/test/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/bkeepers-inc/test/subscription",
|
||||
"commits_url": "https://api.github.com/repos/bkeepers-inc/test/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/bkeepers-inc/test/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/bkeepers-inc/test/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/bkeepers-inc/test/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/bkeepers-inc/test/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/bkeepers-inc/test/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/bkeepers-inc/test/merges",
|
||||
"archive_url": "https://api.github.com/repos/bkeepers-inc/test/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/bkeepers-inc/test/downloads",
|
||||
"issues_url": "https://api.github.com/repos/bkeepers-inc/test/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/bkeepers-inc/test/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/bkeepers-inc/test/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/bkeepers-inc/test/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/bkeepers-inc/test/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/bkeepers-inc/test/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/bkeepers-inc/test/deployments",
|
||||
"created_at": "2016-09-17T19:44:06Z",
|
||||
"updated_at": "2016-11-18T21:04:26Z",
|
||||
"pushed_at": "2016-12-05T05:04:36Z",
|
||||
"git_url": "git://github.com/bkeepers-inc/test.git",
|
||||
"ssh_url": "git@github.com:bkeepers-inc/test.git",
|
||||
"clone_url": "https://github.com/bkeepers-inc/test.git",
|
||||
"svn_url": "https://github.com/bkeepers-inc/test",
|
||||
"homepage": null,
|
||||
"size": 18,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "JavaScript",
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 16,
|
||||
"forks": 0,
|
||||
"open_issues": 16,
|
||||
"watchers": 0,
|
||||
"default_branch": "master"
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"label": "bkeepers-inc:master",
|
||||
"ref": "master",
|
||||
"sha": "1eae38616d24ac8aa20de052ca87ca986f9b0edf",
|
||||
"user": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"repo": {
|
||||
"id": 68474533,
|
||||
"name": "test",
|
||||
"full_name": "bkeepers-inc/test",
|
||||
"owner": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"private": true,
|
||||
"html_url": "https://github.com/bkeepers-inc/test",
|
||||
"description": "personal botland",
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test",
|
||||
"forks_url": "https://api.github.com/repos/bkeepers-inc/test/forks",
|
||||
"keys_url": "https://api.github.com/repos/bkeepers-inc/test/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/bkeepers-inc/test/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/bkeepers-inc/test/teams",
|
||||
"hooks_url": "https://api.github.com/repos/bkeepers-inc/test/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/bkeepers-inc/test/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/bkeepers-inc/test/events",
|
||||
"assignees_url": "https://api.github.com/repos/bkeepers-inc/test/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/bkeepers-inc/test/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/bkeepers-inc/test/tags",
|
||||
"blobs_url": "https://api.github.com/repos/bkeepers-inc/test/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/bkeepers-inc/test/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/bkeepers-inc/test/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/bkeepers-inc/test/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/bkeepers-inc/test/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/bkeepers-inc/test/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/bkeepers-inc/test/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/bkeepers-inc/test/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/bkeepers-inc/test/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/bkeepers-inc/test/subscription",
|
||||
"commits_url": "https://api.github.com/repos/bkeepers-inc/test/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/bkeepers-inc/test/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/bkeepers-inc/test/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/bkeepers-inc/test/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/bkeepers-inc/test/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/bkeepers-inc/test/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/bkeepers-inc/test/merges",
|
||||
"archive_url": "https://api.github.com/repos/bkeepers-inc/test/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/bkeepers-inc/test/downloads",
|
||||
"issues_url": "https://api.github.com/repos/bkeepers-inc/test/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/bkeepers-inc/test/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/bkeepers-inc/test/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/bkeepers-inc/test/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/bkeepers-inc/test/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/bkeepers-inc/test/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/bkeepers-inc/test/deployments",
|
||||
"created_at": "2016-09-17T19:44:06Z",
|
||||
"updated_at": "2016-11-18T21:04:26Z",
|
||||
"pushed_at": "2016-12-05T05:04:36Z",
|
||||
"git_url": "git://github.com/bkeepers-inc/test.git",
|
||||
"ssh_url": "git@github.com:bkeepers-inc/test.git",
|
||||
"clone_url": "https://github.com/bkeepers-inc/test.git",
|
||||
"svn_url": "https://github.com/bkeepers-inc/test",
|
||||
"homepage": null,
|
||||
"size": 18,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "JavaScript",
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 16,
|
||||
"forks": 0,
|
||||
"open_issues": 16,
|
||||
"watchers": 0,
|
||||
"default_branch": "master"
|
||||
}
|
||||
},
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/3"
|
||||
},
|
||||
"html": {
|
||||
"href": "https://github.com/bkeepers-inc/test/pull/3"
|
||||
},
|
||||
"issue": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/issues/3"
|
||||
},
|
||||
"comments": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/issues/3/comments"
|
||||
},
|
||||
"review_comments": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/3/comments"
|
||||
},
|
||||
"review_comment": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/comments{/number}"
|
||||
},
|
||||
"commits": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/pulls/3/commits"
|
||||
},
|
||||
"statuses": {
|
||||
"href": "https://api.github.com/repos/bkeepers-inc/test/statuses/d90d08599501cec59c5682cfcd9c212aa48eb9a5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"id": 68474533,
|
||||
"name": "test",
|
||||
"full_name": "bkeepers-inc/test",
|
||||
"owner": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers-inc",
|
||||
"html_url": "https://github.com/bkeepers-inc",
|
||||
"followers_url": "https://api.github.com/users/bkeepers-inc/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers-inc/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers-inc/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers-inc/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers-inc/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers-inc/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers-inc/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers-inc/received_events",
|
||||
"type": "Organization",
|
||||
"site_admin": false
|
||||
},
|
||||
"private": true,
|
||||
"html_url": "https://github.com/bkeepers-inc/test",
|
||||
"description": "personal botland",
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/bkeepers-inc/test",
|
||||
"forks_url": "https://api.github.com/repos/bkeepers-inc/test/forks",
|
||||
"keys_url": "https://api.github.com/repos/bkeepers-inc/test/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/bkeepers-inc/test/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/bkeepers-inc/test/teams",
|
||||
"hooks_url": "https://api.github.com/repos/bkeepers-inc/test/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/bkeepers-inc/test/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/bkeepers-inc/test/events",
|
||||
"assignees_url": "https://api.github.com/repos/bkeepers-inc/test/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/bkeepers-inc/test/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/bkeepers-inc/test/tags",
|
||||
"blobs_url": "https://api.github.com/repos/bkeepers-inc/test/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/bkeepers-inc/test/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/bkeepers-inc/test/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/bkeepers-inc/test/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/bkeepers-inc/test/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/bkeepers-inc/test/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/bkeepers-inc/test/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/bkeepers-inc/test/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/bkeepers-inc/test/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/bkeepers-inc/test/subscription",
|
||||
"commits_url": "https://api.github.com/repos/bkeepers-inc/test/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/bkeepers-inc/test/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/bkeepers-inc/test/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/bkeepers-inc/test/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/bkeepers-inc/test/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/bkeepers-inc/test/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/bkeepers-inc/test/merges",
|
||||
"archive_url": "https://api.github.com/repos/bkeepers-inc/test/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/bkeepers-inc/test/downloads",
|
||||
"issues_url": "https://api.github.com/repos/bkeepers-inc/test/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/bkeepers-inc/test/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/bkeepers-inc/test/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/bkeepers-inc/test/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/bkeepers-inc/test/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/bkeepers-inc/test/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/bkeepers-inc/test/deployments",
|
||||
"created_at": "2016-09-17T19:44:06Z",
|
||||
"updated_at": "2016-11-18T21:04:26Z",
|
||||
"pushed_at": "2016-12-05T05:04:36Z",
|
||||
"git_url": "git://github.com/bkeepers-inc/test.git",
|
||||
"ssh_url": "git@github.com:bkeepers-inc/test.git",
|
||||
"clone_url": "https://github.com/bkeepers-inc/test.git",
|
||||
"svn_url": "https://github.com/bkeepers-inc/test",
|
||||
"homepage": null,
|
||||
"size": 18,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "JavaScript",
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 16,
|
||||
"forks": 0,
|
||||
"open_issues": 16,
|
||||
"watchers": 0,
|
||||
"default_branch": "master"
|
||||
},
|
||||
"organization": {
|
||||
"login": "bkeepers-inc",
|
||||
"id": 11724939,
|
||||
"url": "https://api.github.com/orgs/bkeepers-inc",
|
||||
"repos_url": "https://api.github.com/orgs/bkeepers-inc/repos",
|
||||
"events_url": "https://api.github.com/orgs/bkeepers-inc/events",
|
||||
"hooks_url": "https://api.github.com/orgs/bkeepers-inc/hooks",
|
||||
"issues_url": "https://api.github.com/orgs/bkeepers-inc/issues",
|
||||
"members_url": "https://api.github.com/orgs/bkeepers-inc/members{/member}",
|
||||
"public_members_url": "https://api.github.com/orgs/bkeepers-inc/public_members{/member}",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11724939?v=3",
|
||||
"description": null
|
||||
},
|
||||
"sender": {
|
||||
"login": "bkeepers",
|
||||
"id": 173,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/173?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/bkeepers",
|
||||
"html_url": "https://github.com/bkeepers",
|
||||
"followers_url": "https://api.github.com/users/bkeepers/followers",
|
||||
"following_url": "https://api.github.com/users/bkeepers/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/bkeepers/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/bkeepers/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/bkeepers/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/bkeepers/orgs",
|
||||
"repos_url": "https://api.github.com/users/bkeepers/repos",
|
||||
"events_url": "https://api.github.com/users/bkeepers/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/bkeepers/received_events",
|
||||
"type": "User",
|
||||
"site_admin": true
|
||||
},
|
||||
"installation": {
|
||||
"id": 1729
|
||||
}
|
||||
}
|
|
@ -6,22 +6,30 @@ const payload = require('../fixtures/webhook/comment.created.json');
|
|||
const createSpy = expect.createSpy;
|
||||
|
||||
describe('issues plugin', () => {
|
||||
const github = {
|
||||
issues: {
|
||||
lock: createSpy(),
|
||||
unlock: createSpy(),
|
||||
edit: createSpy(),
|
||||
addLabels: createSpy(),
|
||||
createComment: createSpy(),
|
||||
addAssigneesToIssue: createSpy(),
|
||||
removeAssigneesFromIssue: createSpy(),
|
||||
removeLabel: createSpy()
|
||||
}
|
||||
};
|
||||
|
||||
const context = new Context(github, {payload});
|
||||
let context;
|
||||
let github;
|
||||
|
||||
before(() => {
|
||||
github = {
|
||||
issues: {
|
||||
lock: createSpy(),
|
||||
unlock: createSpy(),
|
||||
edit: createSpy(),
|
||||
addLabels: createSpy(),
|
||||
createComment: createSpy(),
|
||||
addAssigneesToIssue: createSpy(),
|
||||
removeAssigneesFromIssue: createSpy(),
|
||||
removeLabel: createSpy(),
|
||||
deleteComment: createSpy()
|
||||
},
|
||||
repos: {
|
||||
deleteCommitComment: createSpy()
|
||||
},
|
||||
pullRequests: {
|
||||
deleteComment: createSpy()
|
||||
}
|
||||
};
|
||||
context = new Context(github, {payload});
|
||||
this.issues = new Issues();
|
||||
});
|
||||
|
||||
|
@ -192,4 +200,42 @@ describe('issues plugin', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteComment', () => {
|
||||
it('deletes an issue comment', () => {
|
||||
this.issues.deleteComment(context);
|
||||
|
||||
expect(github.issues.deleteComment).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
id: 252508381
|
||||
});
|
||||
});
|
||||
|
||||
it('deletes a commit comment', () => {
|
||||
const payload = require('../fixtures/webhook/commit_comment.created');
|
||||
|
||||
context = new Context(github, {payload});
|
||||
this.issues.deleteComment(context);
|
||||
|
||||
expect(github.repos.deleteCommitComment).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
id: 20067099
|
||||
});
|
||||
});
|
||||
|
||||
it('deletes a PR comment', () => {
|
||||
const payload = require('../fixtures/webhook/pull_request_review_comment.created');
|
||||
|
||||
context = new Context(github, {payload});
|
||||
this.issues.deleteComment(context);
|
||||
|
||||
expect(github.pullRequests.deleteComment).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
id: 90805181
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue