Skip to content

Anchor and check upstream-targeted ship branches against the target's default branch - #293

Merged
trillium merged 2 commits into
mainfrom
fm/upstream-pr-base
Nov 4, 2026
Merged

trillium merged 2 commits into
mainfrom
fm/upstream-pr-base

Conversation

@trillium

@trillium trillium commented Nov 3, 2026

Copy link
Copy Markdown
Owner

What changes

A ship task that publishes to another repository (recorded with --upstream-consent) used to build on the clone's fork main, which can be hundreds of commits ahead of the target. A push from that branch put fork-only files into the upstream pull request.

Now the generated direct-PR brief for such a task:

  1. Starts the branch from the target repository's own default branch (bin/fm-target-base.sh anchor), not the fork's.
  2. Requires bin/fm-target-base.sh check <target> --allow <intended path> before every push. It refuses when the branch is not built on the target's tip or touches a file outside the intended set, and it prints the commit and file list to read.

The new script only fetches into FETCH_HEAD; it never pushes and never edits remotes or git config. No-mistakes mode was already refused for a foreign target, because the pipeline rebases onto origin's default branch and has no setting that names a different repository; that refusal is unchanged.

Affected output: the generated ship brief (Setup step 2 and Definition of done) when --upstream-consent is present, plus the new bin/fm-target-base.sh.

Evidence

flowchart LR
  subgraph Before
    A[fork main +N commits] --> B[task branch] --> C[push] --> D[upstream PR shows fork-only files]
  end
  subgraph After
    E[target main] --> F[anchor] --> G[task branch] --> H[check against target] -->|clean| I[push]
    H -->|other base or stray file| J[refused]
  end
Loading

Test run (tests/fm-target-base.test.sh, a fork that diverged from its upstream by two commits):

ok - fm-target-base.sh: anchor starts a fresh branch from the target, not the fork
ok - fm-target-base.sh: anchor refuses to discard commits
ok - fm-target-base.sh: check accepts an anchored branch touching only intended files
ok - fm-target-base.sh: check refuses a branch built on the fork's history
ok - fm-target-base.sh: check names fork-only files even when the target tip is an ancestor
ok - fm-target-base.sh: an unreachable target is refused rather than skipped

The brief assertions are in tests/fm-self-repo-role.test.sh; bin/fm-lint.sh and bin/fm-doc-audience-check.sh pass.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1e135cd7-5303-43ba-9417-5af17cf93a74
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…epository's default branch

A direct-PR task with upstream consent now starts its branch from the consented
repository's default branch and gates every push on a diff measured against it,
so fork-only history cannot ride into the upstream pull request.
@trillium
trillium force-pushed the fm/upstream-pr-base branch from 8f44fd5 to 9a61465 Compare November 4, 2026 04:05
@trillium
trillium merged commit e21bf85 into main Nov 4, 2026
25 checks passed
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.

1 participant