ace-git-worktree 0.24.0 → 0.24.1

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: 440da5b336b58817b1e6bbc1b8d57de396e78848b9e9c289d1492ca85fc7065a
4
- data.tar.gz: 432c570346044a2351c72355b729501cef4723507fb64f0298307f7790edf289
3
+ metadata.gz: 9cc5a752911b79c40cf895ba0431dbde985c56c96fe628af54d7cb675a65933a
4
+ data.tar.gz: e0cd68c94bc6b67e400df61262538edee3c9dfd045cbff28e783b4f9a454b67b
5
5
  SHA512:
6
- metadata.gz: c4c1f7d225354653e5d6d4c3ff8e88c0c8b4cee1142707e5d51181569b961b58e81fd1f64bca355a78a6675205429654420ed9776481470204342f70e7bfc9a5
7
- data.tar.gz: 46e6f7112657db3d867a69db98dacbe429883672beb37b83fa35bda5b059d071a8a318fe5d26adc90835da05a3b4f74d105b096244be92beb61a904007652358
6
+ metadata.gz: 377f121307f98729bc20a0f62be300ad1a9fe62ecc7434edbb976b49fec7a0c2d29853e525a70054514b0cb3524e5fa67242674d3ab649e26f636f361439e4df
7
+ data.tar.gz: 11783401d8ff7fa04a37b00611cd438e25bfcb936bc30064f6091b19c84a5e2a0257c90c12a7af64ae63dd41b818ece145a992234bef4a282a04c006260551f4
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.24.1] - 2026-09-29
11
+
12
+ ### Fixed
13
+ - Cleanup merge proof requires PR evidence provenance (server, repository,
14
+ branch, base) to agree with the resolved selection; incomplete or
15
+ conflicting provenance retains the candidate, so identical branch/PR
16
+ numbers in different repositories can never cross-prove removal.
17
+ - Cleanup targets resolve to the PR base branch across ref forms:
18
+ bare ("main"), remote-prefixed ("origin/main"), and fully qualified
19
+ ("refs/heads/main", "refs/remotes/origin/main").
20
+
10
21
  ## [0.24.0] - 2026-09-28
11
22
 
12
23
  ### Added
@@ -14,8 +14,11 @@ module Ace
14
14
  # Only confirmed remote merge evidence (:merged) can prove removal;
15
15
  # object states (:no_pr, :open, :closed_unmerged) and transport
16
16
  # failures (:offline, :authentication_error, :malformed) always
17
- # retain the candidate. Local ancestry proof is handled by the
18
- # reporter before this resolver is consulted.
17
+ # retain the candidate. Merge proof additionally requires the
18
+ # evidence's provenance (server, repository, branch, base) to agree
19
+ # with the resolved selection; incomplete or conflicting provenance
20
+ # retains. Local ancestry proof is handled by the reporter before
21
+ # this resolver is consulted.
19
22
  class CleanupPrResolver
20
23
  # @param target [String] base ref the PR must have targeted
21
24
  # @param target_sha [String] commit SHA of the target
@@ -57,7 +60,10 @@ module Ace
57
60
  return unproven_result(:no_pr) unless evidence
58
61
  return unproven_result(:open) if evidence.state == :open
59
62
  return unproven_result(:closed_unmerged) if evidence.state == :closed
60
- return unproven_result(:no_pr, "state_unavailable") unless evidence.state == :merged
63
+ return unproven_result(:merged, "state_unavailable") unless evidence.state == :merged
64
+
65
+ problem = provenance_problem(evidence, branch)
66
+ return unproven_result(:merged, problem) if problem
61
67
  return unproven_result(:merged, "merge_commit_unavailable") unless evidence.merge_commit_sha
62
68
  return unproven_result(:merged, "merge_commit_unreachable") unless ancestor?(evidence.merge_commit_sha, @target_sha)
63
69
 
@@ -118,6 +124,53 @@ module Ace
118
124
  end
119
125
  end
120
126
 
127
+ # Merge proof may only remove a candidate whose evidence provably
128
+ # belongs to the resolved server and the candidate's branch/base.
129
+ # PR and branch identities are not globally unique: incomplete
130
+ # provenance cannot be verified and conflicting provenance means
131
+ # the evidence was routed from another repository — both retain.
132
+ # @return [String, nil] retention reason, or nil when provenance agrees
133
+ def provenance_problem(evidence, branch)
134
+ server = resolved_server
135
+ unless server && evidence.server_name && evidence.base_repository_url &&
136
+ evidence.head_ref && evidence.base_ref
137
+ return "provenance_incomplete"
138
+ end
139
+
140
+ return "provenance_conflict" unless evidence.server_name == server.name
141
+ return "provenance_conflict" unless Ace::Git::Atoms::ServerUrl.match?(evidence.base_repository_url, server.url)
142
+ return "provenance_conflict" unless evidence.head_ref == branch
143
+ return "provenance_conflict" unless evidence.base_ref == target_branch
144
+
145
+ nil
146
+ end
147
+
148
+ # The branch the PR must have targeted. Targets arrive as bare
149
+ # branch names, remote-tracking refs ("origin/main",
150
+ # "refs/remotes/origin/main"), or local refs ("refs/heads/main");
151
+ # all of those forms name the same branch the PR base reports. A
152
+ # path segment only counts as a remote prefix when it names a
153
+ # configured git remote, so slashed branch names stay strict.
154
+ def target_branch
155
+ ref = @target.to_s
156
+ ref = ref.sub(%r{\Arefs/remotes/([^/]+)/}) do
157
+ git_remotes.include?(Regexp.last_match(1)) ? "" : Regexp.last_match(0)
158
+ end
159
+ ref = ref.sub(%r{\Arefs/heads/}, "")
160
+ if ref.include?("/")
161
+ prefix, rest = ref.split("/", 2)
162
+ ref = rest if git_remotes.include?(prefix)
163
+ end
164
+ ref
165
+ end
166
+
167
+ def git_remotes
168
+ out, _status = Open3.capture2("git", "remote")
169
+ out.to_s.lines.map(&:strip).reject(&:empty?)
170
+ rescue StandardError
171
+ []
172
+ end
173
+
121
174
  def proof_result(evidence, proof, candidate_sha, pr_head_sha, merge_commit_sha)
122
175
  {
123
176
  status: :merged,
@@ -3,7 +3,7 @@
3
3
  module Ace
4
4
  module Git
5
5
  module Worktree
6
- VERSION = "0.24.0"
6
+ VERSION = "0.24.1"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ace-git-worktree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Czyz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-09-29 00:00:00.000000000 Z
10
+ date: 2026-10-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ace-support-cli