lib/tutter/action/sppuppet.rb in tutter-sppuppet-1.2.7 vs lib/tutter/action/sppuppet.rb in tutter-sppuppet-1.2.8
- old
+ new
@@ -2,10 +2,11 @@
require 'json'
class Sppuppet
# Match regexps
MERGE_COMMENT = /(:shipit:|:ship:|!merge)/
+ DELETE_BRANCH_COMMENT = /(:scissors:)/
PLUS_VOTE = /^(:?\+1:?|LGTM)/ # Match :+1:, +1, and LGTM
MINUS_VOTE = /^(:?\-1:?)/ # Match :-1: and -1
BLOCK_VOTE = /^(:poop:|:hankey:|-2)/ # Blocks merge
INCIDENT = /jira.*INCIDENT/
@@ -97,10 +98,14 @@
owner_votes[commenter] = 1
end
end
end
+ if DELETE_BRANCH_COMMENT.match(i.body)
+ @branch_to_delete = pr.head
+ end
+
if PLUS_VOTE.match(i.body) && pr.user.login != commenter
votes[commenter] = 1
if @settings['owners'].include?(commenter)
owner_votes[commenter] = 1
end
@@ -163,9 +168,11 @@
if incident_merge_override
@client.add_labels_to_an_issue @project, pull_request_id, ['incident']
end
begin
merge_commit = @client.merge_pull_request(@project, pull_request_id, merge_msg)
+ # If a owner posted a chop comment and was successfully merged delete the branch ref
+ @client.delete_branch(@project, @branch_to_delete) if @branch_to_delete
rescue Octokit::MethodNotAllowed => e
return post_comment(pull_request_id, "Pull request not mergeable: #{e.message}")
end
return 200, "merging #{pull_request_id} #{@project}"
end