hiiro 0.1.295 → 0.1.296

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
  SHA256:
3
- metadata.gz: 11e1f44deb6626f97123e066d0c746e82174392c5c60b28a508f4730b62a85f7
4
- data.tar.gz: b72bf798fe7e23b2e1df95746f6f3c07482fd19f620f9114bc356dc4226c3d92
3
+ metadata.gz: 367fe7c933727ce4c7345b14ee3cab47596540d8b46ac1a144a5a89fee546a51
4
+ data.tar.gz: 576f659f1565b3a9c78adf366ad6880e07f2738fc09aac0665fba70dc8a909fb
5
5
  SHA512:
6
- metadata.gz: '06915243bcc868b2ea77def9c9ead108409dd85a3fe6a1a3ca2fbdbfb1b421bb3c5e86ef58ec2535b0e4878f5c8384e8d3b13f04f533f577403a9c3d8181741d'
7
- data.tar.gz: 4d75730e12195c1945af43b348932a0fcd0ae5b4cc7d7da6f1f2b8b4b1c5f6bbc8176523d9919ebbd7f044bf77f6922477d03d396550a8820a3344cd8763f10a
6
+ metadata.gz: 42e9998efb966a27319ea9d49b4ae5e989391c427a5052c04976fa42bd7660ed4374b406d288e400430ce22a1d2009b4e5870eeb370e386d85fd68f0e2b039e7
7
+ data.tar.gz: b90c3c8df288b570aa5465b2f858065da93af8ce5d47ad10b837a0ca4fab74038dbb46777e55dcfa07ee7d3213d1e19bb1dcf3efc11bf7bde01db54ced04fa9f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
  ```markdown
2
+ ## v0.1.296 (2026-03-27)
3
+
4
+ ### Changed
5
+ - `Hiiro::Git::Pr`: added `red?`, `green?`, `pending?`, `active?`, `drafts?`, `conflicts?` predicate methods and `matches_filters?(opts, forced: [])` — filter logic now lives on the `Pr` object instead of in `PinnedPRManager` lambdas
6
+ - `PinnedPRManager`: removed `FILTER_PREDICATES` constant; `apply_filters` and `filter_active?` now delegate to `Pr#matches_filters?`
7
+
2
8
  ## v0.1.295 (2026-03-26)
3
9
 
4
10
  ### Changed
data/lib/hiiro/git/pr.rb CHANGED
@@ -201,6 +201,33 @@ class Hiiro
201
201
  def draft? = is_draft == true
202
202
  def conflicting? = mergeable == 'CONFLICTING'
203
203
 
204
+ # Check-status predicates
205
+ def red? = (c = checks) && c['failed'].to_i > 0
206
+ def green? = (c = checks) && c['failed'].to_i == 0 && c['pending'].to_i == 0 && c['success'].to_i > 0
207
+ def pending? = (c = checks) && c['pending'].to_i > 0 && c['failed'].to_i == 0
208
+
209
+ # Aliases matching filter option names
210
+ def active? = !merged? && !closed?
211
+ def drafts? = draft?
212
+ def conflicts? = conflicting?
213
+
214
+ # Filter dimensions. Flags within each group OR together; groups AND together.
215
+ # e.g. -o -g → (active?) AND (green?), -o -r -g → (active?) AND (red? OR green?)
216
+ STATE_FILTER_KEYS = %i[active merged drafts conflicts].freeze
217
+ CHECK_FILTER_KEYS = %i[red green pending].freeze
218
+
219
+ # Returns true if this PR satisfies the filter options set in opts.
220
+ # forced: injects additional filter keys as if the user had set them.
221
+ def matches_filters?(opts, forced: [])
222
+ state_active = STATE_FILTER_KEYS.select { |k| forced.include?(k) || (opts.respond_to?(k) && opts.send(k)) }
223
+ check_active = CHECK_FILTER_KEYS.select { |k| forced.include?(k) || (opts.respond_to?(k) && opts.send(k)) }
224
+
225
+ state_match = state_active.empty? || state_active.any? { |k| send(:"#{k}?") }
226
+ check_match = check_active.empty? || check_active.any? { |k| send(:"#{k}?") }
227
+
228
+ state_match && check_match
229
+ end
230
+
204
231
  def view = system('gh', 'pr', 'view', number.to_s)
205
232
  def checkout = system('gh', 'pr', 'checkout', number.to_s)
206
233
 
@@ -5,24 +5,6 @@ require 'fileutils'
5
5
 
6
6
  class Hiiro
7
7
  class PinnedPRManager
8
- FILTER_PREDICATES = {
9
- red: ->(pr) { (c = pr.checks) && c['failed'].to_i > 0 },
10
- green: ->(pr) { (c = pr.checks) && c['failed'].to_i == 0 && c['pending'].to_i == 0 && c['success'].to_i > 0 },
11
- conflicts: ->(pr) { pr.conflicting? },
12
- drafts: ->(pr) { pr.draft? },
13
- pending: ->(pr) { (c = pr.checks) && c['pending'].to_i > 0 && c['failed'].to_i == 0 },
14
- merged: ->(pr) { pr.merged? },
15
- active: ->(pr) { !pr.merged? && !pr.closed? },
16
- }.freeze
17
-
18
- # Filters are split into two orthogonal dimensions:
19
- # state — what lifecycle state the PR is in (active, merged, draft, conflicting)
20
- # checks — what the CI check status is (red, green, pending)
21
- # Flags within each dimension OR together; dimensions AND together.
22
- # e.g. -o -g → (active) AND (green checks)
23
- # -o -r -g → (active) AND (red OR green)
24
- STATE_FILTER_KEYS = %i[active merged drafts conflicts].freeze
25
- CHECK_FILTER_KEYS = %i[red green pending].freeze
26
8
 
27
9
  def self.add_resolvers(hiiro)
28
10
  pm = new
@@ -393,24 +375,14 @@ class Hiiro
393
375
  end
394
376
 
395
377
  def filter_active?(opts)
396
- FILTER_PREDICATES.keys.any? { |f| opts.respond_to?(f) && opts.send(f) } ||
378
+ all_keys = Hiiro::Git::Pr::STATE_FILTER_KEYS + Hiiro::Git::Pr::CHECK_FILTER_KEYS
379
+ all_keys.any? { |f| opts.respond_to?(f) && opts.send(f) } ||
397
380
  (opts.respond_to?(:tag) && Array(opts.tag).any?)
398
381
  end
399
382
 
400
383
  def apply_filters(prs, opts, forced: [])
401
- active = FILTER_PREDICATES.keys.select { |f| opts.respond_to?(f) && opts.send(f) }
402
- active = (active + forced).uniq
384
+ results = prs.select { |pr| pr.matches_filters?(opts, forced: forced) }
403
385
 
404
- state_flags = active & STATE_FILTER_KEYS
405
- check_flags = active & CHECK_FILTER_KEYS
406
-
407
- results = prs.select do |pr|
408
- state_match = state_flags.empty? || state_flags.any? { |f| FILTER_PREDICATES[f]&.call(pr) }
409
- check_match = check_flags.empty? || check_flags.any? { |f| FILTER_PREDICATES[f]&.call(pr) }
410
- state_match && check_match
411
- end
412
-
413
- # Tags are an AND post-filter; multiple tags are OR'd among themselves
414
386
  tag_filter = Array(opts.respond_to?(:tag) ? opts.tag : nil).map(&:to_s).reject(&:empty?)
415
387
  unless tag_filter.empty?
416
388
  results = results.select { |pr| (Array(pr.tags) & tag_filter).any? }
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.295"
2
+ VERSION = "0.1.296"
3
3
  end
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.295
4
+ version: 0.1.296
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota