@feigi/fleet-ctl 3.79.6 → 3.80.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.
package/package.json
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
|
-
# Release a claim
|
|
3
|
-
#
|
|
4
|
-
#
|
|
2
|
+
# Release a claim: drop the in-progress label, remove the worktree, delete the
|
|
3
|
+
# branch — but only when the claim provably carries no work. The inverse of
|
|
4
|
+
# claim-ticket.sh. Two claim shapes release, told apart by the branch on origin:
|
|
5
5
|
#
|
|
6
|
-
#
|
|
6
|
+
# - Never dispatched: no branch on origin. The branch must carry no commit
|
|
7
|
+
# beyond origin/main and no commit unique to it.
|
|
8
|
+
# - Closed unmerged: the branch is on origin, and every PR of this repository
|
|
9
|
+
# whose head is that branch reads CLOSED — none OPEN, none MERGED, at least
|
|
10
|
+
# one present. The local branch must sit at the tip origin holds. Under
|
|
11
|
+
# --apply origin's tip is read again right before the remote branch is
|
|
12
|
+
# deleted, and that delete runs before the label drops. It is a plain one,
|
|
13
|
+
# not leased on the tip: a push landing between the re-read and the delete
|
|
14
|
+
# goes with the branch. A branch on origin with no PR, or with a PR list that
|
|
15
|
+
# cannot be read, blocks.
|
|
16
|
+
#
|
|
17
|
+
# Dry-run by default; --apply mutates the tracker, the remote and the filesystem.
|
|
7
18
|
#
|
|
8
19
|
# reap.sh will not do this: no merge happened, so no remote branch was ever
|
|
9
20
|
# deleted, so the branch is not [gone] and reap's for-each-ref filter never
|
|
@@ -15,8 +26,10 @@
|
|
|
15
26
|
# Every precondition is recomputed inside THIS invocation rather than trusted
|
|
16
27
|
# from an earlier tool call, for the reason reap.sh gives: the dangerous
|
|
17
28
|
# direction is a worktree that gained work after it was checked. Two of them are
|
|
18
|
-
# recomputed a second time at the moment of the delete,
|
|
19
|
-
#
|
|
29
|
+
# recomputed a second time at the moment of the delete, and in closed mode
|
|
30
|
+
# origin's tip is re-read at the remote delete as well, which is why every
|
|
31
|
+
# delete — the remote one included — runs before the label is dropped rather
|
|
32
|
+
# than after.
|
|
20
33
|
#
|
|
21
34
|
# The dirty check's second opinion is git's own — that is what `worktree remove`
|
|
22
35
|
# without --force is for. It covers the live-directory case ONLY: `worktree
|
|
@@ -27,7 +40,8 @@
|
|
|
27
40
|
#
|
|
28
41
|
# The commit check's is this script's own: the compare-and-swap delete refuses
|
|
29
42
|
# only a ref that moved, so the `ahead` count is re-run against $base right
|
|
30
|
-
# before it
|
|
43
|
+
# before it — in closed mode, a compare of the local tip against the tip origin
|
|
44
|
+
# held instead. Why not `-d`, and what that recount does and does not cover, is
|
|
31
45
|
# argued once at the delete site below — don't restate it here.
|
|
32
46
|
set -eu
|
|
33
47
|
|
|
@@ -854,6 +868,44 @@ if [ -z "$wt" ] && [ -n "$stray" ]; then
|
|
|
854
868
|
fi
|
|
855
869
|
fi
|
|
856
870
|
|
|
871
|
+
# A pushed branch — work that survives the local delete and that a PR may
|
|
872
|
+
# already point at. Live query, so this one cannot be stale; a failure here is
|
|
873
|
+
# an unknown answer, never a "no".
|
|
874
|
+
# stderr stays on stderr, never folded into the value: the emptiness of $remote
|
|
875
|
+
# IS the answer, so an SSH host-key notice on a successful query used to read as
|
|
876
|
+
# a branch that exists. git's own message is more useful on the terminal anyway.
|
|
877
|
+
# 30s: `ls-remote` moves refs and no objects, so this is generous for the work,
|
|
878
|
+
# and it is the budget inflight.sh's own `ls-remote` runs on. `FLEET_NET_TIMEOUT`
|
|
879
|
+
# is the shorten-only override this lookup shares with the fleet's fetches — but
|
|
880
|
+
# NOT with inflight.sh's `ls-remote`, which reads `INFLIGHT_LS_REMOTE_TIMEOUT`
|
|
881
|
+
# and nothing else, so shortening this one does not shorten that one. The rule
|
|
882
|
+
# is net_budget's, in net.sh.
|
|
883
|
+
ls_budget=$(net_budget 30 "${FLEET_NET_TIMEOUT:-}")
|
|
884
|
+
ls_rc=0
|
|
885
|
+
remote=$(net_git "" "$ls_budget" ls-remote --heads origin "refs/heads/$branch") || ls_rc=$?
|
|
886
|
+
if [ "$ls_rc" -ne 0 ]; then
|
|
887
|
+
# A killed lookup and a refused one are different facts and get different
|
|
888
|
+
# words. Both leave the same verdict — the answer is unknown, so nothing is
|
|
889
|
+
# released — but only one of them names a cause this script observed.
|
|
890
|
+
if net_stalled "$ls_rc"; then
|
|
891
|
+
die "git ls-remote did not finish within ${ls_budget}s and was killed, so whether $branch was pushed is unknown"
|
|
892
|
+
fi
|
|
893
|
+
die "git ls-remote failed, so whether $branch was pushed is unknown"
|
|
894
|
+
fi
|
|
895
|
+
|
|
896
|
+
# The tip origin holds, split off ls-remote's `<sha><TAB><ref>` line on the tab
|
|
897
|
+
# itself rather than on a `[:space:]` class, which would put a locale-sensitive
|
|
898
|
+
# construct under the `export LC_ALL=C` paragraph above that says there is none.
|
|
899
|
+
# Whether this pushed branch is the one that releases is a tracker question,
|
|
900
|
+
# asked below once nothing local blocks.
|
|
901
|
+
tab=$(printf '\t')
|
|
902
|
+
remote_sha=
|
|
903
|
+
if [ -n "$remote" ]; then
|
|
904
|
+
remote_sha=${remote%%"$tab"*}
|
|
905
|
+
[ "${remote#*"$tab"}" = "refs/heads/$branch" ] ||
|
|
906
|
+
die "git ls-remote did not answer with refs/heads/$branch for $branch, so whether it was pushed is unknown"
|
|
907
|
+
fi
|
|
908
|
+
|
|
857
909
|
# An Orphaned worktree directory: this claim's directory still on disk with its
|
|
858
910
|
# registration already cleared. `stray` cannot see it BY CONSTRUCTION — it is
|
|
859
911
|
# awk over git's registry, and there is no registration left to match — so the
|
|
@@ -893,7 +945,10 @@ if [ -z "$wt" ] && [ -z "$stray" ]; then
|
|
|
893
945
|
block "worktree directory $orphan is this claim's and has no registration — inspect it and remove the directory by hand"
|
|
894
946
|
elif ! gone "$orphan"; then
|
|
895
947
|
block "cannot tell whether an orphaned worktree directory is at $orphan, so whether #$issue can be released is unknown"
|
|
896
|
-
elif [ "$has_branch" = false ] && [ -z "$blockers" ]; then
|
|
948
|
+
elif [ "$has_branch" = false ] && [ -z "$blockers" ] && [ -z "$remote" ]; then
|
|
949
|
+
# A branch of this name on origin proves the slug right, so the die below
|
|
950
|
+
# does not fire: a closed-PR claim whose local branch is already gone
|
|
951
|
+
# releases from the remote alone.
|
|
897
952
|
# A mistyped <slug>/<type> names a branch that does not exist, and without
|
|
898
953
|
# this die the run would drop the label off a ticket whose real claim is
|
|
899
954
|
# untouched — invisible to candidates.mjs and still in-flight. Refuse
|
|
@@ -927,7 +982,18 @@ if [ -z "$wt" ] && [ -z "$stray" ]; then
|
|
|
927
982
|
fi
|
|
928
983
|
fi
|
|
929
984
|
|
|
930
|
-
|
|
985
|
+
# A closed PR's commits are the branch's whole content, so `ahead` and the `git
|
|
986
|
+
# cherry` count below would refuse every one — and the PR states that tell a
|
|
987
|
+
# closed-PR claim from any other pushed branch are not read until the blockers
|
|
988
|
+
# below are known. So a branch on origin is held to one check here: the local
|
|
989
|
+
# branch must sit at the tip origin holds. Any commit it carries beyond that is
|
|
990
|
+
# unpushed, and the local delete would take it with the branch.
|
|
991
|
+
if [ "$has_branch" = true ] && [ -n "$remote" ]; then
|
|
992
|
+
local_tip=$(git rev-parse --verify "refs/heads/$branch") ||
|
|
993
|
+
die "cannot read $branch's tip, so whether it matches origin's is unknown"
|
|
994
|
+
[ "$local_tip" = "$remote_sha" ] ||
|
|
995
|
+
block "$branch is not at the tip origin holds — unpushed work would be lost"
|
|
996
|
+
elif [ "$has_branch" = true ]; then
|
|
931
997
|
# Commits ahead — a member that did work. Measured on the branch ref rather
|
|
932
998
|
# than the worktree's HEAD: the worktree above was located BY that ref, so the
|
|
933
999
|
# two agree, and this still runs when the worktree is already gone.
|
|
@@ -951,32 +1017,6 @@ if [ "$has_branch" = true ]; then
|
|
|
951
1017
|
[ "$uniq" -eq 0 ] || block "$uniq commit(s) unique to $branch (git cherry)"
|
|
952
1018
|
fi
|
|
953
1019
|
|
|
954
|
-
# A pushed branch — work that survives the local delete and that a PR may
|
|
955
|
-
# already point at. Live query, so this one cannot be stale; a failure here is
|
|
956
|
-
# an unknown answer, never a "no".
|
|
957
|
-
# stderr stays on stderr, never folded into the value: the emptiness of $remote
|
|
958
|
-
# IS the answer, so an SSH host-key notice on a successful query used to read as
|
|
959
|
-
# a branch that exists. git's own message is more useful on the terminal anyway.
|
|
960
|
-
# 30s: `ls-remote` moves refs and no objects, so this is generous for the work,
|
|
961
|
-
# and it is the budget inflight.sh's own `ls-remote` runs on. `FLEET_NET_TIMEOUT`
|
|
962
|
-
# is the shorten-only override this lookup shares with the fleet's fetches — but
|
|
963
|
-
# NOT with inflight.sh's `ls-remote`, which reads `INFLIGHT_LS_REMOTE_TIMEOUT`
|
|
964
|
-
# and nothing else, so shortening this one does not shorten that one. The rule
|
|
965
|
-
# is net_budget's, in net.sh.
|
|
966
|
-
ls_budget=$(net_budget 30 "${FLEET_NET_TIMEOUT:-}")
|
|
967
|
-
ls_rc=0
|
|
968
|
-
remote=$(net_git "" "$ls_budget" ls-remote --heads origin "refs/heads/$branch") || ls_rc=$?
|
|
969
|
-
if [ "$ls_rc" -ne 0 ]; then
|
|
970
|
-
# A killed lookup and a refused one are different facts and get different
|
|
971
|
-
# words. Both leave the same verdict — the answer is unknown, so nothing is
|
|
972
|
-
# released — but only one of them names a cause this script observed.
|
|
973
|
-
if net_stalled "$ls_rc"; then
|
|
974
|
-
die "git ls-remote did not finish within ${ls_budget}s and was killed, so whether $branch was pushed is unknown"
|
|
975
|
-
fi
|
|
976
|
-
die "git ls-remote failed, so whether $branch was pushed is unknown"
|
|
977
|
-
fi
|
|
978
|
-
[ -z "$remote" ] || block "branch $branch exists on origin"
|
|
979
|
-
|
|
980
1020
|
# `-d`, because a directory that is not there holds no uncommitted work. Deleted
|
|
981
1021
|
# by hand, a worktree leaves its admin files registered, so `worktree list
|
|
982
1022
|
# --porcelain` keeps listing the entry and the status below ran against a path
|
|
@@ -1197,10 +1237,52 @@ if [ -n "$wt" ]; then
|
|
|
1197
1237
|
fi
|
|
1198
1238
|
fi
|
|
1199
1239
|
|
|
1200
|
-
#
|
|
1201
|
-
#
|
|
1202
|
-
#
|
|
1203
|
-
#
|
|
1240
|
+
# The one pushed branch that releases: every PR of this repository whose head
|
|
1241
|
+
# is $branch reads CLOSED, and there is at least one. Read live, and failing
|
|
1242
|
+
# closed — a PR list that cannot be read is an unknown answer, as the lookup
|
|
1243
|
+
# above is. Any other pushed branch blocks, as it always did.
|
|
1244
|
+
#
|
|
1245
|
+
# Asked only once every local check has had its say and none blocked, for the
|
|
1246
|
+
# reason the report below gives: a claim already blocked is answered, and a
|
|
1247
|
+
# tracker that cannot be reached must not turn it into an exit 2 with no
|
|
1248
|
+
# receipt. Such a claim names its pushed branch as one more blocker instead,
|
|
1249
|
+
# without the PR states nothing asked for.
|
|
1250
|
+
closed_pr=false
|
|
1251
|
+
pr_seen=
|
|
1252
|
+
if [ -n "$remote" ] && [ -n "$blockers" ]; then
|
|
1253
|
+
block "branch $branch exists on origin"
|
|
1254
|
+
elif [ -n "$remote" ]; then
|
|
1255
|
+
# One `number:state` token per PR, so the loop below needs no JSON parser.
|
|
1256
|
+
# --limit 1000: gh's default page of 30 would hide a later OPEN PR.
|
|
1257
|
+
# `--head` matches a head branch NAME, from any fork, so a fork's PR whose
|
|
1258
|
+
# branch shares this one's name is dropped before it is counted — the filter
|
|
1259
|
+
# delete-merged-branch.sh applies to its own `--head` lookup. Without it, a
|
|
1260
|
+
# fork's closed PR would read as this branch's and release a branch no PR of
|
|
1261
|
+
# ours names.
|
|
1262
|
+
prs=$(gh pr list --state all --head "$branch" --limit 1000 --json number,state,isCrossRepository \
|
|
1263
|
+
--jq '.[] | select(.isCrossRepository | not) | "\(.number):\(.state)"') ||
|
|
1264
|
+
die "gh pr list failed for $branch, so whether its PR closed unmerged is unknown"
|
|
1265
|
+
pr_bad=
|
|
1266
|
+
for pr in $prs; do
|
|
1267
|
+
pr_seen="$pr_seen #${pr%%:*} ${pr#*:};"
|
|
1268
|
+
case ${pr#*:} in
|
|
1269
|
+
CLOSED) ;;
|
|
1270
|
+
*) pr_bad="$pr_bad #${pr%%:*} ${pr#*:};" ;;
|
|
1271
|
+
esac
|
|
1272
|
+
done
|
|
1273
|
+
if [ -z "$pr_seen" ]; then
|
|
1274
|
+
block "branch $branch exists on origin and no PR names it"
|
|
1275
|
+
elif [ -n "$pr_bad" ]; then
|
|
1276
|
+
block "branch $branch exists on origin and its PR(s) are not closed unmerged:$pr_bad"
|
|
1277
|
+
else
|
|
1278
|
+
closed_pr=true
|
|
1279
|
+
fi
|
|
1280
|
+
fi
|
|
1281
|
+
|
|
1282
|
+
# Report the blockers before asking GitHub anything more. The answer cannot
|
|
1283
|
+
# change — every artefact stays put either way — and reaching for the tracker
|
|
1284
|
+
# first turns an offline blocked claim into an unanswerable one, burying the
|
|
1285
|
+
# finding the caller actually needs. "label":null says it was never read.
|
|
1204
1286
|
if [ -n "$blockers" ]; then
|
|
1205
1287
|
echo "$NAME: #$issue NOT released — nothing was touched" >&2
|
|
1206
1288
|
printf '{"issue":%s,"branch":"%s","branchRewritten":%s,"worktree":"%s","worktreeRewritten":%s,"label":null,"released":false,"applied":%s,"blockers":[%s]}\n' \
|
|
@@ -1242,6 +1324,10 @@ if [ "$apply" = false ]; then
|
|
|
1242
1324
|
[ "$has_label" = true ] && echo " would: gh issue edit $issue --remove-label in-progress" >&2
|
|
1243
1325
|
[ -n "$wt" ] && printf ' would: git worktree remove %s\n' "$wt" >&2
|
|
1244
1326
|
[ "$has_branch" = true ] && echo " would: git update-ref -d refs/heads/$branch <its current tip>" >&2
|
|
1327
|
+
if [ "$closed_pr" = true ]; then
|
|
1328
|
+
echo " PR states on $branch:$pr_seen" >&2
|
|
1329
|
+
echo " would: git push origin --delete refs/heads/$branch (origin read at $remote_sha)" >&2
|
|
1330
|
+
fi
|
|
1245
1331
|
else
|
|
1246
1332
|
# Label LAST. The two local deletes are the ones that refuse — that refusal is
|
|
1247
1333
|
# the dirty check recomputed by git at the moment of the delete, so it is
|
|
@@ -1249,7 +1335,10 @@ else
|
|
|
1249
1335
|
# left in-progress already gone: with the worktree still standing the ticket
|
|
1250
1336
|
# read free to candidates.mjs while re-claiming failed on the existing branch.
|
|
1251
1337
|
# Run them first and a refusal leaves the claim exactly as it was, label and
|
|
1252
|
-
# all, which reads as still taken — the direction that costs nothing.
|
|
1338
|
+
# all, which reads as still taken — the direction that costs nothing. Closed
|
|
1339
|
+
# mode's remote delete runs after them, and ahead of the label for the same
|
|
1340
|
+
# reason.
|
|
1341
|
+
|
|
1253
1342
|
if [ -n "$wt" ]; then
|
|
1254
1343
|
# No --force, ever. A refusal is a finding to report, never something to
|
|
1255
1344
|
# force past. Quote git's own reason: this fires precisely when something
|
|
@@ -1294,8 +1383,16 @@ else
|
|
|
1294
1383
|
halt "cannot read $branch's tip at the delete"
|
|
1295
1384
|
n=$(git rev-list --count "$base_rev..$tip") ||
|
|
1296
1385
|
halt "cannot recount commits on $branch against $base at the delete"
|
|
1297
|
-
[ "$
|
|
1298
|
-
|
|
1386
|
+
if [ "$closed_pr" != true ]; then
|
|
1387
|
+
[ "$n" -eq 0 ] ||
|
|
1388
|
+
halt "$branch gained $n commit(s) since the checks — not deleted"
|
|
1389
|
+
else
|
|
1390
|
+
# A closed PR's commits are the whole content of the branch, so the
|
|
1391
|
+
# recount above refuses every one of them. What holds instead: the local
|
|
1392
|
+
# tip has not moved off the tip origin held when the checks read it.
|
|
1393
|
+
[ "$tip" = "$remote_sha" ] ||
|
|
1394
|
+
halt "$branch is no longer at the tip origin holds — not deleted"
|
|
1395
|
+
fi
|
|
1299
1396
|
|
|
1300
1397
|
# What the CAS does not give back: `git update-ref` is ref-only plumbing
|
|
1301
1398
|
# and, unlike `-D`, consults no worktree at all — so the one guard the CAS
|
|
@@ -1371,6 +1468,47 @@ else
|
|
|
1371
1468
|
done_branch=true
|
|
1372
1469
|
fi
|
|
1373
1470
|
|
|
1471
|
+
# Closed mode only: the remote branch goes after the local one and before the
|
|
1472
|
+
# label drops, for the same reason as the local deletes above.
|
|
1473
|
+
#
|
|
1474
|
+
# Origin is read again first, so a push that landed since the checks halts
|
|
1475
|
+
# the release here rather than going with the branch. Here, beside the remote
|
|
1476
|
+
# delete, and not inside the local branch delete: a closed-PR claim whose
|
|
1477
|
+
# local branch is already gone releases from the remote alone, and has no
|
|
1478
|
+
# local delete to hang the re-read on. The delete itself is a plain one: a
|
|
1479
|
+
# push landing in the gap between that re-read and this call is deleted with
|
|
1480
|
+
# the branch. A lease would close that gap, but this file spells no form of
|
|
1481
|
+
# force, so the gap stays.
|
|
1482
|
+
#
|
|
1483
|
+
# A non-zero rc does not say the delete failed to land: the watchdog can kill
|
|
1484
|
+
# the push after origin applied it. So a failed push is followed by a read of
|
|
1485
|
+
# origin, as delete-merged-branch.sh does, and the halt names what origin
|
|
1486
|
+
# holds rather than calling every non-zero rc a refusal. A branch already gone
|
|
1487
|
+
# from origin is the outcome this step exists for, whoever removed it.
|
|
1488
|
+
if [ "$closed_pr" = true ]; then
|
|
1489
|
+
recheck=$(net_git "" "$ls_budget" ls-remote --heads origin "refs/heads/$branch") ||
|
|
1490
|
+
halt "cannot re-read origin's $branch before the delete — not deleted"
|
|
1491
|
+
[ "${recheck%%"$tab"*}" = "$remote_sha" ] ||
|
|
1492
|
+
halt "origin's $branch moved since the checks — not deleted"
|
|
1493
|
+
|
|
1494
|
+
# $ls_budget: a ref-only `push --delete` moves no objects either, so it
|
|
1495
|
+
# shares the lookup's budget, as delete-merged-branch.sh's own push does.
|
|
1496
|
+
echo "\$ git push origin --delete refs/heads/$branch" >&2
|
|
1497
|
+
push_rc=0
|
|
1498
|
+
net_git "" "$ls_budget" push origin --delete "refs/heads/$branch" >&2 || push_rc=$?
|
|
1499
|
+
if [ "$push_rc" -ne 0 ]; then
|
|
1500
|
+
echo "\$ git ls-remote --heads origin refs/heads/$branch" >&2
|
|
1501
|
+
back=$(net_git "" "$ls_budget" ls-remote --heads origin "refs/heads/$branch") ||
|
|
1502
|
+
halt "git push --delete exited $push_rc and origin could not be read back, so whether origin still holds $branch is unknown"
|
|
1503
|
+
if [ -n "$back" ] && net_stalled "$push_rc"; then
|
|
1504
|
+
halt "git push --delete did not finish within ${ls_budget}s and was killed — origin still holds $branch"
|
|
1505
|
+
elif [ -n "$back" ]; then
|
|
1506
|
+
halt "git push --delete refused $branch on origin (rc $push_rc) — origin still holds it"
|
|
1507
|
+
fi
|
|
1508
|
+
fi
|
|
1509
|
+
done_branch=true
|
|
1510
|
+
fi
|
|
1511
|
+
|
|
1374
1512
|
if [ "$has_label" = true ]; then
|
|
1375
1513
|
echo "\$ gh issue edit $issue --remove-label in-progress" >&2
|
|
1376
1514
|
gh issue edit "$issue" --remove-label in-progress >/dev/null ||
|
|
@@ -58,10 +58,12 @@ So nothing in the run cleans it up. Next run, the in-flight probe's local-worktr
|
|
|
58
58
|
|
|
59
59
|
- **`ahead` + dirty catch a member that did work.** `ahead` against `origin/main`. Not redundant with `git cherry`: commit already cherry-picked upstream is upstream-equivalent (`-` line, not `+`), and only `ahead` still sees it. Pinned by a test.
|
|
60
60
|
- **`git cherry` catches commits that exist only locally.** Against `origin/main`, never a local main — same trap reap has.
|
|
61
|
-
- **Remote check catches a pushed branch.** Live `git ls-remote`, so it cannot be stale. Its failure is an unknown answer, never a "not pushed" — swallow it and a release deletes the local copy of work already on the server.
|
|
61
|
+
- **Remote check catches a pushed branch.** Live `git ls-remote`, so it cannot be stale. Its failure is an unknown answer, never a "not pushed" — swallow it and a release deletes the local copy of work already on the server. A pushed branch blocks unless it is the closed-unmerged shape below.
|
|
62
62
|
- **Label read first, `gh` failure fatal.** Worktree and branch gone with `in-progress` left behind hides the ticket from `candidates.mjs` entirely — worse than not releasing. All three artefacts or none.
|
|
63
63
|
|
|
64
|
-
**
|
|
64
|
+
**One pushed branch releases: a claim whose PR closed unmerged.** Every PR of this repository whose head is the branch reads CLOSED — none OPEN, none MERGED, at least one present. Read with `gh pr list` only once no local check blocks, so a blocked claim still reports without asking GitHub; a list that cannot be read, or names no PR, blocks. `ahead` and `git cherry` do not apply — a closed PR's commits are the branch's whole content — so the local branch must sit at the tip origin holds instead, re-checked at the local delete. The remote branch is a fourth artefact: `--apply` deletes it after the local deletes and before the label drops, re-reading origin's tip first and halting if it moved. A plain delete, not leased on that tip, so a push landing between the re-read and the delete goes with the branch. A delete whose `git push` fails is read back from origin: gone counts as done.
|
|
65
|
+
|
|
66
|
+
**The delete is `git update-ref -d`'s compare-and-swap here too, and for reap's reason** — authorized by the `ahead` and `git cherry` checks above, plus the `ahead` recount re-run against `origin/main` immediately before the delete itself (a commit can land across the `gh issue view` between the checks and the delete; `git cherry` is not re-run, because such a commit is ahead of `origin/main` by construction), plus a fresh check, re-read immediately before the delete, that no worktree holds the branch (`update-ref` consults no worktree, where `-D` refused a held branch; a worktree it cannot resolve, or a listing that will not re-read, stops the delete too), and by nothing else. In the closed-unmerged shape the tip-at-origin check and its re-check at the delete stand in for `ahead`, `git cherry` and the recount; the worktree check stays. A claim used to carry `origin/main` as its upstream, so `-d` compared against *that* and forgave a behind local main; now `claim-ticket.sh` passes `--no-track` (so `@{u}` cannot silently answer about main), a claim has no upstream until its first `push -u`, and `-d` falls back to comparing against local `HEAD`. Measured: with local `main` behind `origin/main`, `-d` refuses a pristine claim — half-releasing it, worktree deleted and branch stranded with `in-progress` still on the ticket. The two checks above are strictly stronger than what `-d` would have asked, and both measure against `origin/main` rather than a local ref.
|
|
65
67
|
|
|
66
68
|
**A checkout that lands between that fresh check and the delete halts the release after it.** `git worktree add` of an existing branch does not move the ref, so the compare-and-swap succeeds under it. The same `wt_recheck_delete` reap uses then finds the worktree, recreates the branch at the tip, and the release halts with exit 2, `released:false` and a blocker naming that worktree — the shape of a holder caught before the delete. A restore that fails halts the same way, with the tip and the repair command in the blocker.
|
|
67
69
|
|