escobar 0.1.35 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/escobar/github/client.rb +11 -7
- data/lib/escobar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1734c4c77497ac41042dada569e23e2f694921c7
|
4
|
+
data.tar.gz: d08a56a8e2fe64867e066e77cbf44c9c19bf5743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
31
|
-
if
|
32
|
-
|
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
|
-
"
|
49
|
+
raise RepoNotFound, "Unable to access #{name_with_owner}"
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
data/lib/escobar/version.rb
CHANGED