kettle-family 1.3.51 → 1.3.53

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: cca9f3c9bbf384bb2986b3ca786c9310258c19ee6cba6481a6a2f025661964c3
4
- data.tar.gz: a7e805bebfe396a081fd05a338e65d5bf6aaf06a604ee30c1696a68a759e096e
3
+ metadata.gz: 8ac74650189f26fe56fe82b278d6fb45600dd53a373bdbbbd81c139c66f0124f
4
+ data.tar.gz: 137dffa05fc18e82328f50dcf3afae4050a2c4705b3c33eef57c9a5ef4afff74
5
5
  SHA512:
6
- metadata.gz: a94ff6b07e58503f1a49a20c6d231b20bdaeb8ced42b53df42c73f2d507b34832f2d12ecdde52b4b491b00b2e196bde48fb674f2957ba170f747f68edaa57ab4
7
- data.tar.gz: a16ed9599f89a5f43cbb1c42836dee26bf1f3b79159fbcaf543a49ec5a8a7fccd2dd08453b1b633b7982b340829c7d0522d25365737a3e021576528d93ac5b6b
6
+ metadata.gz: 196f1e4b93738a4c6952a3e580956a7de610ebe43263a8c210e490df4e60b4c971d79a29e99be09c42a45abd17d8ec22ec10587f6c1040b718932d5f77277f04
7
+ data.tar.gz: c62dccd06c683fde361f3a81e56eda91ceb6d2195f233478c62497858a3d00362e4b71ecc63c0105fdf7dbddb8feaf23f6a00d863741421d0a7dbe7abf3b4cda
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,48 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [1.3.53] - 2026-11-28
34
+
35
+ - TAG: [v1.3.53][1.3.53t]
36
+ - COVERAGE: 94.22% -- 9326/9898 lines in 50 files
37
+ - BRANCH COVERAGE: 79.42% -- 3936/4956 branches in 50 files
38
+ - 40.19% documented
39
+
40
+ ### Added
41
+
42
+ - `RemoteCheck`, `fix-remotes`, and `state` remote-drift reporting: inspect hosted git remotes across family members offline (comparing against explicit `remotes.expected_org`/`family.org`, gemspec homepage/source org, and family majority org while respecting `remotes.allowed_orgs`), surface mismatches in `state` (`git_remote_org`, `git_remote_issues`, conditional `remote` column, and `remote warnings:` with exact fix hints), probe flagged GitHub remotes on `fix-remotes` and `release`/`template`/`sync`/`push` preflight to auto-fix verified permanent redirects (`301`/`308`) under `--execute` while aborting on HTTP `404` or explicit org-policy violations (fixes #90)
43
+
44
+ - managed family mise tasks: wire a `fix-remotes` task (`bundle exec kettle-family fix-remotes --execute`) into the generated `mise-family.tasks.toml` for every family root, so redirected git remotes can be fixed fleet-wide via `mise run fix-remotes`
45
+
46
+ ### Changed
47
+
48
+ - [kc] kettle-jem/prepare: updated 8 project files since the last release:
49
+ - dependencies (8)
50
+
51
+ - [kc] kettle-jem/template: updated 2 project files since the last release:
52
+ - code and tests (1)
53
+ - other (1)
54
+
55
+ ### Fixed
56
+
57
+ - release resume hints: preserve `--start-step N` (such as `--start-step 10` on CI monitoring timeouts/failures) in both per-result and final summary `resume:` commands by extracting the resume step from failed `ci_monitor` (`restart_hint`/`reason`), `summary` (`error_message`), and blocking `diagnostic` events as well as plain-text `kettle-release` restart output, while ignoring non-failed events and `summary["start_step"]` (fixes #88)
58
+
59
+ ## [1.3.52] - 2026-11-27
60
+
61
+ - TAG: [v1.3.52][1.3.52t]
62
+ - COVERAGE: 94.38% -- 8960/9494 lines in 49 files
63
+ - BRANCH COVERAGE: 79.76% -- 3791/4753 branches in 49 files
64
+ - 41.52% documented
65
+
66
+ ### Added
67
+
68
+ - `state` (`release-state`): report single-char git working-tree dirty state (`-` clean, `+` staged, `?` untracked, `*` unstaged, `!` conflict) in the `^ / v / ~` column, a conditional `wt` column (`-`, `N`, `@`, `@+N`) when linked git worktrees are present, and structured `git_dirty`/`git_state`/`git_*_count`/`git_worktree`/`git_linked_worktrees` fields in `--json` output (fixes #86)
69
+
70
+ ### Fixed
71
+
72
+ - progress pane secondary ticker: move remaining `N/M` counters (`attempt/attempts` for `release_lockfile`, `release_probe`, and `github_release`; `queued/total` for `secret_provider`) out of TTY status row text and into the dedicated `secondary:` ticker column while keeping counts in plain log lines (fixes #83)
73
+ - release secrets broker: stop `CommandRunner` from concurrently selecting on `$stdin` while `Secrets::TerminalPrompter` reads a fallback RubyGems MFA code (which left the main loop blocked in `$stdin.readpartial` after the prompter consumed the line, freezing terminal output until a second Enter). Disable child stdin forwarding under `kettle-release --yes` with an active broker, coordinate exclusive terminal stdin handoff for `--no-accept` runs, exit Open3 interactive loops once child stdout/stderr close, and require a prompt delimiter (`:`/`?`) in `otp_response_prompt?` so intro sentences and invalid-OTP errors never double-fire
74
+
33
75
  ## [1.3.51] - 2026-11-26
34
76
 
35
77
  - TAG: [v1.3.51][1.3.51t]
@@ -3578,7 +3620,11 @@ Please file a bug if you notice a violation of semantic versioning.
3578
3620
  - Fixed CI load failures on engines without compatible `pty` support by falling back to Open3 for interactive release commands.
3579
3621
  - Fixed Ruby 3.2 version-bump support by loading Prism lazily and wiring the Prism gem only for MRI versions that need it.
3580
3622
 
3581
- [Unreleased]: https://github.com/kettle-dev/kettle-family/compare/v1.3.51...HEAD
3623
+ [Unreleased]: https://github.com/kettle-dev/kettle-family/compare/v1.3.53...HEAD
3624
+ [1.3.53]: https://github.com/kettle-dev/kettle-family/compare/v1.3.52...v1.3.53
3625
+ [1.3.53t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.53
3626
+ [1.3.52]: https://github.com/kettle-dev/kettle-family/compare/v1.3.51...v1.3.52
3627
+ [1.3.52t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.52
3582
3628
  [1.3.51]: https://github.com/kettle-dev/kettle-family/compare/v1.3.50...v1.3.51
3583
3629
  [1.3.51t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.51
3584
3630
  [1.3.50]: https://github.com/kettle-dev/kettle-family/compare/v1.3.49...v1.3.50
data/README.md CHANGED
@@ -516,6 +516,7 @@ The command names below are available from `kettle-family --help`:
516
516
  | `pull` | Pull selected member repositories with rebase. |
517
517
  | `sync` | Fetch and rebase selected member repositories and branches. |
518
518
  | `up` | Pull with rebase, then push selected member repositories. |
519
+ | `fix-remotes` | Plan or execute git remote URL updates for permanently redirected repositories. |
519
520
  | `branch-lanes` | Audit configured long-lived release branches. |
520
521
  | `release-state` | Report release state for selected members. |
521
522
  | `state` | Alias for `release-state`. |
@@ -1143,7 +1144,7 @@ If none of the available licenses suit your use case, please [contact us](mailto
1143
1144
  [📌gitmoji]: https://gitmoji.dev
1144
1145
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
1145
1146
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
1146
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-9.275-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1147
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-9.898-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
1147
1148
  [🔐security]: https://github.com/kettle-dev/kettle-family/blob/main/SECURITY.md
1148
1149
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
1149
1150
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -11,10 +11,10 @@ module Kettle
11
11
  class CLI < CommandKit::Command
12
12
  include CommandKit::Commands
13
13
 
14
- COMMANDS = %w[version mise-trust mise-tasks discover plan report metadata check clean-blockers clean-installed clean-unreleased reconcile-releases reset test lint docs template gha-sha-pins bup bupb update-bundler bex install bump bump-version add-changelog release push pull sync up branch-lanes release-state state].freeze
15
- EVENT_COMMANDS = %w[bup bupb update-bundler up push pull sync test install lint docs bex check reset clean-unreleased clean-blockers clean-installed bump bump-version add-changelog mise-trust reconcile-releases].freeze
14
+ COMMANDS = %w[version mise-trust mise-tasks discover plan report metadata check clean-blockers clean-installed clean-unreleased reconcile-releases reset test lint docs template gha-sha-pins bup bupb update-bundler bex install bump bump-version add-changelog release push pull sync up fix-remotes branch-lanes release-state state].freeze
15
+ EVENT_COMMANDS = %w[bup bupb update-bundler up push pull sync fix-remotes test install lint docs bex check reset clean-unreleased clean-blockers clean-installed bump bump-version add-changelog mise-trust reconcile-releases].freeze
16
16
  PROGRESS_COMMANDS = (%w[release template gha-sha-pins] + EVENT_COMMANDS).freeze
17
- WORKFLOW_COMMANDS = %w[check reset test lint docs template gha-sha-pins bup bupb update-bundler bex release push pull sync up].freeze
17
+ WORKFLOW_COMMANDS = %w[check reset test lint docs template gha-sha-pins bup bupb update-bundler bex release push pull sync up fix-remotes].freeze
18
18
 
19
19
  command_name "kettle-family"
20
20
  usage "[options] COMMAND [ARGS...]"
@@ -778,6 +778,12 @@ module Kettle
778
778
  description "Plan or execute git pull --rebase then git push per member."
779
779
  end
780
780
 
781
+ class FixRemotes < WorkflowCommand
782
+ command_name "fix-remotes"
783
+ usage "[options]"
784
+ description "Plan or execute git remote URL updates for permanently redirected repositories."
785
+ end
786
+
781
787
  command Discover
782
788
  command Version
783
789
  command MiseTrust
@@ -809,6 +815,7 @@ module Kettle
809
815
  command Pull
810
816
  command Sync
811
817
  command Up
818
+ command FixRemotes
812
819
  command BranchLanes
813
820
  command ReleaseState
814
821
  command State
@@ -224,12 +224,15 @@ module Kettle
224
224
  end
225
225
  private_constant :FailureStatus
226
226
 
227
- def initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil, mise_adapter: nil)
227
+ def initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil, mise_adapter: nil, forward_stdin: true, stdin_input: nil, stdin_gate: nil)
228
228
  @execute = execute
229
229
  @accept = accept
230
230
  @gem_signing_password = gem_signing_password
231
231
  @otp_coordinator = otp_coordinator
232
232
  @mise_adapter = mise_adapter || Kettle::Family.mise_adapter
233
+ @forward_stdin = forward_stdin
234
+ @stdin_input = stdin_input
235
+ @stdin_gate = stdin_gate
233
236
  end
234
237
 
235
238
  def call(member:, phase:, command:, env: {}, interactive: false, raw: false, stdout_line_handler: nil, log_path: nil, passthrough_output: true, chdir: member.root, **options)
@@ -282,7 +285,7 @@ module Kettle
282
285
 
283
286
  private
284
287
 
285
- attr_reader :execute, :accept, :gem_signing_password, :otp_coordinator
288
+ attr_reader :execute, :accept, :gem_signing_password, :otp_coordinator, :stdin_gate
286
289
 
287
290
  def run_streaming(env:, argv:, chdir:, process_options:, stdout_line_handler:, log_io: nil)
288
291
  captured_stdout = +""
@@ -354,22 +357,16 @@ module Kettle
354
357
  prompt_buffer = +""
355
358
  status = nil
356
359
  PTY.spawn(env, *argv, chdir: chdir, **process_options) do |output, input, pid|
357
- begin
360
+ with_stdin_gate do |wakeup|
361
+ stdin_eof = false
358
362
  loop do
359
- readers = [output]
360
- readers << $stdin if $stdin.tty? && !otp_coordinator
361
- ready = IO.select(readers)
362
- ready.first.each do |reader|
363
- if reader.equal?(output)
364
- chunk = output.readpartial(1024)
365
- stdout << chunk
366
- transcript_write(log_io, chunk)
367
- stdout_line_buffer = print_interactive_stdout(stdout_line_buffer, chunk, stdout_line_handler, passthrough_output: passthrough_output)
368
- prompt_buffer = handle_interactive_prompt(input, chunk, member_name: member_name, prompt_buffer: prompt_buffer)
369
- else
370
- chunk = $stdin.readpartial(1024)
371
- input.write(chunk)
372
- end
363
+ ready_outputs, stdin_eof = select_interactive_readers([output], input: input, wakeup: wakeup, stdin_eof: stdin_eof)
364
+ ready_outputs.each do |reader|
365
+ chunk = reader.readpartial(1024)
366
+ stdout << chunk
367
+ transcript_write(log_io, chunk)
368
+ stdout_line_buffer = print_interactive_stdout(stdout_line_buffer, chunk, stdout_line_handler, passthrough_output: passthrough_output)
369
+ prompt_buffer = handle_interactive_prompt(input, chunk, member_name: member_name, prompt_buffer: prompt_buffer)
373
370
  end
374
371
  end
375
372
  rescue Errno::EIO, EOFError
@@ -407,29 +404,25 @@ module Kettle
407
404
  status = nil
408
405
  Open3.popen3(env, *argv, chdir: chdir, **process_options) do |input, output, error, wait_thread|
409
406
  readers = [output, error]
410
- readers << $stdin if $stdin.tty? && !otp_coordinator
411
- begin
407
+ with_stdin_gate do |wakeup|
408
+ stdin_eof = false
412
409
  until readers.empty?
413
- ready = IO.select(readers)
414
- ready.first.each do |reader|
415
- if reader.equal?($stdin)
416
- input.write($stdin.readpartial(1024))
417
- else
418
- stdout_line_buffer, prompt_buffer = read_interactive_stream(
419
- reader,
420
- output,
421
- input,
422
- captured_stdout,
423
- captured_stderr,
424
- readers,
425
- member_name: member_name,
426
- stdout_line_buffer: stdout_line_buffer,
427
- stdout_line_handler: stdout_line_handler,
428
- log_io: log_io,
429
- passthrough_output: passthrough_output,
430
- prompt_buffer: prompt_buffer
431
- )
432
- end
410
+ ready_outputs, stdin_eof = select_interactive_readers(readers, input: input, wakeup: wakeup, stdin_eof: stdin_eof)
411
+ ready_outputs.each do |reader|
412
+ stdout_line_buffer, prompt_buffer = read_interactive_stream(
413
+ reader,
414
+ output,
415
+ input,
416
+ captured_stdout,
417
+ captured_stderr,
418
+ readers,
419
+ member_name: member_name,
420
+ stdout_line_buffer: stdout_line_buffer,
421
+ stdout_line_handler: stdout_line_handler,
422
+ log_io: log_io,
423
+ passthrough_output: passthrough_output,
424
+ prompt_buffer: prompt_buffer
425
+ )
433
426
  end
434
427
  end
435
428
  rescue Error => error
@@ -452,8 +445,9 @@ module Kettle
452
445
  prompt_buffer = +""
453
446
  status = nil
454
447
  Open3.popen3(env, *argv, chdir: chdir, **process_options) do |input, output, stderr_stream, wait_thread|
455
- streams = [output, stderr_stream]
456
- streams << $stdin if $stdin.tty? && !otp_coordinator
448
+ output_streams = [output, stderr_stream]
449
+ streams = output_streams.dup
450
+ streams << stdin_stream if forward_stdin?
457
451
  queue = Queue.new
458
452
  readers = streams.map do |stream|
459
453
  Thread.new do # rubocop:disable ThreadSafety/NewThread -- Windows pipes are not selectable with IO.select.
@@ -462,17 +456,16 @@ module Kettle
462
456
  queue << [stream, nil]
463
457
  end
464
458
  end
465
- input_reader = readers[streams.index($stdin)] if streams.include?($stdin)
466
- active_streams = streams.dup
459
+ input_reader = readers[streams.index(stdin_stream)] if streams.include?(stdin_stream)
467
460
  begin
468
- until active_streams.empty?
461
+ until output_streams.empty?
469
462
  stream, chunk = queue.pop
470
463
  unless chunk
471
- active_streams.delete(stream)
464
+ output_streams.delete(stream)
472
465
  next
473
466
  end
474
- if stream.equal?($stdin)
475
- input.write(chunk)
467
+ if stream.equal?(stdin_stream)
468
+ write_forwarded_stdin(input, chunk)
476
469
  next
477
470
  end
478
471
  if stream.equal?(output)
@@ -501,6 +494,77 @@ module Kettle
501
494
  [captured_stdout, captured_stderr, status]
502
495
  end
503
496
 
497
+ def forward_stdin?
498
+ @forward_stdin && !otp_coordinator && stdin_stream.respond_to?(:tty?) && stdin_stream.tty?
499
+ end
500
+
501
+ def stdin_stream
502
+ @stdin_input || $stdin
503
+ end
504
+
505
+ def with_stdin_gate(&block)
506
+ if forward_stdin? && stdin_gate
507
+ stdin_gate.with_stdin_forwarder(&block)
508
+ else
509
+ yield nil
510
+ end
511
+ end
512
+
513
+ def select_interactive_readers(output_readers, input:, wakeup:, stdin_eof:)
514
+ readers = output_readers.dup
515
+ watching_stdin = false
516
+ stdin_chunk = nil
517
+ begin
518
+ if !stdin_eof && forward_stdin?
519
+ watching_stdin = stdin_gate ? stdin_gate.enter_stdin_select : true
520
+ readers << stdin_stream if watching_stdin
521
+ readers << wakeup if wakeup
522
+ end
523
+ ready_readers = IO.select(readers).first
524
+ drain_wakeup(wakeup) if wakeup && ready_readers.include?(wakeup)
525
+ if watching_stdin
526
+ stdin_chunk, stdin_eof = read_forwarded_stdin(ready_readers.include?(stdin_stream))
527
+ watching_stdin = false
528
+ end
529
+ ensure
530
+ stdin_gate.leave_stdin_select if watching_stdin && stdin_gate
531
+ end
532
+ write_forwarded_stdin(input, stdin_chunk) if stdin_chunk
533
+ [ready_readers.select { |reader| output_readers.include?(reader) }, stdin_eof]
534
+ end
535
+
536
+ def read_forwarded_stdin(stdin_ready)
537
+ return read_stdin_chunk(stdin_ready) unless stdin_gate
538
+
539
+ result = [nil, false]
540
+ stdin_gate.leave_stdin_select do
541
+ result = read_stdin_chunk(stdin_ready)
542
+ end
543
+ result
544
+ end
545
+
546
+ def read_stdin_chunk(stdin_ready)
547
+ return [nil, false] unless stdin_ready
548
+
549
+ [stdin_stream.readpartial(1024), false]
550
+ rescue IOError
551
+ [nil, true]
552
+ end
553
+
554
+ def write_forwarded_stdin(input, chunk)
555
+ input.write(chunk)
556
+ rescue Errno::EPIPE, IOError
557
+ nil
558
+ end
559
+
560
+ def drain_wakeup(wakeup)
561
+ loop do
562
+ break unless wakeup.read_nonblock(1024, exception: false).is_a?(String)
563
+ end
564
+ rescue IOError
565
+ nil
566
+ end
567
+
504
568
  def read_interactive_stream(
505
569
  reader,
506
570
  output,
@@ -650,7 +714,7 @@ module Kettle
650
714
  end
651
715
 
652
716
  def otp_response_prompt?(chunk)
653
- chunk.match?(/(?:OTP code|one-time password|\bCode:\s*)/i)
717
+ chunk.match?(/(?:OTP code|one-time password|\bCode)\s*[:?]\s*\z/i)
654
718
  end
655
719
 
656
720
  def signing_password_prompt?(chunk)
@@ -339,6 +339,16 @@ module Kettle
339
339
  fetch_path("release", "required_remotes")
340
340
  end
341
341
 
342
+ def expected_org
343
+ value = fetch_path("remotes", "expected_org") || fetch_path("family", "org")
344
+ value = value.to_s.strip
345
+ value.empty? ? nil : value
346
+ end
347
+
348
+ def allowed_remote_orgs
349
+ Array(fetch_path("remotes", "allowed_orgs")).map { |org| org.to_s.strip }.reject(&:empty?)
350
+ end
351
+
342
352
  def release_env
343
353
  stringify_env(fetch_path("release", "env") || {})
344
354
  end
@@ -385,7 +385,7 @@ module Kettle
385
385
  # families write each member's own.
386
386
  "changelog" => "bundle exec kettle-family add-changelog --execute"
387
387
  }
388
- %w[install docs clean-unreleased gha-sha-pins bex branch-lanes discover metadata report pull push up sync reset mise-trust reconcile-releases].each do |command|
388
+ %w[install docs clean-unreleased gha-sha-pins bex branch-lanes discover metadata report pull push up sync fix-remotes reset mise-trust reconcile-releases].each do |command|
389
389
  name = {"clean-unreleased" => "clean", "gha-sha-pins" => "pins"}.fetch(command, command)
390
390
  flags = %w[branch-lanes discover metadata report mise-trust].include?(command) ? "" : " --execute"
391
391
  flags += " --upgrade major" if name == "pins"
@@ -24,6 +24,7 @@ module Kettle
24
24
  TRANSFER_CHANGELOG_TOTAL_UNSET = Object.new.freeze
25
25
  CACHE_MISS = Object.new.freeze
26
26
  WORKTREE_ADMIN_MUTEX = Mutex.new
27
+ UNMERGED_STATUS_CODES = %w[DD AU UD UA DU AA UU].freeze
27
28
 
28
29
  # +branches+ scopes the check to specific release target branches. A
29
30
  # branch-stack member produces one result per branch; a per-branch
@@ -39,27 +40,48 @@ module Kettle
39
40
  @transfer_changelog_status_by_root = {}
40
41
  @transfer_changelog_lag_by_key = {}
41
42
  @transfer_changelog_total_count = TRANSFER_CHANGELOG_TOTAL_UNSET
43
+ @git_status_by_worktree = {}
44
+ @git_worktrees_by_common_dir = {}
45
+ @branch_worktree_snapshot = nil
42
46
  @cache_mutex = Mutex.new
43
47
  @transfer_changelog_total_mutex = Mutex.new
44
48
  end
45
49
 
46
50
  def results(event_handler: nil)
47
- return scoped_checkout_results(event_handler: event_handler) if checked_out_scoped_results?
48
- return branch_results(event_handler: event_handler) unless release_target_branches.empty?
49
- if shared_changelog?
50
- results = parallel_map(members) { |member| check_shared_changelog_member_or_local(member, event_handler: event_handler) }
51
- return normalize_lockstep_version_bump(normalize_shared_version_bump(results))
52
- end
53
-
54
- member_results = parallel_map(members) do |member|
55
- member_branch_results = member_local_branch_results(member, event_handler: event_handler)
56
- member_branch_results || check_member(member, event_handler: event_handler)
51
+ computed = if checked_out_scoped_results?
52
+ scoped_checkout_results(event_handler: event_handler)
53
+ elsif !release_target_branches.empty?
54
+ branch_results(event_handler: event_handler)
55
+ elsif shared_changelog?
56
+ raw = parallel_map(members) { |member| check_shared_changelog_member_or_local(member, event_handler: event_handler) }
57
+ normalize_lockstep_version_bump(normalize_shared_version_bump(raw))
58
+ else
59
+ member_results = parallel_map(members) do |member|
60
+ member_branch_results = member_local_branch_results(member, event_handler: event_handler)
61
+ member_branch_results || check_member(member, event_handler: event_handler)
62
+ end
63
+ normalize_lockstep_version_bump(member_results.flat_map { |result| Array(result) })
57
64
  end
58
- normalize_lockstep_version_bump(member_results.flat_map { |result| Array(result) })
65
+ enrich_remote_state!(computed)
59
66
  end
60
67
 
61
68
  private
62
69
 
70
+ def enrich_remote_state!(computed_results)
71
+ inspection = RemoteCheck.inspect_family(config: config, members: members)
72
+ by_member = inspection.fetch(:members)
73
+ computed_results.each do |result|
74
+ next unless result.respond_to?(:state) && result.state.is_a?(Hash)
75
+
76
+ info = by_member[result.member_name]
77
+ next unless info
78
+
79
+ result.state["git_remote_org"] = info[:origin_org] if info[:origin_org]
80
+ result.state["git_remote_issues"] = info[:issues]
81
+ end
82
+ computed_results
83
+ end
84
+
63
85
  attr_reader :members, :config, :jobs, :branches
64
86
 
65
87
  # A single-branch scope whose checkout already sits on that branch needs
@@ -336,6 +358,7 @@ module Kettle
336
358
  enriched = state.dup
337
359
  current_branch = branch || git_output(root, "branch", "--show-current")
338
360
  enriched["current_branch"] = current_branch unless current_branch.to_s.empty?
361
+ enrich_working_tree_state!(root, enriched, branch: branch)
339
362
 
340
363
  version = state["latest_released"].to_s.empty? ? state["latest_changelog_version"] : state["latest_released"]
341
364
  return enriched if version.to_s.empty?
@@ -361,6 +384,166 @@ module Kettle
361
384
  enriched
362
385
  end
363
386
 
387
+ def enrich_working_tree_state!(root, enriched, branch: nil)
388
+ if @branch_worktree_snapshot && branch
389
+ snapshot = @branch_worktree_snapshot
390
+ checked_out_path = snapshot[:by_branch][branch]
391
+ enriched["git_worktree"] = !checked_out_path.nil? && checked_out_path != snapshot[:primary_path]
392
+ enriched["git_linked_worktrees"] = snapshot[:linked_count]
393
+ if checked_out_path && (status = git_status_summary(checked_out_path))
394
+ enriched.merge!(status)
395
+ end
396
+ return
397
+ end
398
+
399
+ worktree_info = git_worktree_info(root)
400
+ if worktree_info
401
+ enriched["git_worktree"] = worktree_info[:linked]
402
+ enriched["git_linked_worktrees"] = worktree_info[:linked_count]
403
+ end
404
+ if (status = git_status_summary(root))
405
+ enriched.merge!(status)
406
+ end
407
+ end
408
+
409
+ def git_worktree_info(root)
410
+ git_dir, common_dir = git_dir_paths(root)
411
+ return nil unless git_dir && common_dir
412
+
413
+ snapshot = @cache_mutex.synchronize { @git_worktrees_by_common_dir[common_dir] }
414
+ unless snapshot
415
+ snapshot = snapshot_git_worktrees(root, common_dir: common_dir)
416
+ @cache_mutex.synchronize { @git_worktrees_by_common_dir[common_dir] = snapshot } if snapshot
417
+ end
418
+ return nil unless snapshot
419
+
420
+ {
421
+ linked: git_dir != common_dir,
422
+ linked_count: snapshot[:linked_count]
423
+ }
424
+ end
425
+
426
+ def snapshot_git_worktrees(root, common_dir: nil)
427
+ return nil unless git_work_tree?(root)
428
+
429
+ common_dir ||= git_dir_paths(root).last
430
+ stdout, _stderr, status = Open3.capture3("git", "worktree", "list", "--porcelain", chdir: root)
431
+ return nil unless status.success?
432
+
433
+ entries = parse_git_worktree_list(stdout)
434
+ primary_path = entries.first&.fetch(:path)
435
+ by_branch = {}
436
+ entries.each do |entry|
437
+ by_branch[entry[:branch]] = entry[:path] if entry[:branch]
438
+ end
439
+ {
440
+ common_dir: common_dir,
441
+ primary_path: primary_path,
442
+ linked_count: [entries.length - 1, 0].max,
443
+ by_branch: by_branch
444
+ }
445
+ end
446
+
447
+ def parse_git_worktree_list(stdout)
448
+ entries = []
449
+ current = nil
450
+ stdout.each_line do |raw_line|
451
+ line = raw_line.strip
452
+ if line.empty?
453
+ entries << current if current && !current[:prunable]
454
+ current = nil
455
+ elsif line.start_with?("worktree ")
456
+ current = {path: canonical_git_path(line.delete_prefix("worktree ")), branch: nil, prunable: false}
457
+ elsif current && line.start_with?("branch ")
458
+ ref = line.delete_prefix("branch ")
459
+ current[:branch] = ref.delete_prefix("refs/heads/")
460
+ elsif current && line.start_with?("prunable")
461
+ current[:prunable] = true
462
+ end
463
+ end
464
+ entries << current if current && !current[:prunable]
465
+ entries
466
+ end
467
+
468
+ def git_dir_paths(root)
469
+ stdout, _stderr, status = Open3.capture3("git", "rev-parse", "--git-dir", "--git-common-dir", chdir: root)
470
+ return [nil, nil] unless status.success?
471
+
472
+ lines = stdout.lines.map(&:strip).reject(&:empty?)
473
+ return [nil, nil] unless lines.length == 2
474
+
475
+ lines.map { |path| canonical_git_path(File.expand_path(path, root)) }
476
+ end
477
+
478
+ def git_status_summary(worktree_root)
479
+ toplevel = git_output(worktree_root, "rev-parse", "--show-toplevel")
480
+ return nil if toplevel.to_s.empty?
481
+
482
+ cache_key = canonical_git_path(toplevel)
483
+ cached = @cache_mutex.synchronize { @git_status_by_worktree.fetch(cache_key, CACHE_MISS) }
484
+ return cached unless cached.equal?(CACHE_MISS)
485
+
486
+ stdout, _stderr, status = Open3.capture3("git", "status", "--porcelain=v1", "-z", "--untracked-files=normal", chdir: toplevel)
487
+ summary = status.success? ? parse_git_status_porcelain(stdout) : nil
488
+ @cache_mutex.synchronize { @git_status_by_worktree[cache_key] = summary }
489
+ summary
490
+ end
491
+
492
+ def parse_git_status_porcelain(stdout)
493
+ entries = stdout.split("\0")
494
+ staged = 0
495
+ unstaged = 0
496
+ untracked = 0
497
+ conflict = 0
498
+ index = 0
499
+ while index < entries.length
500
+ entry = entries[index]
501
+ index += 1
502
+ next if entry.empty?
503
+
504
+ code = entry[0, 2]
505
+ x = code[0]
506
+ y = code[1]
507
+ index += 1 if %w[R C].include?(x) || %w[R C].include?(y)
508
+
509
+ if code == "??"
510
+ untracked += 1
511
+ elsif UNMERGED_STATUS_CODES.include?(code)
512
+ conflict += 1
513
+ else
514
+ staged += 1 if x && x != " "
515
+ unstaged += 1 if y && y != " "
516
+ end
517
+ end
518
+
519
+ git_state = if conflict.positive?
520
+ "conflict"
521
+ elsif unstaged.positive?
522
+ "unstaged"
523
+ elsif untracked.positive?
524
+ "untracked"
525
+ elsif staged.positive?
526
+ "staged"
527
+ else
528
+ "clean"
529
+ end
530
+
531
+ {
532
+ "git_dirty" => git_state != "clean",
533
+ "git_state" => git_state,
534
+ "git_staged_count" => staged,
535
+ "git_unstaged_count" => unstaged,
536
+ "git_untracked_count" => untracked,
537
+ "git_conflict_count" => conflict
538
+ }
539
+ end
540
+
541
+ def canonical_git_path(path)
542
+ File.realpath(path)
543
+ rescue Errno::ENOENT, Errno::ENOTDIR
544
+ File.expand_path(path)
545
+ end
546
+
364
547
  def git_work_tree?(root)
365
548
  _stdout, _stderr, status = Open3.capture3("git", "rev-parse", "--is-inside-work-tree", chdir: root)
366
549
  status.success?
@@ -954,8 +1137,13 @@ module Kettle
954
1137
  def with_branch_worktrees(root:, branches:)
955
1138
  with_worktree_registry_lock(root: root) do
956
1139
  base = File.join(root, "tmp", "kettle-family-release-state")
957
- FileUtils.mkdir_p(base)
958
1140
  prune_stale_worktrees(root: root)
1141
+ # Snapshot worktrees and working-tree status before creating
1142
+ # tmp/kettle-family-release-state/ so repos without tmp/ in
1143
+ # .gitignore do not report our own inspection worktrees as dirty.
1144
+ @branch_worktree_snapshot = snapshot_git_worktrees(root)
1145
+ @branch_worktree_snapshot&.fetch(:by_branch)&.each_value { |path| git_status_summary(path) }
1146
+ FileUtils.mkdir_p(base)
959
1147
  entries = branches.map do |branch|
960
1148
  {branch: branch, worktree_root: File.join(base, "worktree-#{Process.pid}-#{SecureRandom.hex(8)}")}
961
1149
  end
@@ -966,6 +1154,7 @@ module Kettle
966
1154
  end
967
1155
  yield entries
968
1156
  ensure
1157
+ @branch_worktree_snapshot = nil
969
1158
  entries&.reverse_each do |entry|
970
1159
  remove_branch_worktree(root: root, worktree_root: entry[:worktree_root])
971
1160
  end