octocheck 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61abb6c55ea292484ec39ad6e3535030d36378e65b844c945c771667f039bf65
4
- data.tar.gz: 6bfa226d7a045dc27fc186c0c4207ba30b18f49421a108d8158a9f359751e4ea
3
+ metadata.gz: 53ba0e2df80c00110a3c923f44d945fa0388216e1e8020134b1a16eb673cba83
4
+ data.tar.gz: 9062e3fa8a8082bc8d5f225c0ca64899b9d7894dc9a039dd8126f90351f97e95
5
5
  SHA512:
6
- metadata.gz: 83a7e8450d3f1a7318ebaf995a8424173b63a09c6079d90e54aa476914bc79de2aae58d694e639d9dd7080ac7f83832528c55d21963beab6d5706adc6cceb794
7
- data.tar.gz: cae918393e2b63ed77fd11c0e7c6f17b567253081b29f3dca487448e9c61b5a8f186cf6d17d6663dad5b225cec74dc03d9ee97918c85c7ffe776d196d3e372a9
6
+ metadata.gz: d29ec815332501e52ddef340da476943c2620ff9d384d5a624de8c0a80e384a67cdc5407f8f29351e8eb712a65494c4151db148de29295479a081a3c3c08a43c
7
+ data.tar.gz: d9f457ad664cd5e6af6dae036d195abc1039799d3a0a9127630911a347093658330af8b2d4e0dde86463da7f6799a1a3ef933de7569de156219dc11a4ca3b474
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
@@ -10,6 +10,14 @@ module Octocheck
10
10
  @branch = branch
11
11
  @repo = repo
12
12
  @token = token
13
+
14
+ @pr_links = []
15
+ end
16
+
17
+ def branch_link
18
+ return unless branch
19
+
20
+ "https://github.com/#{org}/#{repo}/tree/#{branch}"
13
21
  end
14
22
 
15
23
  def statuses
@@ -28,6 +36,14 @@ module Octocheck
28
36
  get("repos/#{org}/#{repo}/commits/#{branch}/check-runs")
29
37
  .fetch("check_runs")
30
38
  .map { |cr|
39
+ @pr_links += (
40
+ cr
41
+ .fetch("pull_requests", [])
42
+ .map { |pr| pr["number"] }
43
+ .compact
44
+ .map { |number| "https://github.com/#{org}/#{repo}/pull/#{number}" }
45
+ )
46
+
31
47
  {
32
48
  name: cr["name"],
33
49
  state: cr["status"].downcase,
@@ -38,6 +54,10 @@ module Octocheck
38
54
  }
39
55
  end
40
56
 
57
+ def pr_links
58
+ @pr_links.uniq.sort
59
+ end
60
+
41
61
  private
42
62
 
43
63
  def check_run_details(text)
@@ -57,7 +57,30 @@ module Octocheck
57
57
  .map {|cr| cr.fetch(:github_url) }
58
58
  .join("\n")
59
59
 
60
- io.puts(["", state_summaries, link_summaries].join("\n"))
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
- io.puts(["", state_summaries, link_summaries].join("\n"))
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Octocheck
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Kinnecom
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
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.1.4
86
+ rubygems_version: 3.3.3
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: See github checks in your terminal