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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8dd689ce4de0b574983a85638a7394385052d5a
4
- data.tar.gz: a301274c5db42cae5d92ad8c3d7004eaad84b7fd
3
+ metadata.gz: 3567c44011db3b375be8334b60e45419a7d9f668
4
+ data.tar.gz: ad89accadaf465803640afc400cc3bb7be20ac9d
5
5
  SHA512:
6
- metadata.gz: 289257bfe1885e00d06a24ecb1d6f5939024f83cc82b5cc07a80844baccb09893820cf26fe0591ed34491e83c5f5130591b1f63f5ccf9dc0f19e989bad492395
7
- data.tar.gz: 1375050a0621ce0196e2f5625601462d2f57b9263951dd0763eefe813cc75d879c27b76fcd203e60703635b5f5160b99290196856c64777a73a87ef3dc6de34d
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
- begin
138
- data = session.commit pull_request["base"]["repo"]["full_name"], sha
139
- data.commit
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 !(internal_pull_request? or tag?)
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
- !!(skip || message.to_s =~ PAYLOAD_IGNORE_RE)
68
+ !!(
69
+ skip ||
70
+ internal_pull_request? ||
71
+ message.to_s =~ PAYLOAD_IGNORE_RE
72
+ )
69
73
  end
70
74
 
71
75
  def tag?
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module ServiceConnector
3
- VERSION = "0.4.6"
3
+ VERSION = "0.4.7"
4
4
  end
5
5
  end
@@ -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 be_false }
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 "internal pull_request" do
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
- before do
41
- mock_get_commit 'evrone/cybergifts', sha
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
- its(:pull_request?) { should be_true }
45
- its(:foreign_pull_request?) { should be_false }
46
- its(:internal_pull_request?){ should be_true }
47
- its(:pull_request_number) { should eq 177 }
48
- its(:sha) { should eq sha }
49
- its(:branch) { should eq 'test' }
50
- its(:branch_label) { should eq 'dima-exe:test' }
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
@@ -69,7 +69,7 @@ describe "(models)" do
69
69
  # pass, pr allowed
70
70
  instance(
71
71
  params.merge(internal_pull_request?: true)
72
- ).to be_perform(pull_request: true)
72
+ ).not_to be_perform(pull_request: true)
73
73
 
74
74
  # deny, pr not allowed
75
75
  instance(
@@ -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/full/name/commits/sha").
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.6
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-13 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit