{"action":"created","comment":{"url":"https://api.github.com/repos/salemove/github-review-helper/pulls/comments/59132737","id":59132737,"diff_hunk":"@@ -61,8 +66,24 @@ func getCommits(issueable Issueable, pullRequests PullRequests) ([]github.Reposi\n func addLabel(repository Repository, issueNumber int, label string, issues Issues) *ErrorResponse {\n \t_, _, err := issues.AddLabelsToIssue(repository.Owner, repository.Name, issueNumber, []string{label})\n \tif err != nil {\n-\t\tmessage := fmt.Sprintf(\"Failed to set the label %s for issue nr %d\", label, issueNumber)\n+\t\tmessage := fmt.Sprintf(\"Failed to set the label %s for issue #%d\", label, issueNumber)\n \t\treturn &ErrorResponse{err, http.StatusBadGateway, message}\n \t}\n \treturn nil\n }\n+\n+func merge(repository Repository, issueNumber int, pullRequests PullRequests) error {\n+\tadditionalCommitMessage := \"\"\n+\tresult, resp, err := pullRequests.Merge(repository.Owner, repository.Name, issueNumber, additionalCommitMessage)\n+\tif err != nil {\n+\t\tif resp != nil && resp.StatusCode == http.StatusMethodNotAllowed {\n+\t\t\treturn NotMergeableError\n+\t\t} else if resp != nil && resp.StatusCode == http.StatusConflict {\n+\t\t\treturn OutdatedMergeRefError\n+\t\t}\n+\t\treturn err\n+\t} else if result.Merged == nil || !*result.Merged {\n+\t\treturn errors.New(\"Request successful, but PR not merged.\")","path":"github.go","position":151,"original_position":43,"commit_id":"e5476f63aa5419b33a097884eba6ad6d6895de63","original_commit_id":"0cc96fd8b12e0a11d6d01e081b760050feee168a","user":{"login":"willmore","id":431211,"avatar_url":"https://avatars.githubusercontent.com/u/431211?v=3","gravatar_id":"","url":"https://api.github.com/users/willmore","html_url":"https://github.com/willmore","followers_url":"https://api.github.com/users/willmore/followers","following_url":"https://api.github.com/users/willmore/following{/other_user}","gists_url":"https://api.github.com/users/willmore/gists{/gist_id}","starred_url":"https://api.github.com/users/willmore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willmore/subscriptions","organizations_url":"https://api.github.com/users/willmore/orgs","repos_url":"https://api.github.com/users/willmore/repos","events_url":"https://api.github.com/users/willmore/events{/privacy}","received_events_url":"https://api.github.com/users/willmore/received_events","type":"User","site_admin":false},"body":"Under what circumstances would this occur?","created_at":"2016-04-10T12:16:28Z","updated_at":"2016-04-10T12:16:28Z","html_url":"https://github.com/salemove/github-review-helper/pull/15#discussion_r59132737","pull_request_url":"https://api.github.com/repos/salemove/github-review-helper/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/comments/59132737"},"html":{"href":"https://github.com/salemove/github-review-helper/pull/15#discussion_r59132737"},"pull_request":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/salemove/github-review-helper/pulls/15","id":65890292,"html_url":"https://github.com/salemove/github-review-helper/pull/15","diff_url":"https://github.com/salemove/github-review-helper/pull/15.diff","patch_url":"https://github.com/salemove/github-review-helper/pull/15.patch","issue_url":"https://api.github.com/repos/salemove/github-review-helper/issues/15","number":15,"state":"open","locked":false,"title":"Add !merge command","user":{"login":"deiwin","id":2261897,"avatar_url":"https://avatars.githubusercontent.com/u/2261897?v=3","gravatar_id":"","url":"https://api.github.com/users/deiwin","html_url":"https://github.com/deiwin","followers_url":"https://api.github.com/users/deiwin/followers","following_url":"https://api.github.com/users/deiwin/following{/other_user}","gists_url":"https://api.github.com/users/deiwin/gists{/gist_id}","starred_url":"https://api.github.com/users/deiwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deiwin/subscriptions","organizations_url":"https://api.github.com/users/deiwin/orgs","repos_url":"https://api.github.com/users/deiwin/repos","events_url":"https://api.github.com/users/deiwin/events{/privacy}","received_events_url":"https://api.github.com/users/deiwin/received_events","type":"User","site_admin":false},"body":"These changes introduce a `!merge` command that currently does the following:\r\n- Sets the `merging` label for the PR;\r\n- Merges the PR if it's mergeable and doesn't have any failed/pending statuses;\r\n- If there are any fixup commits (identified by a pending `review/squash` status) it behaves exactly as a `!squash` command would.\r\n\r\nThis is just the ground work for the `!merge` command and means that isn't currently usable in any meaningful way. At least the following steps are necessary and still to be done for the command to be actually useful, but they will be tackled in separate PRs:\r\n- Listen to status change events and PR `synchronized` events and find any related PRs with the `merging` label. See if the found PRs (updated, and having the `merging` label) are ready to be merged and merge if they are;\r\n- Restore `review/peer` statuses after squashing.\r\n\r\nI suggest reviewing commit by commit. I won't do any large refactorings as a part of this PR, but feel free to suggest ideas for future improvements.","created_at":"2016-04-09T19:38:21Z","updated_at":"2016-04-10T12:16:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"590244fb2760dd802ed97c4a0acc289be483fa0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/salemove/github-review-helper/pulls/15/commits","review_comments_url":"https://api.github.com/repos/salemove/github-review-helper/pulls/15/comments","review_comment_url":"https://api.github.com/repos/salemove/github-review-helper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/salemove/github-review-helper/issues/15/comments","statuses_url":"https://api.github.com/repos/salemove/github-review-helper/statuses/e5476f63aa5419b33a097884eba6ad6d6895de63","head":{"label":"salemove:add_merge_commad","ref":"add_merge_commad","sha":"e5476f63aa5419b33a097884eba6ad6d6895de63","user":{"login":"salemove","id":5281619,"avatar_url":"https://avatars.githubusercontent.com/u/5281619?v=3","gravatar_id":"","url":"https://api.github.com/users/salemove","html_url":"https://github.com/salemove","followers_url":"https://api.github.com/users/salemove/followers","following_url":"https://api.github.com/users/salemove/following{/other_user}","gists_url":"https://api.github.com/users/salemove/gists{/gist_id}","starred_url":"https://api.github.com/users/salemove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salemove/subscriptions","organizations_url":"https://api.github.com/users/salemove/orgs","repos_url":"https://api.github.com/users/salemove/repos","events_url":"https://api.github.com/users/salemove/events{/privacy}","received_events_url":"https://api.github.com/users/salemove/received_events","type":"Organization","site_admin":false},"repo":{"id":43648578,"name":"github-review-helper","full_name":"salemove/github-review-helper","owner":{"login":"salemove","id":5281619,"avatar_url":"https://avatars.githubusercontent.com/u/5281619?v=3","gravatar_id":"","url":"https://api.github.com/users/salemove","html_url":"https://github.com/salemove","followers_url":"https://api.github.com/users/salemove/followers","following_url":"https://api.github.com/users/salemove/following{/other_user}","gists_url":"https://api.github.com/users/salemove/gists{/gist_id}","starred_url":"https://api.github.com/users/salemove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salemove/subscriptions","organizations_url":"https://api.github.com/users/salemove/orgs","repos_url":"https://api.github.com/users/salemove/repos","events_url":"https://api.github.com/users/salemove/events{/privacy}","received_events_url":"https://api.github.com/users/salemove/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/salemove/github-review-helper","description":"GitHub bot for improving your project's PR review workflow","fork":false,"url":"https://api.github.com/repos/salemove/github-review-helper","forks_url":"https://api.github.com/repos/salemove/github-review-helper/forks","keys_url":"https://api.github.com/repos/salemove/github-review-helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/salemove/github-review-helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/salemove/github-review-helper/teams","hooks_url":"https://api.github.com/repos/salemove/github-review-helper/hooks","issue_events_url":"https://api.github.com/repos/salemove/github-review-helper/issues/events{/number}","events_url":"https://api.github.com/repos/salemove/github-review-helper/events","assignees_url":"https://api.github.com/repos/salemove/github-review-helper/assignees{/user}","branches_url":"https://api.github.com/repos/salemove/github-review-helper/branches{/branch}","tags_url":"https://api.github.com/repos/salemove/github-review-helper/tags","blobs_url":"https://api.github.com/repos/salemove/github-review-helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/salemove/github-review-helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/salemove/github-review-helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/salemove/github-review-helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/salemove/github-review-helper/statuses/{sha}","languages_url":"https://api.github.com/repos/salemove/github-review-helper/languages","stargazers_url":"https://api.github.com/repos/salemove/github-review-helper/stargazers","contributors_url":"https://api.github.com/repos/salemove/github-review-helper/contributors","subscribers_url":"https://api.github.com/repos/salemove/github-review-helper/subscribers","subscription_url":"https://api.github.com/repos/salemove/github-review-helper/subscription","commits_url":"https://api.github.com/repos/salemove/github-review-helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/salemove/github-review-helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/salemove/github-review-helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/salemove/github-review-helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/salemove/github-review-helper/contents/{+path}","compare_url":"https://api.github.com/repos/salemove/github-review-helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/salemove/github-review-helper/merges","archive_url":"https://api.github.com/repos/salemove/github-review-helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/salemove/github-review-helper/downloads","issues_url":"https://api.github.com/repos/salemove/github-review-helper/issues{/number}","pulls_url":"https://api.github.com/repos/salemove/github-review-helper/pulls{/number}","milestones_url":"https://api.github.com/repos/salemove/github-review-helper/milestones{/number}","notifications_url":"https://api.github.com/repos/salemove/github-review-helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/salemove/github-review-helper/labels{/name}","releases_url":"https://api.github.com/repos/salemove/github-review-helper/releases{/id}","deployments_url":"https://api.github.com/repos/salemove/github-review-helper/deployments","created_at":"2015-10-04T19:00:56Z","updated_at":"2016-04-06T10:56:47Z","pushed_at":"2016-04-09T20:26:52Z","git_url":"git://github.com/salemove/github-review-helper.git","ssh_url":"git@github.com:salemove/github-review-helper.git","clone_url":"https://github.com/salemove/github-review-helper.git","svn_url":"https://github.com/salemove/github-review-helper","homepage":"","size":82,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"salemove:master","ref":"master","sha":"ed2c45dab2c2509a657739de563fc492cd2323c2","user":{"login":"salemove","id":5281619,"avatar_url":"https://avatars.githubusercontent.com/u/5281619?v=3","gravatar_id":"","url":"https://api.github.com/users/salemove","html_url":"https://github.com/salemove","followers_url":"https://api.github.com/users/salemove/followers","following_url":"https://api.github.com/users/salemove/following{/other_user}","gists_url":"https://api.github.com/users/salemove/gists{/gist_id}","starred_url":"https://api.github.com/users/salemove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salemove/subscriptions","organizations_url":"https://api.github.com/users/salemove/orgs","repos_url":"https://api.github.com/users/salemove/repos","events_url":"https://api.github.com/users/salemove/events{/privacy}","received_events_url":"https://api.github.com/users/salemove/received_events","type":"Organization","site_admin":false},"repo":{"id":43648578,"name":"github-review-helper","full_name":"salemove/github-review-helper","owner":{"login":"salemove","id":5281619,"avatar_url":"https://avatars.githubusercontent.com/u/5281619?v=3","gravatar_id":"","url":"https://api.github.com/users/salemove","html_url":"https://github.com/salemove","followers_url":"https://api.github.com/users/salemove/followers","following_url":"https://api.github.com/users/salemove/following{/other_user}","gists_url":"https://api.github.com/users/salemove/gists{/gist_id}","starred_url":"https://api.github.com/users/salemove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/salemove/subscriptions","organizations_url":"https://api.github.com/users/salemove/orgs","repos_url":"https://api.github.com/users/salemove/repos","events_url":"https://api.github.com/users/salemove/events{/privacy}","received_events_url":"https://api.github.com/users/salemove/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/salemove/github-review-helper","description":"GitHub bot for improving your project's PR review workflow","fork":false,"url":"https://api.github.com/repos/salemove/github-review-helper","forks_url":"https://api.github.com/repos/salemove/github-review-helper/forks","keys_url":"https://api.github.com/repos/salemove/github-review-helper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/salemove/github-review-helper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/salemove/github-review-helper/teams","hooks_url":"https://api.github.com/repos/salemove/github-review-helper/hooks","issue_events_url":"https://api.github.com/repos/salemove/github-review-helper/issues/events{/number}","events_url":"https://api.github.com/repos/salemove/github-review-helper/events","assignees_url":"https://api.github.com/repos/salemove/github-review-helper/assignees{/user}","branches_url":"https://api.github.com/repos/salemove/github-review-helper/branches{/branch}","tags_url":"https://api.github.com/repos/salemove/github-review-helper/tags","blobs_url":"https://api.github.com/repos/salemove/github-review-helper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/salemove/github-review-helper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/salemove/github-review-helper/git/refs{/sha}","trees_url":"https://api.github.com/repos/salemove/github-review-helper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/salemove/github-review-helper/statuses/{sha}","languages_url":"https://api.github.com/repos/salemove/github-review-helper/languages","stargazers_url":"https://api.github.com/repos/salemove/github-review-helper/stargazers","contributors_url":"https://api.github.com/repos/salemove/github-review-helper/contributors","subscribers_url":"https://api.github.com/repos/salemove/github-review-helper/subscribers","subscription_url":"https://api.github.com/repos/salemove/github-review-helper/subscription","commits_url":"https://api.github.com/repos/salemove/github-review-helper/commits{/sha}","git_commits_url":"https://api.github.com/repos/salemove/github-review-helper/git/commits{/sha}","comments_url":"https://api.github.com/repos/salemove/github-review-helper/comments{/number}","issue_comment_url":"https://api.github.com/repos/salemove/github-review-helper/issues/comments{/number}","contents_url":"https://api.github.com/repos/salemove/github-review-helper/contents/{+path}","compare_url":"https://api.github.com/repos/salemove/github-review-helper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/salemove/github-review-helper/merges","archive_url":"https://api.github.com/repos/salemove/github-review-helper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/salemove/github-review-helper/downloads","issues_url":"https://api.github.com/repos/salemove/github-review-helper/issues{/number}","pulls_url":"https://api.github.com/repos/salemove/github-review-helper/pulls{/number}","milestones_url":"https://api.github.com/repos/salemove/github-review-helper/milestones{/number}","notifications_url":"https://api.github.com/repos/salemove/github-review-helper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/salemove/github-review-helper/labels{/name}","releases_url":"https://api.github.com/repos/salemove/github-review-helper/releases{/id}","deployments_url":"https://api.github.com/repos/salemove/github-review-helper/deployments","created_at":"2015-10-04T19:00:56Z","updated_at":"2016-04-06T10:56:47Z","pushed_at":"2016-04-09T20:26:52Z","git_url":"git://github.com/salemove/github-review-helper.git","ssh_url":"git@github.com:salemove/github-review-helper.git","clone_url":"https://github.com/salemove/github-review-helper.git","svn_url":"https://github.com/salemove/github-review-helper","homepage":"","size":82,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/15"},"html":{"href":"https://github.com/salemove/github-review-helper/pull/15"},"issue":{"href":"https://api.github.com/repos/salemove/github-review-helper/issues/15"},"comments":{"href":"https://api.github.com/repos/salemove/github-review-helper/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/salemove/github-review-helper/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/salemove/github-review-helper/statuses/e5476f63aa5419b33a097884eba6ad6d6895de63"}}}}