carson 3.21.1 → 3.22.0
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/RELEASE.md +15 -0
- data/VERSION +1 -1
- data/lib/carson/cli.rb +23 -0
- data/lib/carson/config.rb +9 -3
- data/lib/carson/runtime/audit.rb +5 -6
- data/lib/carson/runtime/deliver.rb +5 -9
- data/lib/carson/runtime/local/prune.rb +15 -4
- data/lib/carson/runtime/local/worktree.rb +1 -1
- data/lib/carson/runtime/status.rb +1 -1
- data/lib/carson/runtime.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e75b6729cf0c977beb1ace5da390f41ae20d80208d7470c97b145b76e44cb3ad
|
|
4
|
+
data.tar.gz: 24d85c37e66498731b9d980b39017a4d73c06c93acd1dd8018e74b33e951d4df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df4ff4c103415e7ff448ee5c8d7bbd60b4259afa15f522d840519b420e0202dc8cb7e86af7d27df0174c8df963eb57cf13fd578678e3c960b669f94e81089d6b
|
|
7
|
+
data.tar.gz: fcc758b8416931f303dbd72bcabac9f703b844c79b1dd37eec4572b43abe455bca81ca0f8f9871c09a2ee27f086f70c3e977b78b5c078d6820d8f8d770fb74c2
|
data/RELEASE.md
CHANGED
|
@@ -5,6 +5,21 @@ Release-note scope rule:
|
|
|
5
5
|
- `RELEASE.md` records only version deltas, breaking changes, and migration actions.
|
|
6
6
|
- Operational usage guides live in `MANUAL.md` and `API.md`.
|
|
7
7
|
|
|
8
|
+
## 3.22.0
|
|
9
|
+
|
|
10
|
+
### What changed
|
|
11
|
+
|
|
12
|
+
- **Command-guard auto-install at CLI startup** — Carson now installs the command-guard hook automatically when any CLI command runs, removing the need for a manual `carson refresh` after install. The guard is installed once and skipped on subsequent invocations.
|
|
13
|
+
- **Stale worktree sweep before portfolio safety check** — `refresh --all` now sweeps stale worktrees before checking repo safety, preventing false "active worktree" skips for worktrees whose branches have already been merged.
|
|
14
|
+
- **Nested config path fix for merge method** — `govern.merge.method` is now read from the correct nested config path instead of the top-level key, fixing repos where the merge method setting was silently ignored.
|
|
15
|
+
- **Deliver proceeds when no CI checks configured** — `deliver --merge` no longer blocks on repos with no CI checks. Previously it waited indefinitely for checks that would never arrive.
|
|
16
|
+
- **Rebase-merge orphan branch pruning** — `prune` now detects branches absorbed into main via rebase merge (tip commit reachable from main) and cleans them up, not just squash-merged branches.
|
|
17
|
+
- **Pluralisation fix** — corrected "branchs" → "branches" in prune and status output.
|
|
18
|
+
|
|
19
|
+
### UX improvement
|
|
20
|
+
|
|
21
|
+
- Carson is now fully self-configuring: installing the gem and running any command sets up all safety guards automatically. Batch operations on portfolios no longer false-skip repos with stale worktrees. Repos using rebase merge keep their branch list clean without manual intervention.
|
|
22
|
+
|
|
8
23
|
## 3.21.1
|
|
9
24
|
|
|
10
25
|
### What changed
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.22.0
|
data/lib/carson/cli.rb
CHANGED
|
@@ -4,6 +4,8 @@ require "optparse"
|
|
|
4
4
|
module Carson
|
|
5
5
|
class CLI
|
|
6
6
|
def self.start( arguments:, repo_root:, tool_root:, output:, error: )
|
|
7
|
+
ensure_global_artefacts!( tool_root: tool_root )
|
|
8
|
+
|
|
7
9
|
parsed = parse_args( arguments: arguments, output: output, error: error )
|
|
8
10
|
command = parsed.fetch( :command )
|
|
9
11
|
return Runtime::EXIT_OK if command == :help
|
|
@@ -685,6 +687,27 @@ module Carson
|
|
|
685
687
|
{ command: :invalid }
|
|
686
688
|
end
|
|
687
689
|
|
|
690
|
+
# --- global artefacts ---
|
|
691
|
+
|
|
692
|
+
# Ensures global (non-repo) artefacts are installed at CLI startup.
|
|
693
|
+
# The command-guard lives at a stable path (~/.carson/hooks/command-guard)
|
|
694
|
+
# referenced by Claude Code's PreToolUse hook. It must exist regardless of
|
|
695
|
+
# whether `carson refresh` has been run in any governed repo.
|
|
696
|
+
def self.ensure_global_artefacts!( tool_root: )
|
|
697
|
+
source = File.join( tool_root, "hooks", "command-guard" )
|
|
698
|
+
return unless File.file?( source )
|
|
699
|
+
|
|
700
|
+
hooks_base = File.expand_path( "~/.carson/hooks" )
|
|
701
|
+
target = File.join( hooks_base, "command-guard" )
|
|
702
|
+
return if File.file?( target ) && FileUtils.identical?( source, target )
|
|
703
|
+
|
|
704
|
+
FileUtils.mkdir_p( hooks_base )
|
|
705
|
+
FileUtils.cp( source, target )
|
|
706
|
+
FileUtils.chmod( 0o755, target )
|
|
707
|
+
rescue StandardError
|
|
708
|
+
# Best-effort — do not block any command if this fails.
|
|
709
|
+
end
|
|
710
|
+
|
|
688
711
|
# --- dispatch ---
|
|
689
712
|
|
|
690
713
|
def self.dispatch( parsed:, runtime: )
|
data/lib/carson/config.rb
CHANGED
|
@@ -66,7 +66,9 @@ module Carson
|
|
|
66
66
|
"govern" => {
|
|
67
67
|
"repos" => [],
|
|
68
68
|
"auto_merge" => true,
|
|
69
|
-
"
|
|
69
|
+
"merge" => {
|
|
70
|
+
"method" => "squash"
|
|
71
|
+
},
|
|
70
72
|
"agent" => {
|
|
71
73
|
"provider" => "auto",
|
|
72
74
|
"codex" => {},
|
|
@@ -154,7 +156,10 @@ module Carson
|
|
|
154
156
|
govern_auto_merge = ENV.fetch( "CARSON_GOVERN_AUTO_MERGE", "" ).to_s.strip
|
|
155
157
|
govern[ "auto_merge" ] = ( govern_auto_merge == "true" ) unless govern_auto_merge.empty?
|
|
156
158
|
govern_method = ENV.fetch( "CARSON_GOVERN_MERGE_METHOD", "" ).to_s.strip
|
|
157
|
-
|
|
159
|
+
unless govern_method.empty?
|
|
160
|
+
govern[ "merge" ] ||= {}
|
|
161
|
+
govern[ "merge" ][ "method" ] = govern_method
|
|
162
|
+
end
|
|
158
163
|
agent = fetch_hash_section( data: govern, key: "agent" )
|
|
159
164
|
govern_provider = ENV.fetch( "CARSON_GOVERN_AGENT_PROVIDER", "" ).to_s.strip
|
|
160
165
|
agent[ "provider" ] = govern_provider unless govern_provider.empty?
|
|
@@ -215,7 +220,8 @@ module Carson
|
|
|
215
220
|
govern_hash = fetch_hash( hash: data, key: "govern" )
|
|
216
221
|
@govern_repos = fetch_optional_string_array( hash: govern_hash, key: "repos" ).map { |path| safe_expand_path( path ) }
|
|
217
222
|
@govern_auto_merge = fetch_optional_boolean( hash: govern_hash, key: "auto_merge", default: true, key_path: "govern.auto_merge" )
|
|
218
|
-
|
|
223
|
+
govern_merge_hash = fetch_hash( hash: govern_hash, key: "merge" )
|
|
224
|
+
@govern_merge_method = fetch_string( hash: govern_merge_hash, key: "method" ).downcase
|
|
219
225
|
govern_agent_hash = fetch_hash( hash: govern_hash, key: "agent" )
|
|
220
226
|
@govern_agent_provider = fetch_string( hash: govern_agent_hash, key: "provider" ).downcase
|
|
221
227
|
dispatch_path = govern_hash.fetch( "dispatch_state_path" ).to_s
|
data/lib/carson/runtime/audit.rb
CHANGED
|
@@ -115,12 +115,12 @@ module Carson
|
|
|
115
115
|
puts_verbose "[Canonical Templates]"
|
|
116
116
|
puts_verbose "HINT: canonical templates not configured — run carson setup to enable."
|
|
117
117
|
end
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
118
|
+
write_and_print_pr_monitor_report(
|
|
119
|
+
report: monitor_report.merge(
|
|
120
|
+
default_branch_baseline: default_branch_baseline,
|
|
121
|
+
audit_status: audit_state
|
|
123
122
|
)
|
|
123
|
+
)
|
|
124
124
|
exit_code = audit_state == "block" ? EXIT_BLOCK : EXIT_OK
|
|
125
125
|
|
|
126
126
|
if json_output
|
|
@@ -581,7 +581,6 @@ module Carson
|
|
|
581
581
|
lines.join( "\n" )
|
|
582
582
|
end
|
|
583
583
|
|
|
584
|
-
# True when there are no staged/unstaged/untracked file changes.
|
|
585
584
|
end
|
|
586
585
|
|
|
587
586
|
include Audit
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# PR delivery lifecycle — push, create PR, and optionally merge.
|
|
2
2
|
# Collapses the 8-step manual PR flow into one or two commands.
|
|
3
3
|
# `carson deliver` pushes and creates the PR.
|
|
4
|
-
# `carson deliver --merge` also merges if CI
|
|
4
|
+
# `carson deliver --merge` also merges if CI passes or no checks are configured.
|
|
5
5
|
# `carson deliver --json` outputs structured result for agent consumption.
|
|
6
6
|
module Carson
|
|
7
7
|
class Runtime
|
|
@@ -46,17 +46,14 @@ module Carson
|
|
|
46
46
|
result[ :ci ] = ci_status.to_s
|
|
47
47
|
|
|
48
48
|
case ci_status
|
|
49
|
-
when :pass
|
|
50
|
-
# Continue to review gate.
|
|
49
|
+
when :pass, :none
|
|
50
|
+
# Continue to review gate. :none means no checks configured — nothing to wait for.
|
|
51
51
|
when :pending
|
|
52
52
|
result[ :recovery ] = "gh pr checks #{pr_number} --watch && carson deliver --merge"
|
|
53
53
|
return deliver_finish( result: result, exit_code: EXIT_OK, json_output: json_output )
|
|
54
54
|
when :fail
|
|
55
55
|
result[ :recovery ] = "gh pr checks #{pr_number} — fix failures, push, then `carson deliver --merge`"
|
|
56
56
|
return deliver_finish( result: result, exit_code: EXIT_BLOCK, json_output: json_output )
|
|
57
|
-
else
|
|
58
|
-
result[ :recovery ] = "gh pr checks #{pr_number}"
|
|
59
|
-
return deliver_finish( result: result, exit_code: EXIT_OK, json_output: json_output )
|
|
60
57
|
end
|
|
61
58
|
|
|
62
59
|
# Step 4: check review gate — block if changes are requested.
|
|
@@ -117,15 +114,14 @@ module Carson
|
|
|
117
114
|
case ci
|
|
118
115
|
when "pass"
|
|
119
116
|
puts_line "CI: pass"
|
|
117
|
+
when "none"
|
|
118
|
+
puts_line "CI: none — no checks configured, proceeding."
|
|
120
119
|
when "pending"
|
|
121
120
|
puts_line "CI: pending — merge when checks complete."
|
|
122
121
|
puts_line " Recovery: #{result[ :recovery ]}" if result[ :recovery ]
|
|
123
122
|
when "fail"
|
|
124
123
|
puts_line "CI: failing — fix before merging."
|
|
125
124
|
puts_line " Recovery: #{result[ :recovery ]}" if result[ :recovery ]
|
|
126
|
-
else
|
|
127
|
-
puts_line "CI: #{ci} — check manually."
|
|
128
|
-
puts_line " Recovery: #{result[ :recovery ]}" if result[ :recovery ]
|
|
129
125
|
end
|
|
130
126
|
end
|
|
131
127
|
|
|
@@ -78,9 +78,9 @@ module Carson
|
|
|
78
78
|
message = if deleted_count > 0 && skipped_count > 0
|
|
79
79
|
"Pruned #{deleted_count}, skipped #{skipped_count} (--verbose for details)."
|
|
80
80
|
elsif deleted_count > 0
|
|
81
|
-
"Pruned #{deleted_count} stale
|
|
81
|
+
"Pruned #{deleted_count} stale #{ deleted_count == 1 ? 'branch' : 'branches' }."
|
|
82
82
|
else
|
|
83
|
-
"Skipped #{skipped_count}
|
|
83
|
+
"Skipped #{skipped_count} #{ skipped_count == 1 ? 'branch' : 'branches' } (--verbose for details)."
|
|
84
84
|
end
|
|
85
85
|
puts_line message
|
|
86
86
|
end
|
|
@@ -347,7 +347,7 @@ module Carson
|
|
|
347
347
|
counters
|
|
348
348
|
end
|
|
349
349
|
|
|
350
|
-
# Checks a single orphan branch for merged PR evidence
|
|
350
|
+
# Checks a single orphan branch for merged PR evidence or absorbed content, then force-deletes if confirmed.
|
|
351
351
|
def prune_orphan_branch_entry( branch: )
|
|
352
352
|
tip_sha_text, tip_sha_error, tip_sha_success, = git_run( "rev-parse", "--verify", branch.to_s )
|
|
353
353
|
unless tip_sha_success
|
|
@@ -363,6 +363,17 @@ module Carson
|
|
|
363
363
|
end
|
|
364
364
|
|
|
365
365
|
merged_pr, error = merged_pr_for_branch( branch: branch, branch_tip_sha: branch_tip_sha )
|
|
366
|
+
|
|
367
|
+
# Fallback: branch content is already on main (rebase merges rewrite SHAs).
|
|
368
|
+
if merged_pr.nil? && branch_absorbed_into_main?( branch: branch )
|
|
369
|
+
merged_pr = {
|
|
370
|
+
number: nil,
|
|
371
|
+
url: "absorbed into #{config.main_branch}",
|
|
372
|
+
merged_at: Time.now.utc.iso8601,
|
|
373
|
+
head_sha: branch_tip_sha
|
|
374
|
+
}
|
|
375
|
+
end
|
|
376
|
+
|
|
366
377
|
if merged_pr.nil?
|
|
367
378
|
reason = error.to_s.strip
|
|
368
379
|
reason = "no merged PR evidence for branch tip into #{config.main_branch}" if reason.empty?
|
|
@@ -374,7 +385,7 @@ module Carson
|
|
|
374
385
|
if force_success
|
|
375
386
|
output.print force_stdout if verbose? && !force_stdout.empty?
|
|
376
387
|
puts_verbose "deleted_orphan_branch: #{branch} merged_pr=#{merged_pr.fetch( :url )}"
|
|
377
|
-
return { action: :deleted, branch: branch, upstream: "", type: "orphan", reason: "
|
|
388
|
+
return { action: :deleted, branch: branch, upstream: "", type: "orphan", reason: "content absorbed into #{config.main_branch}" }
|
|
378
389
|
end
|
|
379
390
|
|
|
380
391
|
force_error_text = normalise_branch_delete_error( error_text: force_stderr )
|
|
@@ -362,7 +362,7 @@ module Carson
|
|
|
362
362
|
# Content-aware check: after squash/rebase merge, commit SHAs differ
|
|
363
363
|
# but the tree content may be identical to main. Compare content,
|
|
364
364
|
# not SHAs — if the diff is empty, the work is already on main.
|
|
365
|
-
|
|
365
|
+
_, _, diff_ok, = Open3.capture3( "git", "diff", "--quiet", config.main_branch, branch, chdir: worktree_path )
|
|
366
366
|
unless diff_ok.success?
|
|
367
367
|
return { error: "branch has not been pushed to #{remote}",
|
|
368
368
|
recovery: "git -C #{worktree_path} push -u #{remote} #{branch}, or use --force to override" }
|
|
@@ -276,7 +276,7 @@ module Carson
|
|
|
276
276
|
if stale && stale.fetch( :count ) > 0
|
|
277
277
|
count = stale.fetch( :count )
|
|
278
278
|
puts_line ""
|
|
279
|
-
puts_line "#{count} stale
|
|
279
|
+
puts_line "#{count} stale #{ count == 1 ? 'branch' : 'branches' } ready for pruning."
|
|
280
280
|
end
|
|
281
281
|
|
|
282
282
|
# Governance
|
data/lib/carson/runtime.rb
CHANGED
|
@@ -306,8 +306,10 @@ module Carson
|
|
|
306
306
|
|
|
307
307
|
reasons = []
|
|
308
308
|
|
|
309
|
-
#
|
|
309
|
+
# Sweep stale worktrees (merged branches) before counting active ones
|
|
310
|
+
# so only genuinely active worktrees block the operation.
|
|
310
311
|
scoped_runtime = build_scoped_runtime( repo_path: repo_path )
|
|
312
|
+
scoped_runtime.sweep_stale_worktrees!
|
|
311
313
|
worktrees = scoped_runtime.send( :worktree_list )
|
|
312
314
|
main_root = scoped_runtime.send( :realpath_safe, repo_path )
|
|
313
315
|
active = worktrees.reject { |worktree| worktree.fetch( :path ) == main_root }
|