tutter-sppuppet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb3374056a2601ef388af3b3119d6fc236e00030
4
+ data.tar.gz: acc0ca1594ca46c7ef6bb4e701311f1d41a4d616
5
+ SHA512:
6
+ metadata.gz: df26292e971f810911aec4f64885f177d59057374ec707afae0f299c272f2e57fbda41d2f0b3d08b7a252d92681fcd0062534ec898562f302aa2b733d53d88e3
7
+ data.tar.gz: ed4f4058f138b80b8fb86d9946450ad21fd4b03b65f67631858271043c7d7b8931308fe38d4352dfd59bc3b4070b0bcbd2bb752b07381b0bbe2cff5e6c073939
data/.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = 'tutter-sppuppet'
4
+ s.version = '0.0.1'
5
+ s.author = 'Johan Haals'
6
+ s.email = ['johan.haals@gmail.com']
7
+ s.homepage = 'https://github.com/jhaals/tutter-sppuppet'
8
+ s.summary = 'Github code review without collaborator access'
9
+ s.description = 'This tutter action let non collaborators review and merge code without having more then read access to the project'
10
+ s.license = 'Apache 2.0'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.require_paths = ['lib']
14
+
15
+ s.required_ruby_version = '>= 1.8.7'
16
+ end
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # tutter-sppuppet
2
+
3
+ This action let non collaborators review
4
+ and merge code without having more then read access to the project.
5
+
6
+ 1. A pull request get submitted
7
+ 2. Someone thinks it looks good and adds a _+1_ comment
8
+ 3. Another person comment _+1_
9
+ 4. The pull request can be merged by commenting _!merge_ when it has the
10
+ desired amount of +1's(configurable)
11
+
12
+ A pull request will be blocked if it has a _-1_ comment
13
+
14
+
15
+ ### tutter.yaml sppuppet specific settings
16
+
17
+ action: 'sppuppet'
18
+ action_settings:
19
+ plus_ones_required: 3
20
+
21
+ ### TODO
22
+ * whitelist
23
+ * blacklist
@@ -0,0 +1,52 @@
1
+ class Sppuppet
2
+
3
+ def initialize(settings, client, project, data)
4
+ @settings = settings
5
+ @client = client
6
+ @project = project
7
+ @data = data
8
+ end
9
+
10
+ def run
11
+ pull_request_id = @data['issue']['number']
12
+ pr = @client.pull_request @project, pull_request_id
13
+ plus_one = {}
14
+ merge = false
15
+
16
+ if pr.mergeable_state != 'clean'
17
+ puts "merge state for #{@project} #{pull_request_id} is not clean. Current state: #{pr.mergeable_state}"
18
+ return false
19
+ end
20
+
21
+ # Don't care about code we can't merge
22
+ return false unless pr.mergeable
23
+
24
+ comments = @client.issue_comments(@project, pull_request_id)
25
+
26
+ # Check each comment for +1 and merge comments
27
+ comments.each do |i|
28
+
29
+ if /^(\+1|:\+1)/.match i.body
30
+ # pull request submitter cant +1
31
+
32
+ unless pr.user.login == i.attrs[:user].attrs[:login]
33
+ plus_one[i.attrs[:user].attrs[:login]] = 1
34
+ end
35
+ end
36
+
37
+ # TODO it should calculate the +1's - the -1's
38
+ # Never merge if someone says -1
39
+ if /^(\-1|:\-1:)/.match i.body
40
+ puts "#{@project} #{pull_request_id} has a -1. I will not take the blame"
41
+ return false
42
+ end
43
+ end
44
+
45
+ merge = true if comments.last.body == '!merge'
46
+
47
+ if plus_one.count >= @settings['plus_ones_required'] and merge
48
+ puts "merging #{pull_request_id} #{@project}"
49
+ @client.merge_pull_request(@project, pull_request_id, 'SHIPPING!!')
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tutter-sppuppet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Johan Haals
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This tutter action let non collaborators review and merge code without
14
+ having more then read access to the project
15
+ email:
16
+ - johan.haals@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gemspec
22
+ - README.md
23
+ - lib/tutter/action/sppuppet.rb
24
+ homepage: https://github.com/jhaals/tutter-sppuppet
25
+ licenses:
26
+ - Apache 2.0
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: 1.8.7
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.0.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Github code review without collaborator access
48
+ test_files: []