escobar 0.1.35 → 0.2.0

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: d56e66efcc0f63ec676683fd5ee54aeeacac9c7e
4
- data.tar.gz: de08a721b1abada71defc4be969314fca7e60526
3
+ metadata.gz: 1734c4c77497ac41042dada569e23e2f694921c7
4
+ data.tar.gz: d08a56a8e2fe64867e066e77cbf44c9c19bf5743
5
5
  SHA512:
6
- metadata.gz: c429c4aa91de6949f3736f7b405825e33485194c46a9df0e91e8b0c83d937f7ae12a93f2fbaed768e108a97e83966c4cca64c44553accc9d1ceff4397f50518a
7
- data.tar.gz: aa25e137d219a68b42f4564cdcc1a7efa2c1f91c9763c5a412871f1b0c9bd23c45a5521f9f073f8860e0a4717ebccd3654f989f8d37db90e6adae48e2edba576
6
+ metadata.gz: 82a1cebae49c1fc0c6a2d12837cbb89cf0315b8d36a5932091a097072b969acf0cf18dc967862ffd6957b8b4cded1d5520b96c51d6cb5c204418328f50f3931c
7
+ data.tar.gz: 323a9bc6acde6d4efb535002dcc0af090173c7b2856a0ef95d5e6db98df65325adaa7aa9e665ca2827ce5ec3f8ecb34e3875672cb53f50fda4f6e613dc7bceaa
@@ -1,5 +1,6 @@
1
1
  module Escobar
2
2
  module GitHub
3
+ class RepoNotFound < StandardError; end
3
4
  # Top-level class for interacting with GitHub API
4
5
  class Client
5
6
  attr_reader :name_with_owner, :token
@@ -27,14 +28,17 @@ module Escobar
27
28
 
28
29
  def required_contexts
29
30
  path = "/repos/#{name_with_owner}/branches/#{default_branch}"
30
- repo = JSON.parse(http_method(:get, path).body)
31
- if repo["protection"] && repo["protection"]["enabled"]
32
- return repo["protection"]["required_status_checks"]["contexts"]
31
+ response = http_method(:get, path)
32
+ if response.status == 200
33
+ repo = JSON.parse(response.body)
34
+ if repo["protection"] && repo["protection"]["enabled"]
35
+ return repo["protection"]["required_status_checks"]["contexts"]
36
+ else
37
+ []
38
+ end
33
39
  else
34
- []
40
+ raise RepoNotFound, "Unable to access #{name_with_owner}"
35
41
  end
36
- rescue StandardError
37
- []
38
42
  end
39
43
 
40
44
  def default_branch
@@ -42,7 +46,7 @@ module Escobar
42
46
  if response.status == 200
43
47
  JSON.parse(response.body)["default_branch"]
44
48
  else
45
- "master"
49
+ raise RepoNotFound, "Unable to access #{name_with_owner}"
46
50
  end
47
51
  end
48
52
 
@@ -1,3 +1,3 @@
1
1
  module Escobar
2
- VERSION = "0.1.35".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escobar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.35
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Donohoe