tutter-sppuppet 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDNiMjU2MTQ2NTU5MjA2MTQxZWQwNzZhYmRkOTY4YWY3NzllNWY3MA==
4
+ ZWUyMDczZGM3ZmY3ZWNmMTk4YTA1MjM1MzE1YzUxMWZkZTlmN2FlNA==
5
5
  data.tar.gz: !binary |-
6
- NzE0NGM3YjdhMmVjMDYwZDgyN2I4ZTUxZDBhZWQ2ZWMwNjE3NDIzNA==
6
+ MzdiMmRhY2I3MzMyZGU0MWJmNWRhM2NhZGE1ZDkzNDgzMTMwZTE4Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWM4ZTcyYWQ3MGMzNDEwMWE3ZWUxOTVjNjkxMTVlODJhMTJhNjk5NjAzNTRj
10
- Yzc3OTBlZDg3OGRlY2VjOGVkNTM5MjU2ZDE4NmQ0ZWJlZWViYWQ0ZjAzN2Rh
11
- NzZmMzkyYmVlNDZmMGE0ZGVmZjIwMzZmNTRhZTNhYTg4NGEwZTE=
9
+ NWM3YmM4ZTBmNDViNDVjNjY3YjAwYzY2YTJhZDAyNTIyYTY4Yzg2ODBlOGE2
10
+ YTYwNmQ0MjdlNGI2NmU3ZDQ5MGFkODZlOTBkYWM2NjJkMmQzZjBmZDUzNWQ0
11
+ YWVjYzFjYWYyYzE0Y2FhNmM3NzY4ZmRjNTBjMWFlN2Q2NzU4Yzk=
12
12
  data.tar.gz: !binary |-
13
- YmNiYzJkZGI2OWQwNTU0ODI1NmQ3MDFiNGRjNjAzZGYyOTZmODU2YWNiZTQ4
14
- NjAxNzA2NzU1YjIwYmMxOGY3YjQ3OThlMTQ1YzU2ZjE1ZDJhODVmNTA1NWM2
15
- ODA4ZmM3OWIyMTNiN2ZmY2ZiZDczYWRhM2Q0NTBlMjMzMmYzOWI=
13
+ YTMyZWQ2ZmU0NTZiZTUwZTZjODc3MTc0MDJiYjgxZDQzOTg3MGQwNzVkOTIw
14
+ ZTE0NGM5MDZlOTFlNmQ2OGNiOWZhOWUzY2U3Nzk5NDFmZGQ3MGVmNDdlOTQz
15
+ OTQ3YzJmZjg4MTE3ZjJhNTg0ZjQzYTA1OThlZjZhM2ZkMTM3MjE=
@@ -12,6 +12,8 @@ class Sppuppet
12
12
  def initialize(settings, client, project, data, event)
13
13
  @settings = settings
14
14
  @settings['plus_ones_required'] ||= 1
15
+ @settings['owner_plus_ones_required'] ||= 0
16
+ @settings['owners'] ||= []
15
17
  @client = client
16
18
  @project = project
17
19
  @data = data
@@ -49,7 +51,12 @@ class Sppuppet
49
51
  # If a new pull request is opened, comment with instructions
50
52
  if @data['action'] == 'opened' && @settings['post_instructions']
51
53
  issue = @data['number']
52
- comment = @settings['instructions'] || "To merge at least #{@settings['plus_ones_required']} person other than the submitter needs to write a comment containing only _+1_ or :+1:. Then write _!merge_ or :shipit: to trigger merging."
54
+ if @settings['owner_plus_ones_required'] > 0
55
+ owners_required_text = " and at least #{@settings['owner_plus_ones_required']} of the owners "
56
+ else
57
+ owners_required_text = ""
58
+ end
59
+ comment = @settings['instructions'] || "To merge at least #{@settings['plus_ones_required']} person other than the submitter #{owners_required_text}needs to write a comment containing only _+1_ or :+1:. Then write _!merge_ or :shipit: to trigger merging."
53
60
  return post_comment(issue, comment)
54
61
  else
55
62
  return 200, 'Not posting instructions'
@@ -60,6 +67,7 @@ class Sppuppet
60
67
  end
61
68
 
62
69
  def maybe_merge(pull_request_id, merge_command, merger = nil)
70
+ owner_votes = {}
63
71
  votes = {}
64
72
  incident_merge_override = false
65
73
  pr = @client.pull_request @project, pull_request_id
@@ -76,23 +84,33 @@ class Sppuppet
76
84
  # We only want to check newer comments
77
85
  next if last_commit_date > i.created_at
78
86
 
87
+ commenter = i.attrs[:user].attrs[:login]
79
88
  # Skip comments from tutter itself
80
- next if i.attrs[:user].attrs[:login] == @client.user.login
89
+ next if commenter == @client.user.login
81
90
 
82
91
  if MERGE_COMMENT.match(i.body)
83
- merger ||= i.attrs[:user].attrs[:login]
92
+ merger ||= commenter
84
93
  # Count as a +1 if it is not the author
85
- unless pr.user.login == i.attrs[:user].attrs[:login]
86
- votes[i.attrs[:user].attrs[:login]] = 1
94
+ unless pr.user.login == commenter
95
+ votes[commenter] = 1
96
+ if @settings['owners'].include?(commenter)
97
+ owner_votes[commenter] = 1
98
+ end
87
99
  end
88
100
  end
89
101
 
90
- if PLUS_VOTE.match(i.body) && pr.user.login != i.attrs[:user].attrs[:login]
91
- votes[i.attrs[:user].attrs[:login]] = 1
102
+ if PLUS_VOTE.match(i.body) && pr.user.login != commenter
103
+ votes[commenter] = 1
104
+ if @settings['owners'].include?(commenter)
105
+ owner_votes[commenter] = 1
106
+ end
92
107
  end
93
108
 
94
- if MINUS_VOTE.match(i.body) && pr.user.login != i.attrs[:user].attrs[:login]
95
- votes[i.attrs[:user].attrs[:login]] = -1
109
+ if MINUS_VOTE.match(i.body) && pr.user.login != commenter
110
+ votes[commenter] = -1
111
+ if @settings['owners'].include?(commenter)
112
+ owner_votes[commenter] = -1
113
+ end
96
114
  end
97
115
 
98
116
  if BLOCK_VOTE.match(i.body)
@@ -125,6 +143,12 @@ class Sppuppet
125
143
  return post_comment(pull_request_id, msg)
126
144
  end
127
145
 
146
+ num_owner_votes = owner_votes.values.reduce(0) { |a, e| a + e }
147
+ if num_owner_votes < @settings['owner_plus_ones_required'] && !incident_merge_override
148
+ msg = "Not enough plus ones from owners. #{@settings['owner_plus_ones_required']} required, and only have #{num_owner_votes}"
149
+ return post_comment(pull_request_id, msg)
150
+ end
151
+
128
152
  # TODO: Word wrap description
129
153
  merge_msg = <<MERGE_MSG
130
154
  Title: #{pr.title}
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'tutter-sppuppet'
4
- s.version = '1.2.6'
4
+ s.version = '1.2.7'
5
5
  s.author = ['Johan Haals', 'Erik Dalén', 'Alexey Lapitsky']
6
6
  s.email = ['johan.haals@gmail.com', 'dalen@spotify.com', 'alexey@spotify.com']
7
7
  s.homepage = 'https://github.com/jhaals/tutter-sppuppet'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tutter-sppuppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Haals
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-18 00:00:00.000000000 Z
13
+ date: 2016-03-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: tutter