Skip to content

fix(ci): make ci scopes --base origin/main work on a shallow clone - #1880

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8290-scopes-shallow-clone/make-ci-scopes-base-origin-main-work-shallow-clone--f4ba206a
Oct 5, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
devs/sileht/mrgfy-8290-scopes-shallow-clone/make-ci-scopes-base-origin-main-work-shallow-clone--f4ba206a

Conversation

@sileht

@sileht sileht commented Oct 5, 2026

Copy link
Copy Markdown
Member

mergify ci scopes --base origin/main --head HEAD is the invocation the
mergify-ci skill documents. Under actions/checkout's default
fetch-depth: 1 it failed the step with a git error instead of emitting
scopes, for two reasons:

  • The fetch asked the remote for origin/main, a name only a clone
    knows: "fatal: couldn't find remote ref origin/main". A leading
    origin/ (or remotes/origin/, refs/remotes/origin/) is now
    stripped from the fetch source; the local ref name is unchanged.
    feature/x is left alone, only the remote we fetch from counts as a
    prefix.
  • With that fixed, --deepen only deepened main. HEAD is never
    fetched by name, so its depth-1 boundary kept hiding its parents and
    the loop ended with "cannot find a common ancestor". The --deepen
    rounds now also ask for every commit listed in the clone's shallow
    file, so each boundary moves, HEAD's included.

The boundary commits rather than HEAD's SHA: they all came from the
remote, while HEAD can be a commit made on top of the checkout, which
the remote refuses and which would fail the whole fetch. They join only
the --deepen rounds, never the first --depth one, which would cut a
history the checkout already has.

Pull request events with a head SHA were not affected: both SHAs are
fetched. The other auto-detected references that use HEAD as head
(the HEAD^ fallback outside GitHub Actions, a push without before)
get the boundary deepening too.

Fixes MRGFY-8290

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Copilot AI balanced review requested due to automatic review settings October 5, 2026 12:59
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections October 5, 2026 12:59 Failure
@sileht
sileht deployed to func-tests-live October 5, 2026 12:59 — with GitHub Actions Active
@mergify

mergify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unrelated shallow boundaries can break fetches from origin, and filesystem errors lose their typed causes.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Fixes ci scopes --base origin/main --head HEAD on shallow checkouts.

Changes:

  • Normalizes remote-tracking names for fetch requests.
  • Includes shallow boundary commits during history deepening.
  • Adds regression tests for shallow checkouts and local commits.
File Description
crates/​mergify-ci/​src/​scopes_detect/​changed_files.rs Updates fetch handling and adds shallow-history regression tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/mergify-ci/src/scopes_detect/changed_files.rs Outdated
Comment thread crates/mergify-ci/src/scopes_detect/changed_files.rs Outdated
@mergify
mergify Bot requested a review from a team October 5, 2026 13:06
@sileht
sileht marked this pull request as ready for review October 5, 2026 14:11
`mergify ci scopes --base origin/main --head HEAD` is the invocation the
mergify-ci skill documents. Under `actions/checkout`'s default
`fetch-depth: 1` it failed the step with a git error instead of emitting
scopes, for two reasons:

- The fetch asked the remote for `origin/main`, a name only a clone
  knows: "fatal: couldn't find remote ref origin/main". A leading
  `origin/` (or `remotes/origin/`, `refs/remotes/origin/`) is now
  stripped from the fetch source; the local ref name is unchanged.
  `feature/x` is left alone, only the remote we fetch from counts as a
  prefix.
- With that fixed, `--deepen` only deepened `main`. HEAD is never
  fetched by name, so its depth-1 boundary kept hiding its parents and
  the loop ended with "cannot find a common ancestor". The `--deepen`
  rounds now also ask for every commit listed in the clone's `shallow`
  file, so each boundary moves, HEAD's included.

The boundary commits rather than HEAD's SHA: they all came from the
remote, while HEAD can be a commit made on top of the checkout, which
the remote refuses and which would fail the whole fetch. They join only
the `--deepen` rounds, never the first `--depth` one, which would cut a
history the checkout already has.

Pull request events with a head SHA were not affected: both SHAs are
fetched. The other auto-detected references that use `HEAD` as head
(the `HEAD^` fallback outside GitHub Actions, a push without `before`)
get the boundary deepening too.

Fixes MRGFY-8290

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change-Id: If4ba206ad2a6f84fe06a47ba62c1e9149b95c104
@sileht

sileht commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial 836fb83 2026-10-05 14:13 UTC
2 content 836fb83 → 2511f5c 2026-10-05 14:13 UTC

@sileht
sileht force-pushed the devs/sileht/mrgfy-8290-scopes-shallow-clone/make-ci-scopes-base-origin-main-work-shallow-clone--f4ba206a branch from 836fb83 to 2511f5c Compare October 5, 2026 14:13
@sileht
sileht deployed to func-tests-live October 5, 2026 14:13 — with GitHub Actions Active
@mergify
mergify Bot deployed to Mergify Merge Protections October 5, 2026 14:14 Active
@mergify
mergify Bot requested a review from a team October 5, 2026 14:53
@mergify

mergify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 9 minutes 3 seconds in the queue, including 8 minutes 21 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Oct 5, 2026
@mergify
mergify Bot merged commit 2e9bb24 into main Oct 5, 2026
23 checks passed
@mergify
mergify Bot deleted the devs/sileht/mrgfy-8290-scopes-shallow-clone/make-ci-scopes-base-origin-main-work-shallow-clone--f4ba206a branch October 5, 2026 15:11
@mergify mergify Bot removed the queued label Oct 5, 2026

This branch was successfully deployed

2 active deployments
Mergify Merge Protections — 2511f5c4 Deployed Oct 5, 2026 by mergify[bot]
func-tests-live — 2511f5c4 Deployed Oct 5, 2026 by sileht via live-tests #1972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants