lib/tutter/action/sppuppet.rb in tutter-sppuppet-0.0.22 vs lib/tutter/action/sppuppet.rb in tutter-sppuppet-0.0.23

- old
+ new

@@ -32,11 +32,11 @@ when 'status' return 200, 'Merge state not clean' unless @data['state'] == 'success' commit_sha = @data['commit']['sha'] @client.pull_requests(@project).each do |pr| - return maybe_merge(pr.number,false) if pr.head.sha == commit_sha + return maybe_merge(pr.number, false) if pr.head.sha == commit_sha end return 200, "Found no pull requests matching #{commit_sha}" when 'pull_request' # If a new pull request is opened, comment with instructions @@ -55,11 +55,11 @@ def maybe_merge(pull_request_id, merge_command) votes = {} merger = nil pr = @client.pull_request @project, pull_request_id - unless pr.mergeable_state == 'clean' + unless pr.mergeable_state == 'clean' msg = "Merge state for is not clean. Current state: #{pr.mergeable_state}\n" reassure = "I will try to merge this for you when the builds turn green\n" + 'If your build fails or becomes stuck for some reason, just say \'rebuild\'' if merge_command return post_comment(pull_request_id, msg + reassure) @@ -78,12 +78,12 @@ comments.each do |i| # Comment is older than last commit. # We only want to check newer comments next if last_commit_date > i.created_at - if (i.body == '!merge' || i.body.start_with?(':shipit:')) - merger ||= i.attrs[:user] + if i.body == '!merge' || i.body.start_with?(':shipit:') + merger ||= i.attrs[:user].attrs[:login] # Count as a +1 if it is not the author unless pr.user.login == i.attrs[:user].attrs[:login] votes[i.attrs[:user].attrs[:login]] = 1 end end @@ -96,10 +96,10 @@ votes[i.attrs[:user].attrs[:login]] = score end end end - return 200, "No merge comment found" unless merger + return 200, 'No merge comment found' unless merger num_votes = votes.values.reduce(0) { |a, e| a + e } if num_votes < @settings['plus_ones_required'] msg = "Not enough plus ones. #{@settings['plus_ones_required']} required, and only have #{num_votes}" return post_comment(pull_request_id, msg)