15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/tutter/action/sppuppet.rb', line 15
def run
pull_request_id = @data['issue']['number']
debug "pull request id: #{pull_request_id}"
pr = @client.pull_request @project, pull_request_id
plus_one = {}
merge = false
if pr.mergeable_state != 'clean'
debug "merge state for #{@project} #{pull_request_id} is not clean. Current state: #{pr.mergeable_state}"
return false
end
if pr. == 0
debug 'no comments, skipping'
return false
end
return false unless pr.mergeable
last_commit = @client.pull_request_commits(@project, pull_request_id).last
last_commit_date = last_commit.commit.committer.date
= @client.(@project, pull_request_id)
.each do |i|
next if last_commit_date > i.created_at
if /^(\+1|:\+1)/.match i.body
unless pr.user.login == i.attrs[:user].attrs[:login]
plus_one[i.attrs[:user].attrs[:login]] = 1
end
end
if /^(\-1|:\-1:)/.match i.body
debug "#{@project} #{pull_request_id} has a -1. I will not take the blame"
return false
end
end
merge = true if .last.body == '!merge'
if plus_one.count >= @settings['plus_ones_required'] and merge
debug "merging #{pull_request_id} #{@project}"
@client.merge_pull_request(@project, pull_request_id, 'SHIPPING!!')
end
end
|