hiiro 0.1.226 → 0.1.227
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/bin/h-pr +19 -3
- data/bin/h-pr-monitor +158 -0
- data/lib/hiiro/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c832fea90f5aa6d0ffffceb6a1817d9987ccf8985aca28d3c8ce12d58da94747
|
|
4
|
+
data.tar.gz: 6886300526738f72f6ed8ec60888fdb859da3891ee0bc17fde211b984fb1ad10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd484c3c4c7d830e9d4ead7170bf68b4ba4bddc9b4121b54fac562aabf1c9a811aad42b2a35005b00781fd377c85154f39c73d258b0567b1e2040b3cc5eaa6db
|
|
7
|
+
data.tar.gz: '05984ff6d73d36ab51281b1481c0674b99868fa50ef4ed3c91a8b9370bb105753863944b02af65c6906fbe8a638736ebb63e0e98c4ac12c82ba9a756a7a27191'
|
data/bin/h-pr
CHANGED
|
@@ -7,10 +7,8 @@ require "yaml"
|
|
|
7
7
|
require "json"
|
|
8
8
|
require "tempfile"
|
|
9
9
|
|
|
10
|
-
Hiiro.load_env
|
|
11
|
-
|
|
12
10
|
class PinnedPRManager
|
|
13
|
-
PINNED_FILE =
|
|
11
|
+
PINNED_FILE = Hiiro::Config.path('pinned_prs.yml')
|
|
14
12
|
|
|
15
13
|
def self.repo_from_url(url)
|
|
16
14
|
return nil unless url
|
|
@@ -568,6 +566,13 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
568
566
|
|
|
569
567
|
add_subcmd(:edit) { edit_files(__FILE__) }
|
|
570
568
|
add_subcmd(:open) { |pr_number=nil|
|
|
569
|
+
if pr_number.nil?
|
|
570
|
+
current = pinned_manager.fetch_current_branch_pr
|
|
571
|
+
if current
|
|
572
|
+
system('gh', 'pr', 'view', current['number'].to_s, '--web')
|
|
573
|
+
next
|
|
574
|
+
end
|
|
575
|
+
end
|
|
571
576
|
pr_number = resolve_pr.call(pr_number)
|
|
572
577
|
system('gh', 'pr', 'view', pr_number.to_s, '--web') if pr_number
|
|
573
578
|
}
|
|
@@ -1190,4 +1195,15 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
|
|
|
1190
1195
|
matches.each_with_index { |pr, i| puts pinned_manager.display_pinned(pr, i) }
|
|
1191
1196
|
end
|
|
1192
1197
|
|
|
1198
|
+
add_subcmd(:config) do |*args|
|
|
1199
|
+
make_child do
|
|
1200
|
+
add_subcmd(:path) do
|
|
1201
|
+
puts PinnedPRManager::PINNED_FILE
|
|
1202
|
+
end
|
|
1203
|
+
|
|
1204
|
+
add_subcmd(:vim) do
|
|
1205
|
+
editor PinnedPRManager::PINNED_FILE
|
|
1206
|
+
end
|
|
1207
|
+
end.run
|
|
1208
|
+
end
|
|
1193
1209
|
end
|
data/bin/h-pr-monitor
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'pry'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'digest'
|
|
6
|
+
require 'optparse'
|
|
7
|
+
require 'shellwords'
|
|
8
|
+
|
|
9
|
+
options = {
|
|
10
|
+
notify_approvals: true,
|
|
11
|
+
notify_status: true,
|
|
12
|
+
notify_publishing: true,
|
|
13
|
+
mark_ready: false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
OptionParser.new do |opts|
|
|
17
|
+
opts.banner = "Usage: h-watchprs [options]"
|
|
18
|
+
|
|
19
|
+
opts.on("-a", "--no-notify-approvals", "Disable notifications for new approvals") do
|
|
20
|
+
options[:notify_approvals] = false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
opts.on("-s", "--no-notify-status", "Disable notifications for status changes") do
|
|
24
|
+
options[:notify_status] = false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
opts.on("-u", "--no-notify-publishing", "Disable notifications when publishing PR as ready") do
|
|
28
|
+
options[:notify_publishing] = false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
opts.on("-r", "--mark-ready", "Enable marking PR as ready when passing") do
|
|
32
|
+
options[:mark_ready] = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
opts.on("-h", "--help", "Prints this help") do
|
|
36
|
+
puts opts
|
|
37
|
+
exit
|
|
38
|
+
end
|
|
39
|
+
end.parse!
|
|
40
|
+
|
|
41
|
+
SLEEP_TIME = ENV.fetch('sleep_for', 60)
|
|
42
|
+
|
|
43
|
+
prs = {}
|
|
44
|
+
approvals = {}
|
|
45
|
+
first_run = true
|
|
46
|
+
|
|
47
|
+
last_prs = {}
|
|
48
|
+
last_json_md5 = nil
|
|
49
|
+
|
|
50
|
+
loop do
|
|
51
|
+
stdout = `gh pr status`
|
|
52
|
+
|
|
53
|
+
md5 = Digest::MD5.hexdigest(stdout)
|
|
54
|
+
|
|
55
|
+
if stdout.match?(/something went wrong/i)
|
|
56
|
+
sleep SLEEP_TIME
|
|
57
|
+
next
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
collecting = false
|
|
61
|
+
current_pr = nil
|
|
62
|
+
new_statuses = {}
|
|
63
|
+
new_approvals = {}
|
|
64
|
+
pr_titles = {}
|
|
65
|
+
stdout.lines(chomp: true).map do |line|
|
|
66
|
+
collecting = true if line.match?(/created by you/i)
|
|
67
|
+
next unless collecting
|
|
68
|
+
|
|
69
|
+
if num = line[/[#]\d+/]
|
|
70
|
+
current_pr = num.sub(?#, '')
|
|
71
|
+
# Extract PR title: everything after #123 and before [branch-name]
|
|
72
|
+
if match = line.match(/#\d+\s+(.+?)\s+\[/)
|
|
73
|
+
pr_titles[current_pr] = match[1].strip
|
|
74
|
+
end
|
|
75
|
+
next
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if current_pr && line.match?(/checks (pending|passing|failing)/i)
|
|
79
|
+
new_status = line[/pending|passing|failing/]
|
|
80
|
+
|
|
81
|
+
old_approval_count = approvals.fetch(current_pr, 0)
|
|
82
|
+
|
|
83
|
+
if line.match?(/✓ (\d\d*) Approved/)
|
|
84
|
+
partial = line[/✓ (\d\d*) Approved/]
|
|
85
|
+
approval_count = partial[/\d\d*/]
|
|
86
|
+
new_approvals[current_pr] = approval_count
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
approvals[current_pr]
|
|
90
|
+
new_statuses[current_pr] = new_status
|
|
91
|
+
current_pr = nil
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
break if line.match?(/^\s*$/)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
status_changed = new_statuses.any?{ |pr,new_status| prs[pr] != new_status }
|
|
98
|
+
approvals_changed = new_approvals.any?{|pr,new_approval_count| approvals[pr] != new_approval_count }
|
|
99
|
+
puts(
|
|
100
|
+
prs:,
|
|
101
|
+
status_changed:,
|
|
102
|
+
approvals_changed:,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if status_changed || approvals_changed
|
|
106
|
+
puts
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
new_approvals.each do |current_pr, new_approval|
|
|
110
|
+
old_approval = approvals[current_pr]
|
|
111
|
+
title = pr_titles[current_pr]
|
|
112
|
+
if old_approval.nil? || old_approval != new_approval
|
|
113
|
+
if options[:notify_approvals]
|
|
114
|
+
if old_approval
|
|
115
|
+
system('pr_approved', current_pr, title, new_approval, old_approval)
|
|
116
|
+
else
|
|
117
|
+
system('pr_approved', current_pr, title, new_approval)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
puts format('%7s (approvals: %s): https://github.com/instacart/carrot/pull/%s', current_pr, new_approval, current_pr)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
new_statuses.each do |current_pr, new_status|
|
|
125
|
+
old_status = prs[current_pr]
|
|
126
|
+
title = pr_titles[current_pr]
|
|
127
|
+
puts format('%7s (status: %s => %s): https://github.com/instacart/carrot/pull/%s', current_pr, old_status, new_status, current_pr)
|
|
128
|
+
if prs.key?(current_pr) && old_status != new_status
|
|
129
|
+
if options[:notify_status]
|
|
130
|
+
case new_status
|
|
131
|
+
when /passing/
|
|
132
|
+
system('pr_passing', current_pr, title, old_status)
|
|
133
|
+
when /failing/
|
|
134
|
+
system('pr_failing', current_pr, title, old_status)
|
|
135
|
+
when /pending/
|
|
136
|
+
system('pr_pending', current_pr, title, old_status)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if new_status[/passing/]
|
|
141
|
+
if options[:mark_ready]
|
|
142
|
+
if options[:notify_publishing]
|
|
143
|
+
system('pr_publishing', current_pr, title)
|
|
144
|
+
end
|
|
145
|
+
system('gh', 'pr', 'ready', current_pr)
|
|
146
|
+
end
|
|
147
|
+
system('gh', 'pr', 'view', '-w', current_pr)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
puts format('%7s (%s): https://github.com/instacart/carrot/pull/%s', current_pr, new_status, current_pr)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
prs = new_statuses
|
|
155
|
+
approvals = new_approvals
|
|
156
|
+
|
|
157
|
+
sleep SLEEP_TIME
|
|
158
|
+
end
|
data/lib/hiiro/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.227
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
@@ -112,6 +112,7 @@ files:
|
|
|
112
112
|
- bin/h-pgsync
|
|
113
113
|
- bin/h-plugin
|
|
114
114
|
- bin/h-pr
|
|
115
|
+
- bin/h-pr-monitor
|
|
115
116
|
- bin/h-project
|
|
116
117
|
- bin/h-session
|
|
117
118
|
- bin/h-sha
|