tutter-sppuppet 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb3374056a2601ef388af3b3119d6fc236e00030
4
- data.tar.gz: acc0ca1594ca46c7ef6bb4e701311f1d41a4d616
3
+ metadata.gz: 9c82c8f1b531c0e1577d3d18c117f8ebda785b4c
4
+ data.tar.gz: c8995bccc8a4f0d9a4a27477ca13bfb7243ddd66
5
5
  SHA512:
6
- metadata.gz: df26292e971f810911aec4f64885f177d59057374ec707afae0f299c272f2e57fbda41d2f0b3d08b7a252d92681fcd0062534ec898562f302aa2b733d53d88e3
7
- data.tar.gz: ed4f4058f138b80b8fb86d9946450ad21fd4b03b65f67631858271043c7d7b8931308fe38d4352dfd59bc3b4070b0bcbd2bb752b07381b0bbe2cff5e6c073939
6
+ metadata.gz: 3a416fb995a3bebf146e3dc6b174e644d38830d664be2f41aa75eb740829dfd62583cd2cf386bd0c2788773f3e2e7cfe8efa7c6508ff0fd47c16a680c7544fbd
7
+ data.tar.gz: 2575109d71bbc07c5f82a85f44a60e3a9a04c8c4617fcfe4416fb4aaa68c90b717119c50283b1ab4aaa6cf771d467c2f861fc5823afd9cf22c6ff55c12eef177
data/.gemspec CHANGED
@@ -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 = '0.0.1'
4
+ s.version = '0.0.2'
5
5
  s.author = 'Johan Haals'
6
6
  s.email = ['johan.haals@gmail.com']
7
7
  s.homepage = 'https://github.com/jhaals/tutter-sppuppet'
data/README.md CHANGED
@@ -11,13 +11,18 @@ desired amount of +1's(configurable)
11
11
 
12
12
  A pull request will be blocked if it has a _-1_ comment
13
13
 
14
+ ## Installation
14
15
 
15
- ### tutter.yaml sppuppet specific settings
16
+ gem install tutter-sppuppet
17
+
18
+ sppuppet specific settings (goes into tutter.yaml)
16
19
 
17
20
  action: 'sppuppet'
18
21
  action_settings:
19
- plus_ones_required: 3
22
+ plus_ones_required: 3
23
+ debug: false
20
24
 
21
25
  ### TODO
22
26
  * whitelist
23
- * blacklist
27
+ * blacklist
28
+ * tests
@@ -5,30 +5,48 @@ class Sppuppet
5
5
  @client = client
6
6
  @project = project
7
7
  @data = data
8
+ @debug = settings['debug'] unless settings['debug'].nil?
9
+ end
10
+
11
+ def debug(message)
12
+ puts message if @debug
8
13
  end
9
14
 
10
15
  def run
11
16
  pull_request_id = @data['issue']['number']
17
+ debug "pull request id: #{pull_request_id}"
12
18
  pr = @client.pull_request @project, pull_request_id
13
19
  plus_one = {}
14
20
  merge = false
15
21
 
16
22
  if pr.mergeable_state != 'clean'
17
- puts "merge state for #{@project} #{pull_request_id} is not clean. Current state: #{pr.mergeable_state}"
23
+ debug "merge state for #{@project} #{pull_request_id} is not clean. Current state: #{pr.mergeable_state}"
24
+ return false
25
+ end
26
+
27
+ # No comments, no need to go further.
28
+ if pr.comments == 0
29
+ debug 'no comments, skipping'
18
30
  return false
19
31
  end
20
32
 
21
33
  # Don't care about code we can't merge
22
34
  return false unless pr.mergeable
23
35
 
36
+ # We fetch the latest commit and it's date.
37
+ last_commit = @client.pull_request_commits(@project, pull_request_id).last
38
+ last_commit_date = last_commit.commit.committer.date
39
+
24
40
  comments = @client.issue_comments(@project, pull_request_id)
25
41
 
26
42
  # Check each comment for +1 and merge comments
27
43
  comments.each do |i|
28
44
 
45
+ # Comment is older than last commit. We only want to check for +1 in newer comments
46
+ next if last_commit_date > i.created_at
47
+
29
48
  if /^(\+1|:\+1)/.match i.body
30
49
  # pull request submitter cant +1
31
-
32
50
  unless pr.user.login == i.attrs[:user].attrs[:login]
33
51
  plus_one[i.attrs[:user].attrs[:login]] = 1
34
52
  end
@@ -37,7 +55,7 @@ class Sppuppet
37
55
  # TODO it should calculate the +1's - the -1's
38
56
  # Never merge if someone says -1
39
57
  if /^(\-1|:\-1:)/.match i.body
40
- puts "#{@project} #{pull_request_id} has a -1. I will not take the blame"
58
+ debug "#{@project} #{pull_request_id} has a -1. I will not take the blame"
41
59
  return false
42
60
  end
43
61
  end
@@ -45,7 +63,7 @@ class Sppuppet
45
63
  merge = true if comments.last.body == '!merge'
46
64
 
47
65
  if plus_one.count >= @settings['plus_ones_required'] and merge
48
- puts "merging #{pull_request_id} #{@project}"
66
+ debug "merging #{pull_request_id} #{@project}"
49
67
  @client.merge_pull_request(@project, pull_request_id, 'SHIPPING!!')
50
68
  end
51
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tutter-sppuppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Haals
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This tutter action let non collaborators review and merge code without
14
14
  having more then read access to the project
@@ -46,3 +46,4 @@ signing_key:
46
46
  specification_version: 4
47
47
  summary: Github code review without collaborator access
48
48
  test_files: []
49
+ has_rdoc: