vx-service_connector 0.4.6 → 0.4.7
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/github/payload.rb +7 -8
- data/lib/vx/service_connector/model.rb +6 -2
- data/lib/vx/service_connector/version.rb +1 -1
- data/spec/lib/bitbucket_payload_spec.rb +1 -22
- data/spec/lib/github_payload_spec.rb +14 -15
- data/spec/lib/model_spec.rb +1 -1
- data/spec/support/github_web_mocks.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3567c44011db3b375be8334b60e45419a7d9f668
|
4
|
+
data.tar.gz: ad89accadaf465803640afc400cc3bb7be20ac9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dfb0cd5d8f3798f24fbd3005af60650444440bb2157544acd88654f9b4910252f16f11e2a8b2bd9efd00f727ecad6a4e47fe321621056b2835d830f8880d96a
|
7
|
+
data.tar.gz: c91c3d991b0bb990f9d3f9adb5216c8fcffc9c84183761fbce9263ac7fcf30089cb7746941a919a82800db0759eb81be31323037ea0d0f667175d61bfcb592ea
|
@@ -20,6 +20,9 @@ module Vx
|
|
20
20
|
tag: tag_name,
|
21
21
|
skip: ignore?,
|
22
22
|
)
|
23
|
+
rescue ::Octokit::NotFound, ::Octokit::Unauthorized => e
|
24
|
+
Rails.logger.warn "#{e.class}: #{e.message}" if defined?(Rails)
|
25
|
+
OpenStruct.new ignore?: true
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
@@ -133,14 +136,10 @@ module Vx
|
|
133
136
|
end
|
134
137
|
|
135
138
|
def commit_for_pull_request
|
136
|
-
@commit_for_pull_request ||=
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
rescue ::Octokit::NotFound => e
|
141
|
-
$stderr.puts "ERROR: #{e.inspect}"
|
142
|
-
OpenStruct.new
|
143
|
-
end
|
139
|
+
@commit_for_pull_request ||= begin
|
140
|
+
data = session.commit pull_request["base"]["repo"]["full_name"], sha
|
141
|
+
data.commit
|
142
|
+
end
|
144
143
|
end
|
145
144
|
|
146
145
|
def head_commit?
|
@@ -41,7 +41,7 @@ module Vx
|
|
41
41
|
if restriction.nil?
|
42
42
|
# skip internal pr or tag
|
43
43
|
# allow all pushes and foreign pr
|
44
|
-
return !
|
44
|
+
return !tag?
|
45
45
|
end
|
46
46
|
|
47
47
|
if restriction.is_a?(Hash)
|
@@ -65,7 +65,11 @@ module Vx
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def ignore?
|
68
|
-
!!(
|
68
|
+
!!(
|
69
|
+
skip ||
|
70
|
+
internal_pull_request? ||
|
71
|
+
message.to_s =~ PAYLOAD_IGNORE_RE
|
72
|
+
)
|
69
73
|
end
|
70
74
|
|
71
75
|
def tag?
|
@@ -27,27 +27,6 @@ describe Vx::ServiceConnector::Bitbucket::Payload do
|
|
27
27
|
its(:web_url) { should eq url }
|
28
28
|
end
|
29
29
|
|
30
|
-
context 'create pull_request' do
|
31
|
-
let(:content) { read_json_fixture 'bitbucket/payload/created_pull_request' }
|
32
|
-
let(:url) { 'https://bitbucket.org/121111foobar/vx-promo/pull-request/1' }
|
33
|
-
let(:sha) { 'b14806535f5e' }
|
34
|
-
|
35
|
-
before do
|
36
|
-
mock_get_commit '121111foobar/vx-promo', sha
|
37
|
-
end
|
38
|
-
|
39
|
-
its(:ignore?) { should be_false }
|
40
|
-
its(:pull_request?) { should be_true }
|
41
|
-
its(:pull_request_number) { should eq 1 }
|
42
|
-
its(:branch) { should eq 'test' }
|
43
|
-
its(:branch_label) { should eq 'test' }
|
44
|
-
its(:sha) { should eq sha }
|
45
|
-
its(:message) { should eq 'Fix all the bugs' }
|
46
|
-
its(:author) { should eq 'login' }
|
47
|
-
its(:author_email) { should eq 'example@gmail.com' }
|
48
|
-
its(:web_url) { should eq url }
|
49
|
-
end
|
50
|
-
|
51
30
|
context 'declined pull request' do
|
52
31
|
let(:content) { read_json_fixture('bitbucket/payload/declined_pull_request') }
|
53
32
|
|
@@ -90,7 +69,7 @@ describe Vx::ServiceConnector::Bitbucket::Payload do
|
|
90
69
|
mock_get_commit '121111foobar/vx-promo', 'b14806535f5e'
|
91
70
|
end
|
92
71
|
|
93
|
-
its(:ignore?) { should
|
72
|
+
its(:ignore?) { should be_true }
|
94
73
|
end
|
95
74
|
|
96
75
|
context 'push with empty commits' do
|
@@ -32,27 +32,26 @@ describe Vx::ServiceConnector::Github::Payload do
|
|
32
32
|
its(:tag) { should be_nil }
|
33
33
|
end
|
34
34
|
|
35
|
-
context "
|
35
|
+
context "Octokit exceptions" do
|
36
36
|
let(:content) { read_json_fixture("github/payload/pull_request") }
|
37
37
|
let(:url) { "https://github.com/evrone/cybergifts/pull/177" }
|
38
38
|
let(:sha) { '84158c732ff1af3db9775a37a74ddc39f5c4078f' }
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
context "not found" do
|
41
|
+
before do
|
42
|
+
mock_get_commit_not_found("evrone/cybergifts", sha)
|
43
|
+
end
|
44
|
+
|
45
|
+
it { should be_ignore }
|
42
46
|
end
|
43
47
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
its(:message) { should eq 'Fix all the bugs' }
|
52
|
-
its(:author) { should eq 'Monalisa Octocat' }
|
53
|
-
its(:author_email) { should eq 'support@github.com' }
|
54
|
-
its(:web_url) { should eq url }
|
55
|
-
its(:ignore?) { should be_false }
|
48
|
+
context "uanuthorized" do
|
49
|
+
before do
|
50
|
+
mock_get_commit_unauthorized("evrone/cybergifts", sha)
|
51
|
+
end
|
52
|
+
|
53
|
+
it { should be_ignore }
|
54
|
+
end
|
56
55
|
end
|
57
56
|
|
58
57
|
context "push tag" do
|
data/spec/lib/model_spec.rb
CHANGED
@@ -4,9 +4,14 @@ module GithubWebMocks
|
|
4
4
|
mock_get "https://api.github.com/repos/#{repo_name}/commits/#{sha}", 'commit'
|
5
5
|
end
|
6
6
|
|
7
|
-
def mock_get_commit_not_found
|
8
|
-
stub_request(:get, "https://api.github.com/repos/
|
9
|
-
to_return(:status => 404, :body => "")
|
7
|
+
def mock_get_commit_not_found(repo, sha)
|
8
|
+
stub_request(:get, "https://api.github.com/repos/#{repo}/commits/#{sha}")
|
9
|
+
.to_return(:status => 404, :body => "")
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_get_commit_unauthorized(repo, sha)
|
13
|
+
stub_request(:get, "https://api.github.com/repos/#{repo}/commits/#{sha}")
|
14
|
+
.to_return(:status => 401, :body => "")
|
10
15
|
end
|
11
16
|
|
12
17
|
def mock_create_notice(state)
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|