octocheck 0.2.2 → 0.3.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/README.md +7 -0
- data/lib/octocheck/api.rb +23 -1
- data/lib/octocheck/cli.rb +12 -0
- data/lib/octocheck/formatters/iterm2.rb +24 -1
- data/lib/octocheck/formatters/simple.rb +23 -1
- data/lib/octocheck/summary.rb +8 -0
- data/lib/octocheck/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10f7d809cad3d2620ae32a0f321618789509d1b9a77b4ca2f2985bfa4d269843
|
4
|
+
data.tar.gz: d74d3d00e7f91649f2229561b82c3a49e9b7e61497e20ac3e7e55685a1c1f632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26b76ccf93aba07bdfff4cbf6435ebdd392cde44e6e7b263df63d3b57a16b3817674045aa64843f132fe4d31a8fbd415b99cd8f31c026d6cb6939f7f729eaddf
|
7
|
+
data.tar.gz: a0dea79fd39fe38ee09af3752987a7379fb66b382a100e575d05bc3a0dc8f8f62ebca900653ea5e4ebb2f871c1919fcbd24a50efaf3151f75996fcf9dc66f25e
|
data/README.md
CHANGED
@@ -7,6 +7,13 @@ $ octocheck
|
|
7
7
|
success ci-check-1 https://example.com/ci-check-1
|
8
8
|
in_progress ci-check-2 https://example.com/ci-check-2
|
9
9
|
failed ci-check-3 https://example.com/ci-check-3
|
10
|
+
|
11
|
+
Branch:
|
12
|
+
https://github.com/org/repo/tree/branchname
|
13
|
+
|
14
|
+
PR:
|
15
|
+
https://github.com/org/repo/pull/174
|
16
|
+
|
10
17
|
```
|
11
18
|
|
12
19
|
### Installation
|
data/lib/octocheck/api.rb
CHANGED
@@ -4,12 +4,22 @@ require "json"
|
|
4
4
|
|
5
5
|
module Octocheck
|
6
6
|
class Api
|
7
|
+
NotFoundError = Class.new(RuntimeError)
|
8
|
+
|
7
9
|
attr_accessor :org, :branch, :repo, :token
|
8
10
|
def initialize(org:, branch:, repo:, token:)
|
9
11
|
@org = org
|
10
12
|
@branch = branch
|
11
13
|
@repo = repo
|
12
14
|
@token = token
|
15
|
+
|
16
|
+
@pr_links = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def branch_link
|
20
|
+
return unless branch
|
21
|
+
|
22
|
+
"https://github.com/#{org}/#{repo}/tree/#{branch}"
|
13
23
|
end
|
14
24
|
|
15
25
|
def statuses
|
@@ -28,6 +38,14 @@ module Octocheck
|
|
28
38
|
get("repos/#{org}/#{repo}/commits/#{branch}/check-runs")
|
29
39
|
.fetch("check_runs")
|
30
40
|
.map { |cr|
|
41
|
+
@pr_links += (
|
42
|
+
cr
|
43
|
+
.fetch("pull_requests", [])
|
44
|
+
.map { |pr| pr["number"] }
|
45
|
+
.compact
|
46
|
+
.map { |number| "https://github.com/#{org}/#{repo}/pull/#{number}" }
|
47
|
+
)
|
48
|
+
|
31
49
|
{
|
32
50
|
name: cr["name"],
|
33
51
|
state: cr["status"].downcase,
|
@@ -38,6 +56,10 @@ module Octocheck
|
|
38
56
|
}
|
39
57
|
end
|
40
58
|
|
59
|
+
def pr_links
|
60
|
+
@pr_links.uniq.sort
|
61
|
+
end
|
62
|
+
|
41
63
|
private
|
42
64
|
|
43
65
|
def check_run_details(text)
|
@@ -70,7 +92,7 @@ module Octocheck
|
|
70
92
|
end
|
71
93
|
http.use_ssl = true
|
72
94
|
response = http.request(request)
|
73
|
-
raise "request failure:\n\n#{response.body}" unless response.code == "200"
|
95
|
+
raise NotFoundError.new("request failure:\n\n#{response.body}") unless response.code == "200"
|
74
96
|
JSON.parse(response.body)
|
75
97
|
end
|
76
98
|
|
data/lib/octocheck/cli.rb
CHANGED
@@ -30,6 +30,18 @@ module Octocheck
|
|
30
30
|
end
|
31
31
|
|
32
32
|
formatter.new($stdout).format(summary)
|
33
|
+
rescue Api::NotFoundError
|
34
|
+
warn <<~TXT
|
35
|
+
Couldn't fetch info for this branch. Some things to check:
|
36
|
+
|
37
|
+
- Has it been pushed to Github?
|
38
|
+
- Does this repo have status checks enabled?
|
39
|
+
|
40
|
+
Branch:
|
41
|
+
#{summary.branch_link}
|
42
|
+
|
43
|
+
TXT
|
44
|
+
exit(1)
|
33
45
|
end
|
34
46
|
end
|
35
47
|
end
|
@@ -57,7 +57,30 @@ module Octocheck
|
|
57
57
|
.map {|cr| cr.fetch(:github_url) }
|
58
58
|
.join("\n")
|
59
59
|
|
60
|
-
|
60
|
+
output = [
|
61
|
+
"",
|
62
|
+
state_summaries,
|
63
|
+
link_summaries,
|
64
|
+
]
|
65
|
+
|
66
|
+
if summary.branch_link
|
67
|
+
output += [
|
68
|
+
"",
|
69
|
+
"Branch:",
|
70
|
+
summary.branch_link
|
71
|
+
|
72
|
+
]
|
73
|
+
end
|
74
|
+
|
75
|
+
(summary.pr_links || []).each do |repo_link|
|
76
|
+
output += [
|
77
|
+
"",
|
78
|
+
"Pull Request:",
|
79
|
+
repo_link
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
83
|
+
io.puts(output.join("\n"))
|
61
84
|
end
|
62
85
|
|
63
86
|
def linkify(text, url)
|
@@ -60,8 +60,30 @@ module Octocheck
|
|
60
60
|
.map {|cr| cr.fetch(:github_url) }
|
61
61
|
.join("\n")
|
62
62
|
|
63
|
-
|
63
|
+
output = [
|
64
|
+
"",
|
65
|
+
state_summaries,
|
66
|
+
link_summaries,
|
67
|
+
]
|
64
68
|
|
69
|
+
if summary.branch_link
|
70
|
+
output += [
|
71
|
+
"",
|
72
|
+
"Branch:",
|
73
|
+
summary.branch_link
|
74
|
+
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
(summary.pr_links || []).each do |repo_link|
|
79
|
+
output += [
|
80
|
+
"",
|
81
|
+
"Pull Request:",
|
82
|
+
repo_link
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
io.puts(output.join("\n"))
|
65
87
|
end
|
66
88
|
|
67
89
|
def colorize(text)
|
data/lib/octocheck/summary.rb
CHANGED
@@ -5,10 +5,18 @@ module Octocheck
|
|
5
5
|
@api = api
|
6
6
|
end
|
7
7
|
|
8
|
+
def branch_link
|
9
|
+
@branch_link ||= api.branch_link
|
10
|
+
end
|
11
|
+
|
8
12
|
def check_runs
|
9
13
|
@check_runs ||= api.check_runs
|
10
14
|
end
|
11
15
|
|
16
|
+
def pr_links
|
17
|
+
@pr_links ||= api.pr_links
|
18
|
+
end
|
19
|
+
|
12
20
|
def statuses
|
13
21
|
@statuses ||= api.statuses
|
14
22
|
end
|
data/lib/octocheck/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octocheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pete Kinnecom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.3.3
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: See github checks in your terminal
|