Skip to content

git plonk misses df12-build roadmap branches and squash-merged issue branches #52

Description

@leynos

Context

A cleanup sweep across 21 repositories on a df12 development host ran
git plonk --dry-run in every main repository that has a *.worktrees
sibling. It reported "No matching git donkey worktrees found" in all 21,
while a manual sweep immediately afterwards found and removed 43
worktrees that were clean and either had a merged pull request or had been
idle for more than seven days. git plonk is therefore not being overly
cautious within its rules — its recognition rules never fire against the
branch names in real use.

Shortcoming 1: the roadmap pattern requires a trailing suffix

plonk_policy._ROADMAP_BRANCH_PATTERN is:

re.compile(r"^(?:(\w+)-)?(\d+)-(\d+)-(\d+)(\w+)?-(?:(\d+)-)?")

The pattern only matches when the dotted id is followed by another -
segment, so it recognizes 2-2-1-description but not a bare task id.
leynos/df12-build names its task branches with no descriptive
suffix
, per its own recognizer
(src/workflows/df12-build-odw/recovery-decision.ts):

export const TASK_BRANCH_RE = /^roadmap-((?:\d+-)*\d+)(-addendum)?$/

Real examples that plonk missed despite merged PRs whose squash titles
carried the (2.2.1)-style marker: roadmap-2-2-1 and roadmap-6-4-1
in leynos/stilyagi (PRs #54 and #55, both merged).

Suggested fixes:

  • make the trailing separator optional, and accept variable-depth dotted
    ids (df12 roadmap ids run from N.N to N.N.N.N), rather than exactly
    three numeric segments; and
  • recognize the df12-build shapes explicitly: roadmap-<id-with-dashes>
    and roadmap-<id-with-dashes>-addendum (the addendum form completes
    when the parent task and every addendum sub-task are ticked, so its
    marker is the same dotted id).

Shortcoming 2: issue branches key on the issue number, but squash merges carry the PR number

For issue-62-polymer-corrections, plonk derives the marker (#62) and
scans trunk history for it. The branch merged via squash as PR #63,
so the trunk commit title ends in (#63) and the worktree is never
recognized as complete. Additional commit-message patterns worth
accepting when checking history for an issue-N branch:

  • Closes #N, Fixes #N, Resolves #N (and their -d/-s variants),
    which GitHub propagates into many squash bodies;
  • classic merge commits: Merge pull request #M from <owner>/<branch>,
    where the branch segment itself matches, making the PR number
    irrelevant; and
  • the branch name appearing verbatim in a squash title or body.

Suggestion: GitHub API fallback for unmatched branch names

Forty of the forty-three worktrees removed in the manual sweep had
purely descriptive branch names (fix-markdown-gates,
adopt-whitaker, typos-shared-base, …) that no offline pattern can
map to a completion marker. When a branch name matches no expected
pattern (or a pattern matches but no marker is found), a fallback query
answers the question authoritatively:

gh pr list --head <branch> --state merged --json number -L 1

(or the equivalent GraphQL pullRequests(headRefName:) lookup). A
MERGED result is a stronger signal than any commit-message heuristic
and also covers squash and rebase merges uniformly. A cheaper offline
approximation, when network access is undesirable, is git fetch --prune followed by checking whether the branch's upstream is gone —
weaker, since it cannot distinguish merged from abandoned, but a useful
--offline tier.

Suggested precedence: marker patterns first (fast, offline), API
fallback second, upstream-gone as an opt-in heuristic; --dry-run
output could label which signal justified each candidate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestmedium

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions