Skip to content

Re-Read a Deleted Ref Before Reporting DELETE_NOT_CONFIRMED in pr_cleanup #3436

Closed

Description

@ptr727

Problem

cleanup_remote_delete in scripts/pr_cleanup.py reads the ref back once, immediately after the deleteRef mutation returns. GitHub's GraphQL ref read can lag the delete by a moment, so a delete that landed can still read at its old tip. The run then prints status=DELETE_NOT_CONFIRMED <branch> on <repo> still reads at <sha> after the delete and exits 2 before the local half runs, leaving the worktree and the local branch in place.

Observed shape (constructed)

  1. pr_review.py cleanup <n> --repo OWNER/NAME --checkout <base-clone> on a merged pull request prints response: {"deleteRef": {"clientMutationId": null}}, then status=DELETE_NOT_CONFIRMED ... still reads at <tip>, and exits 2.
  2. A REST read seconds later, gh api repos/OWNER/NAME/git/ref/heads/<branch>, returns 404.
  3. Rerunning the same cleanup treats the branch as already gone, removes the worktree and the local branch, and exits 0.

What fixing it needs

A bounded re-read, a few attempts over a few seconds, before a still-present ref is reported. The exit stays 2 once the bound is spent, so a delete that truly did not land is still reported rather than assumed. A test drives the reader returning the old tip once and then nothing, and expects DELETED and exit 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions