carson 3.21.0 → 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/LICENSE +91 -21
- data/RELEASE.md +21 -0
- data/VERSION +1 -1
- data/carson.gemspec +1 -1
- data/hooks/command-guard +3 -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 +2 -2
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/LICENSE
CHANGED
|
@@ -1,21 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# PolyForm Shield License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
4
|
+
|
|
5
|
+
Required Notice: Copyright (c) 2026 Hailei Wang (WHL) <wanghailei@gmail.com>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to Distribution License and make changes or new works based on the software according to Changes and New Works License.
|
|
14
|
+
|
|
15
|
+
## Distribution License
|
|
16
|
+
|
|
17
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by Changes and New Works License.
|
|
18
|
+
|
|
19
|
+
## Notices
|
|
20
|
+
|
|
21
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
22
|
+
|
|
23
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
24
|
+
|
|
25
|
+
## Changes and New Works License
|
|
26
|
+
|
|
27
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
28
|
+
|
|
29
|
+
## Patent License
|
|
30
|
+
|
|
31
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
32
|
+
|
|
33
|
+
## Noncompete
|
|
34
|
+
|
|
35
|
+
Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
|
|
36
|
+
|
|
37
|
+
## Competition
|
|
38
|
+
|
|
39
|
+
Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
|
|
40
|
+
|
|
41
|
+
## New Products
|
|
42
|
+
|
|
43
|
+
If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
|
|
44
|
+
|
|
45
|
+
## Discontinued Products
|
|
46
|
+
|
|
47
|
+
You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
|
|
48
|
+
|
|
49
|
+
> Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
|
|
50
|
+
|
|
51
|
+
## Sales of Business
|
|
52
|
+
|
|
53
|
+
If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce Noncompete for that product.
|
|
54
|
+
|
|
55
|
+
## Fair Use
|
|
56
|
+
|
|
57
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
58
|
+
|
|
59
|
+
## No Other Rights
|
|
60
|
+
|
|
61
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
62
|
+
|
|
63
|
+
## Patent Defense
|
|
64
|
+
|
|
65
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
66
|
+
|
|
67
|
+
## Violations
|
|
68
|
+
|
|
69
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
70
|
+
|
|
71
|
+
## No Liability
|
|
72
|
+
|
|
73
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
78
|
+
|
|
79
|
+
A **product** can be a good or service, or a combination of them.
|
|
80
|
+
|
|
81
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
|
|
84
|
+
|
|
85
|
+
**Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
|
|
86
|
+
|
|
87
|
+
**Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
88
|
+
|
|
89
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
90
|
+
|
|
91
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
data/RELEASE.md
CHANGED
|
@@ -5,6 +5,27 @@ 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
|
+
|
|
23
|
+
## 3.21.1
|
|
24
|
+
|
|
25
|
+
### What changed
|
|
26
|
+
|
|
27
|
+
- **Command guard false-positive fix** — the `command-guard` regex now matches `gh pr create/merge` only at command position (start of line or after `&&`, `||`, `;`, `|`). Previously it matched inside string arguments, blocking legitimate commands like `git commit -m 'Document gh pr create hook'`.
|
|
28
|
+
|
|
8
29
|
## 3.21.0
|
|
9
30
|
|
|
10
31
|
### What changed
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.22.0
|
data/carson.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.summary = "Autonomous repository governance — you write the code, Carson manages everything else."
|
|
11
11
|
spec.description = "Carson is a governance runtime that lives outside the repositories it governs — no Carson-owned artefacts in your repo. On every commit, managed hooks enforce centralised lint policy and review gates. At portfolio level, carson govern triages every open PR across your registered repositories: merge what's ready, dispatch coding agents to fix what's failing, escalate what needs human judgement. One command, all your projects, unmanned."
|
|
12
12
|
spec.homepage = "https://github.com/wanghailei/carson"
|
|
13
|
-
spec.license = "
|
|
13
|
+
spec.license = "PolyForm-Shield-1.0.0"
|
|
14
14
|
spec.required_ruby_version = ">= 3.4"
|
|
15
15
|
spec.metadata = {
|
|
16
16
|
"source_code_uri" => "https://github.com/wanghailei/carson",
|
data/hooks/command-guard
CHANGED
|
@@ -33,7 +33,9 @@ command_text="$(echo "$input" | jq -r '.tool_input.command // empty' 2>/dev/null
|
|
|
33
33
|
[ -n "$command_text" ] || exit 0
|
|
34
34
|
|
|
35
35
|
# Check for gh pr commands that Carson replaces.
|
|
36
|
-
|
|
36
|
+
# Match only at command position: start of line, or after a shell operator (&&, ||, ;, |).
|
|
37
|
+
# This avoids false positives from gh pr references inside commit messages or string arguments.
|
|
38
|
+
guarded_pattern='(^|&&|\|\||;|\|)\s*gh\s+pr\s+(create|merge)'
|
|
37
39
|
if ! echo "$command_text" | grep -qE "$guarded_pattern"; then
|
|
38
40
|
exit 0
|
|
39
41
|
fi
|
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 }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: carson
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.22.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hailei Wang
|
|
@@ -80,7 +80,7 @@ files:
|
|
|
80
80
|
- templates/.github/pull_request_template.md
|
|
81
81
|
homepage: https://github.com/wanghailei/carson
|
|
82
82
|
licenses:
|
|
83
|
-
-
|
|
83
|
+
- PolyForm-Shield-1.0.0
|
|
84
84
|
metadata:
|
|
85
85
|
source_code_uri: https://github.com/wanghailei/carson
|
|
86
86
|
changelog_uri: https://github.com/wanghailei/carson/blob/main/RELEASE.md
|