hiiro 0.1.294 → 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: 9ca86bd25276511b4190cdde354a65a71243a2fad0b94604e10ac14d466d8c33
4
- data.tar.gz: 9cb9807c855963e1b5c260f9be734c7b3032a1cca941bed1432e40e06d144f33
3
+ metadata.gz: 367fe7c933727ce4c7345b14ee3cab47596540d8b46ac1a144a5a89fee546a51
4
+ data.tar.gz: 576f659f1565b3a9c78adf366ad6880e07f2738fc09aac0665fba70dc8a909fb
5
5
  SHA512:
6
- metadata.gz: d3d792f804941b33782102e92a81e8a12abdafcfd01182db74a98b9e2553b4286a4cb135a4da44b81e7cd707af38429c7b976d84d86768c02be0ed0f3b7d3dd6
7
- data.tar.gz: a4147e91c73d2aed9cd89868d5830eca7b2db4d5361e74062df995b9cd5d4d692276c075abadb3beaf5a8ac69f9ba696043cd7600ffa27d3505d8e1ef062c845
6
+ metadata.gz: 42e9998efb966a27319ea9d49b4ae5e989391c427a5052c04976fa42bd7660ed4374b406d288e400430ce22a1d2009b4e5870eeb370e386d85fd68f0e2b039e7
7
+ data.tar.gz: b90c3c8df288b570aa5465b2f858065da93af8ce5d47ad10b837a0ca4fab74038dbb46777e55dcfa07ee7d3213d1e19bb1dcf3efc11bf7bde01db54ced04fa9f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
-
2
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
+
8
+ ## v0.1.295 (2026-03-26)
9
+
10
+ ### Changed
11
+ - `h pr ls`/`h pr update`: filter flags now use AND-across-dimensions logic — state flags (`-o`, `-m`, `-D`, `-c`) OR within their group, check flags (`-r`, `-g`, `-p`) OR within theirs, and the two groups AND together; e.g. `-o -g` shows open PRs with passing checks, `-o -r -g` shows open PRs with failing or passing checks
12
+
3
13
  ## v0.1.294 (2026-03-26)
4
14
 
5
15
  ### Fixed
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,15 +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
8
 
18
9
  def self.add_resolvers(hiiro)
19
10
  pm = new
@@ -384,17 +375,14 @@ class Hiiro
384
375
  end
385
376
 
386
377
  def filter_active?(opts)
387
- 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) } ||
388
380
  (opts.respond_to?(:tag) && Array(opts.tag).any?)
389
381
  end
390
382
 
391
383
  def apply_filters(prs, opts, forced: [])
392
- active = FILTER_PREDICATES.keys.select { |f| opts.respond_to?(f) && opts.send(f) }
393
- active = (active + forced).uniq
384
+ results = prs.select { |pr| pr.matches_filters?(opts, forced: forced) }
394
385
 
395
- results = active.empty? ? prs : prs.select { |pr| active.any? { |f| FILTER_PREDICATES[f]&.call(pr) } }
396
-
397
- # Tags are an AND post-filter; multiple tags are OR'd among themselves
398
386
  tag_filter = Array(opts.respond_to?(:tag) ? opts.tag : nil).map(&:to_s).reject(&:empty?)
399
387
  unless tag_filter.empty?
400
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.294"
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.294
4
+ version: 0.1.296
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota