vx-service_connector 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vx/service_connector/bitbucket/payload.rb +25 -9
- data/lib/vx/service_connector/gitlab_v6/payload.rb +0 -12
- data/lib/vx/service_connector/version.rb +1 -1
- data/spec/fixtures/bitbucket/payload/bug_3_pr_approve.json +21 -0
- data/spec/fixtures/bitbucket/payload/bug_4_pr_comment_created.json +36 -0
- data/spec/lib/bitbucket_payload_spec.rb +14 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 038bdbfc4a4a3a9c062f956e9abcd945a3a5794a
|
4
|
+
data.tar.gz: 8904ea0285f5d9be686867b85a86ec69eb193ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 246df6b11fe38d2077747806361efbf3f83b5012c5796ed183fb88b2438df07770d9d5077646f2bf8877411dc63909ba6fec9812f7a844d2b4b8c7802bab0111
|
7
|
+
data.tar.gz: 7c30d3382cfe8b72a5be90e2af05d9c2d18528a776134fa45248e25b67105eb520df3760fcf26007a83c72b9ff86ecf6f70889c3087e211ec38b9898e2da2075
|
@@ -16,7 +16,7 @@ module Vx
|
|
16
16
|
author_email: author_email,
|
17
17
|
web_url: web_url,
|
18
18
|
tag: tag_name,
|
19
|
-
skip:
|
19
|
+
skip: !valid?,
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
@@ -39,7 +39,8 @@ module Vx
|
|
39
39
|
|
40
40
|
def sha
|
41
41
|
if pull_request?
|
42
|
-
pull_request['source']
|
42
|
+
pull_request['source'] &&
|
43
|
+
pull_request['source']['commit']['hash']
|
43
44
|
else
|
44
45
|
head_commit['raw_node']
|
45
46
|
end
|
@@ -48,7 +49,8 @@ module Vx
|
|
48
49
|
def branch
|
49
50
|
@branch ||= begin
|
50
51
|
if pull_request?
|
51
|
-
pull_request['source']
|
52
|
+
pull_request['source'] &&
|
53
|
+
pull_request['source']['branch']['name']
|
52
54
|
else
|
53
55
|
head_commit['branch']
|
54
56
|
end
|
@@ -69,7 +71,8 @@ module Vx
|
|
69
71
|
|
70
72
|
def message
|
71
73
|
if pull_request?
|
72
|
-
commit_for_pull_request
|
74
|
+
commit = commit_for_pull_request
|
75
|
+
commit && commit['message']
|
73
76
|
else
|
74
77
|
head_commit['message']
|
75
78
|
end
|
@@ -77,7 +80,8 @@ module Vx
|
|
77
80
|
|
78
81
|
def author
|
79
82
|
if pull_request?
|
80
|
-
commit_for_pull_request
|
83
|
+
commit = commit_for_pull_request
|
84
|
+
commit && commit["author"]["user"]["display_name"]
|
81
85
|
else
|
82
86
|
head_commit['author']
|
83
87
|
end
|
@@ -89,7 +93,8 @@ module Vx
|
|
89
93
|
|
90
94
|
def author_email
|
91
95
|
if pull_request?
|
92
|
-
commit_for_pull_request
|
96
|
+
commit = commit_for_pull_request
|
97
|
+
commit && commit["author"]["raw"][/.*<([^>]*)/,1]
|
93
98
|
else
|
94
99
|
commits? && head_commit['raw_author'][/.*<([^>]*)/,1]
|
95
100
|
end
|
@@ -104,11 +109,13 @@ module Vx
|
|
104
109
|
end
|
105
110
|
|
106
111
|
def pull_request_head_repo_full_name
|
107
|
-
pull_request['source']
|
112
|
+
pull_request['source'] &&
|
113
|
+
pull_request['source']['repository']['full_name']
|
108
114
|
end
|
109
115
|
|
110
116
|
def pull_request_base_repo_full_name
|
111
|
-
pull_request['destination']
|
117
|
+
pull_request['destination'] &&
|
118
|
+
pull_request['destination']['repository']['full_name']
|
112
119
|
end
|
113
120
|
|
114
121
|
def foreign_pull_request?
|
@@ -117,6 +124,14 @@ module Vx
|
|
117
124
|
end
|
118
125
|
end
|
119
126
|
|
127
|
+
def valid?
|
128
|
+
if ignore?
|
129
|
+
false
|
130
|
+
else
|
131
|
+
message && author && author_email || false
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
120
135
|
def ignore?
|
121
136
|
if pull_request?
|
122
137
|
closed_pull_request?
|
@@ -127,7 +142,8 @@ module Vx
|
|
127
142
|
|
128
143
|
def commit_for_pull_request
|
129
144
|
@commit_for_pull_request ||= begin
|
130
|
-
|
145
|
+
pull_request['source'] &&
|
146
|
+
(session.get pull_request['source']['commit']['links']['self']['href'])
|
131
147
|
end
|
132
148
|
end
|
133
149
|
|
@@ -5,18 +5,6 @@ module Vx
|
|
5
5
|
Payload = Struct.new(:session, :repo, :params) do
|
6
6
|
|
7
7
|
def build
|
8
|
-
ServiceConnector::Model::Payload.new(
|
9
|
-
!valid?,
|
10
|
-
!!pull_request?,
|
11
|
-
pull_request_number,
|
12
|
-
branch,
|
13
|
-
branch_label,
|
14
|
-
sha,
|
15
|
-
message,
|
16
|
-
author,
|
17
|
-
author_email,
|
18
|
-
web_url
|
19
|
-
)
|
20
8
|
ServiceConnector::Model::Payload.from_hash(
|
21
9
|
internal_pull_request?: (pull_request? && !foreign_pull_request?),
|
22
10
|
foreign_pull_request?: foreign_pull_request?,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"pullrequest_approve": {
|
3
|
+
"date": "2014-12-03T14:13:07.062645+00:00",
|
4
|
+
"user": {
|
5
|
+
"username": "pi_boomstarter",
|
6
|
+
"display_name": "Pavel Ivanov",
|
7
|
+
"uuid": "{3acc0b44-d08a-4e50-9e8b-3cf223ff4bbd}",
|
8
|
+
"links": {
|
9
|
+
"self": {
|
10
|
+
"href": "https://bitbucket.org/api/2.0/users/pi_boomstarter"
|
11
|
+
},
|
12
|
+
"html": {
|
13
|
+
"href": "https://bitbucket.org/pi_boomstarter"
|
14
|
+
},
|
15
|
+
"avatar": {
|
16
|
+
"href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2014/Oct/15/pi_boomstarter-avatar-2102014747-6_avatar.png"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"pullrequest_comment_created": {
|
3
|
+
"links": {
|
4
|
+
"self": {
|
5
|
+
"href": "https://bitbucket.org/api/2.0/repositories/boomstarter/boomstarter/pullrequests/349/comments/4135018"
|
6
|
+
},
|
7
|
+
"html": {
|
8
|
+
"href": "https://bitbucket.org/boomstarter/boomstarter/pull-request/349/_/diff#comment-4135018"
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"content": {
|
12
|
+
"raw": "\u041f\u043e\u043c\u0435\u043d\u044f\u043b.",
|
13
|
+
"markup": "markdown",
|
14
|
+
"html": "<p>\u041f\u043e\u043c\u0435\u043d\u044f\u043b.</p>"
|
15
|
+
},
|
16
|
+
"created_on": "2014-12-03T11:49:47.310260+00:00",
|
17
|
+
"user": {
|
18
|
+
"username": "bibimij",
|
19
|
+
"display_name": "bibimij",
|
20
|
+
"uuid": "{7385eb2d-3482-4bda-a311-91418d7373ce}",
|
21
|
+
"links": {
|
22
|
+
"self": {
|
23
|
+
"href": "https://bitbucket.org/api/2.0/users/bibimij"
|
24
|
+
},
|
25
|
+
"html": {
|
26
|
+
"href": "https://bitbucket.org/bibimij"
|
27
|
+
},
|
28
|
+
"avatar": {
|
29
|
+
"href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2014/Nov/10/bibimij-avatar-403312456-2_avatar.png"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"updated_on": "2014-12-03T11:49:47.313956+00:00",
|
34
|
+
"id": 4135018
|
35
|
+
}
|
36
|
+
}
|
@@ -96,4 +96,18 @@ describe Vx::ServiceConnector::Bitbucket::Payload do
|
|
96
96
|
its(:ignore?) { should be_true }
|
97
97
|
end
|
98
98
|
|
99
|
+
context 'push with PR approve' do
|
100
|
+
|
101
|
+
let(:content) { read_json_fixture 'bitbucket/payload/bug_3_pr_approve' }
|
102
|
+
|
103
|
+
its(:ignore?) { should be_true }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'push with PR approve' do
|
107
|
+
|
108
|
+
let(:content) { read_json_fixture 'bitbucket/payload/bug_4_pr_comment_created' }
|
109
|
+
|
110
|
+
its(:ignore?) { should be_true }
|
111
|
+
end
|
112
|
+
|
99
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-service_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -177,6 +177,8 @@ files:
|
|
177
177
|
- spec/fixtures/bitbucket/hooks.json
|
178
178
|
- spec/fixtures/bitbucket/payload/bug_1_empty_commits.json
|
179
179
|
- spec/fixtures/bitbucket/payload/bug_2_empty_commits.json
|
180
|
+
- spec/fixtures/bitbucket/payload/bug_3_pr_approve.json
|
181
|
+
- spec/fixtures/bitbucket/payload/bug_4_pr_comment_created.json
|
180
182
|
- spec/fixtures/bitbucket/payload/created_pull_request.json
|
181
183
|
- spec/fixtures/bitbucket/payload/declined_pull_request.json
|
182
184
|
- spec/fixtures/bitbucket/payload/foreign_pull_request.json
|
@@ -269,6 +271,8 @@ test_files:
|
|
269
271
|
- spec/fixtures/bitbucket/hooks.json
|
270
272
|
- spec/fixtures/bitbucket/payload/bug_1_empty_commits.json
|
271
273
|
- spec/fixtures/bitbucket/payload/bug_2_empty_commits.json
|
274
|
+
- spec/fixtures/bitbucket/payload/bug_3_pr_approve.json
|
275
|
+
- spec/fixtures/bitbucket/payload/bug_4_pr_comment_created.json
|
272
276
|
- spec/fixtures/bitbucket/payload/created_pull_request.json
|
273
277
|
- spec/fixtures/bitbucket/payload/declined_pull_request.json
|
274
278
|
- spec/fixtures/bitbucket/payload/foreign_pull_request.json
|