Skip to content

fix(pr): publish when the migration branch is already on GitHub - #120

Merged
lucasbraum merged 1 commit into
mainfrom
claude/kind-pasteur-7e07gb
Oct 14, 2026
Merged

lucasbraum merged 1 commit into
mainfrom
claude/kind-pasteur-7e07gb

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

What and why

UPT-19

Closing a pull request does not delete its branch. When a later run found uptide/<pkg>-<version> already on origin, its plain push was rejected, so a verified migration got no PR. In a real run, fix stripe verified the migration (types 0 → 4 → 0, tests pass) but could not open the PR because uptide/stripe-23.0.0 was still there from a closed PR.

What publishing does now when the branch already exists (packages/core/src/fix/publish.ts):

  • Already at the verified commit: nothing is pushed.
  • Only Uptide's commits beyond the base: Uptide's means the App's bot that authored this run's commits, or the legacy uptide[bot]. A person's identity never counts, not even the local user's. The branch is replaced with --force-with-lease against the commit just read. If an open Uptide PR uses the branch, its description is refreshed and no second PR is opened. If none is open, a new PR is opened.
  • Any commit from someone else, or commits that cannot be read: the branch is never overwritten. The run goes to the next free <branch>-2, -3, … under the same rules, and the PR body opens with a line naming the branch left alone and whose commits are on it.
  • Where authors come from: GitHub's compare (gh api repos/<repo>/compare/<base>...<sha>), because the Action's checkout is shallow. Read locally, main's older history would look like someone else's commits.

When publication fails, uptide pr --json now emits { error: { code, reason } }. The reason is a sentence Uptide composes, never git or GitHub output. The Action puts it in the report and the job summary, e.g. "verified, but the pull request could not be opened: the branch on GitHub changed while it was being published", instead of "the job log has the reason".

How it was verified

  • packages/core/src/fix/publish-branch.test.ts runs real git against a bare-repo origin. The run's checkout is a shallow clone like the Action's, and main moves on after the old branch was made. Only gh is faked; its compare answers come from the origin itself. Cases:

    • the branch is absent;
    • a closed-PR branch left by the App bot, and one left by legacy uptide[bot], is replaced and a new PR is opened;
    • an open Uptide PR is updated, not duplicated;
    • a person's commit sends the run to -3, because -2 holds a person's commit under a bot commit. The body says so, and a re-run is idempotent;
    • a commit pushed mid-publish fails the leased push, and the error names the reason.

    Five of the six fail against the previous publish.ts.

  • action/run.test.ts: a PublishFailure reason reaches the upgrade's error and renderSummary, and the report stays schema-valid.

  • cli.test.ts: pr --json emits the reason, and the full error still goes to stderr.

  • pnpm lint && pnpm typecheck && pnpm test pass. The one lint warning, in report.test.ts, was already on main.

Checklist

  • Tests for the change (a bug fix starts with a failing test)
  • pnpm lint && pnpm typecheck && pnpm test pass
  • README and docs updated if behavior changed (docs/commands/pr.md)
  • Changeset added if a user would notice (pnpm changeset)
  • No new dependency, or it was agreed in an issue
  • No private code, names or paths in fixtures, tests or docs
  • The rules in CONTRIBUTING.md ("Rules that do not bend") still hold. Nothing is pushed without --yes, and the publish step only fetches what GitHub's API reports; it writes no ref in the user's checkout.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EBZ9skzRkmHe3mYSxTVzyN


Generated by Claude Code

UPT-19

Closing a pull request does not delete its branch, so a later run found
uptide/<pkg>-<version> on origin and its plain push was rejected: a
verified migration with no PR. Now the branch is reused when it holds
only Uptide's commits beyond the base (the App's bot or the legacy
uptide[bot]), replaced with --force-with-lease against what was just
read; an open Uptide PR on it gets the new description instead of a
second PR. A branch with anyone else's commit is never overwritten: the
run goes to the next free <branch>-2, -3, ... and the PR body says so.
Authors are read from GitHub's compare, since the Action's checkout is
shallow.

When publishing fails, `uptide pr --json` emits a reason Uptide
composed, and the Action's report and job summary name it instead of
"the job log has the reason".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EBZ9skzRkmHe3mYSxTVzyN
Signed-off-by: Claude <[email protected]>
@lucasbraum
lucasbraum merged commit b7e0f42 into main Oct 14, 2026
10 checks passed
@lucasbraum
lucasbraum deleted the claude/kind-pasteur-7e07gb branch October 14, 2026 00:50
@uptide-release uptide-release Bot mentioned this pull request Oct 14, 2026
lucasbraum pushed a commit that referenced this pull request Oct 14, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## [email protected]

### Patch Changes

- [#118](#118)
[`40b3c1f`](40b3c1f)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - The onboarding
generator (`uptide/onboarding`, the "Add Uptide" pull request) writes
`minReleaseAgeDays` to `uptide.yml`, with a comment, when the settings
set it. Before, the
  setting was kept in the returned config but left out of the file.

- [#117](#117)
[`d1e7388`](d1e7388)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Let packs inspect
declared config and convention files without imports and apply verified
multi-file create, delete, write and rename transactions.

- [#116](#116)
[`4419673`](4419673)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Allow migration
packs to require a successful repository build before publication,
including subsequent verification runs.

- [#120](#120)
[`b7e0f42`](b7e0f42)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - `uptide pr` (and
`fix --pr`) publishes when the migration branch is already on GitHub, as
it is after a pull request was closed without merging. A branch holding
only Uptide's commits is replaced with `--force-with-lease`, and an open
Uptide pull request on it is updated instead of a second one being
opened. A branch with anyone else's commit is never overwritten: the run
goes to the next free `<branch>-2`, `-3`, … and the pull request says
so. When publication fails in the Action, the job summary and run report
name the reason.

- [#115](#115)
[`17cb9a2`](17cb9a2)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Support explicit
pack release groups so installed lockstep companions move with their
lead even without dependency edges or incompatible peers.

Co-authored-by: uptide-release[bot] <338861287+uptide-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants