tutter-jenkins 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 +8 -8
- data/.gemspec +1 -1
- data/lib/tutter/action/jenkins.rb +22 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWJmNDY3MWFmZjg2MDYyOWU3NzY3OWQ4YmY2NDZmOWFhZjI4ZjdkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDk5MzhkY2E4YmZiNGQyYWQyNmI2N2U2ZmUzNGZjZDcwZTFhNDA5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTJkMDFjYzI4ZDkyY2FkMjczNzkzYjc0MGNhYzczZjg1YjFmYTY1NmJhNjVi
|
10
|
+
YjQ3MDlmYjExZjRhZTFkZjAyODdkZGFmYjllMGE0MmEzNzEwZjBiMjhlZjAy
|
11
|
+
ZjVjZWFjMDMwZDNhYjI0ZThmNDAyYzZlZjZjMjJlMDRhMDlkODE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTA2Njk1MTY2MThlMzk0Nzk3NzJlNzkwOWNkNjBhZGM3N2ZkZGI3NGZhYTVm
|
14
|
+
MTlhMjBhYjNmZTQwZWQ4MzgzNzkxN2FmNzQ1NWIxMTc4MmUxMzVhNmU5NDA1
|
15
|
+
MDRiZDAyZmFlYjhhZjg0MGM1NmQxMjZkNzUyZTFjZTBiMDgzNWE=
|
data/.gemspec
CHANGED
@@ -1,48 +1,53 @@
|
|
1
1
|
class Jenkins
|
2
2
|
def initialize(settings, client, project, data)
|
3
|
-
@settings = settings
|
3
|
+
@settings = settings || {}
|
4
4
|
@client = client
|
5
5
|
@project = project
|
6
6
|
@data = data
|
7
|
+
@merge_request_comment = @settings['merge_request_comment']
|
8
|
+
@merge_request_comment ||= 'merge, my change is covered by tests'
|
7
9
|
end
|
8
10
|
|
9
11
|
def run
|
10
12
|
pull_request_id = @data['issue']['number']
|
11
13
|
puts "pull request id: #{pull_request_id}"
|
12
|
-
pr = @client.pull_request @project, pull_request_id
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
comments = @client.issue_comments(@project, pull_request_id)
|
16
|
+
last_comment = comments.last
|
17
|
+
|
18
|
+
asked_to_merge = last_comment && last_comment.body.strip.downcase == @merge_request_comment.strip.downcase
|
19
|
+
unless asked_to_merge
|
20
|
+
puts "not asked to merge"
|
16
21
|
return false
|
17
22
|
end
|
18
23
|
|
19
|
-
|
20
|
-
if pr.
|
21
|
-
|
24
|
+
pr = @client.pull_request @project, pull_request_id
|
25
|
+
if pr.mergeable_state != 'clean'
|
26
|
+
@client.add_comment(@project, pull_request_id, "Please rebase your change, merge state is #{pr.mergeable_state}")
|
22
27
|
return false
|
23
28
|
end
|
24
29
|
|
25
|
-
# Don't care about code we can't merge
|
26
30
|
unless pr.mergeable
|
27
|
-
|
31
|
+
@client.add_comment(@project, pull_request_id, "Please rebase your change, pull request is not mergeable")
|
28
32
|
return false
|
29
33
|
end
|
30
34
|
|
31
|
-
# We fetch the latest commit and it's date.
|
32
35
|
last_commit = @client.pull_request_commits(@project, pull_request_id).last
|
33
36
|
last_commit_date = last_commit.commit.committer.date
|
34
37
|
|
35
|
-
|
38
|
+
if last_comment.created_at < last_commit_date
|
39
|
+
@client.add_comment(@project, pull_request_id, "Please reopen pull request, found a new commit")
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
36
43
|
jenkins_last_comment = @client.issue_comments(@project, pull_request_id).select{|c| c.attrs[:user].attrs[:login] == 'jenkins'}.last
|
37
44
|
jenkins_allows_merge = jenkins_last_comment && jenkins_last_comment.body =~ /PASS/
|
38
45
|
|
39
46
|
if jenkins_allows_merge
|
40
|
-
puts "
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@client.merge_pull_request(@project, pull_request_id, 'ok, shipping!')
|
45
|
-
end
|
47
|
+
puts "merging #{pull_request_id} #{@project}"
|
48
|
+
@client.merge_pull_request(@project, pull_request_id, 'ok, shipping!')
|
49
|
+
else
|
50
|
+
@client.add_comment(@project, pull_request_id, "Please make sure tests pass")
|
46
51
|
end
|
47
52
|
end
|
48
53
|
end
|