feat: smart merge base for depot ci run by 121watts · Pull Request #467 · depot/cli

@121watts

Instead of always diffing against origin/main, detectPatch now checks
if the current branch has been pushed. If origin/<branch> exists, its
SHA is used as the merge base — so the patch contains only unpushed
local changes rather than the entire branch diff against main.

Uses the local tracking ref (not a live fetch) since the user may not
have pulled and the tracking ref is guaranteed to exist on GitHub.

Falls back to the default-branch merge base for unpushed topic branches.

DEP-3888

Made-with: Cursor

@121watts

- Log a warning to stderr when merge base detection fails instead of
  silently skipping patch mode.
- Update Cobra Long text to accurately describe the new branch-aware
  patch behavior.

Made-with: Cursor

graphite-app[bot]

cursor[bot]

The fast path was using rev-parse to get the SHA of origin/<branch>,
which could be ahead of HEAD. This caused git diff to generate a
reverse patch undoing remote commits when the tracking ref was ahead.

Now both paths use merge-base to find the common ancestor, ensuring
the diff only contains unpushed local changes.

Applied via @cursor push command
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

lukevmorris

The OnDefaultBranch test hardcoded origin/main but CI's git defaults
to master. Now discovers the actual default branch name dynamically,
matching how the production code works.

Also fixes extra blank lines caught by go fmt.

Made-with: Cursor

@121watts

@121watts 121watts deleted the watts/dep-3888-smart-merge-base branch

March 25, 2026 20:25