Repository navigation
fix(telemetry): don't shallow-clone the user's repo for git labels - #13363
Merged
Merged
Conversation
grouville
reviewed
Jun 8, 2026
marcosnils
force-pushed
the
push-ysmwqwptvkqz
branch
from
June 8, 2026 20:01
38815d8 to
938ec81
Compare
grouville
self-requested a review
June 8, 2026 21:43
In a GitHub pull_request build, WithGitLabels resolved the PR head commit by running `git fetch --depth 1` inside the host checkout. That writes .git/shallow and silently turns a full checkout into a depth-1 clone, breaking later git history operations (merge-base, describe, log, ...). Resolve the PR head read-only from the merge commit's second parent (refs/pull/N/merge has the base as parent 1 and the PR head as parent 2), which needs no fetch and never mutates the repo. Fall back to a fetch only when that isn't possible, and gate --depth 1 on the repo already being shallow so the fetch can never shallow a full checkout either. Fixes dagger#13351 Signed-off-by: Marcos Nils <[email protected]>
WithGitLabels has two distinct GitHub pull_request checkout cases. When the local checkout is GitHub synthetic refs/pull/N/merge commit, the PR head is already available as the merge commit second parent and the code should not need to fetch refs/pull/N/head. When the workflow has checked out the PR head directly, local HEAD may itself be a merge commit and the code must not replace it with its second parent. The previous test coverage mostly asserted the final git labels. That can hide regressions because the fallback fetch path can still return the expected PR head even when the local synthetic-merge optimization is unreachable. Add a synthetic merge checkout test that removes origin before calling WithGitLabels. A correct implementation can still resolve the PR head locally, while an implementation that falls back to fetch leaves the label on the synthetic merge commit. Rename the existing PR-head checkout test so it is clear that it protects the direct-checkout merge-commit case. Signed-off-by: Guillaume de Rouville <[email protected]>
WithGitLabels has to distinguish two GitHub pull_request checkout shapes that both expose GITHUB_REF as refs/pull/N/merge. In the default checkout, local HEAD is GitHub's synthetic PR merge commit and the PR head is available as its second parent. In workflows that explicitly check out github.event.pull_request.head.sha, local HEAD is already the PR head and may itself be a merge commit. The previous guard compared commit.Hash with head.Hash, but commit is loaded from head.Hash just above, so the comparison is always equal and the local parent lookup never runs. That leaves the code on the fallback fetch path even when the synthetic merge commit and its parents are already present locally. Use the Actions runtime SHA to identify the default synthetic-merge checkout instead. When GITHUB_REF ends in /merge and local HEAD matches GITHUB_SHA, resolve the PR head from the merge commit's second parent. Otherwise fetch refs/pull/N/head, which handles refs/pull/N/head directly and direct PR-head checkouts where GITHUB_REF still points at /merge. Read GITHUB_REF and GITHUB_SHA through labels.eg so this path follows the injectable environment pattern used by the rest of the CI label code. Signed-off-by: Guillaume de Rouville <[email protected]>
The GitHub pull_request label logic now has a small decision tree: refs/pull/N/head fetches the PR head, refs/pull/N/merge without GITHUB_SHA keeps the old fetch behavior, refs/pull/N/merge with the synthetic merge checked out can use the local second parent, synthetic merge checkouts with a missing parent fall back to fetching, and workflows that checked out the PR head directly must not use the second parent of that PR head. The previous tests covered the important regression cases, but they were split across generic and very specific test names. That made it harder to see which PR-ref shapes were protected and which branch of WithGitLabels each test exercised. Group the GitHub PR ref coverage under one test with named subtests. Keep the previous refs/pull/N/head and refs/pull/N/merge fallback cases visible, and add the missing explicit fallback case for a checked-out refs/pull/N/merge commit whose local parent is unavailable, so all PR-ref branches are described next to each other. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
push-ysmwqwptvkqz
branch
from
June 8, 2026 21:55
662dadc to
06c08b4
Compare
grouville
approved these changes
Jun 8, 2026
Member
|
|
removes tests that are not relevant for the case we're trying to verify Signed-off-by: Marcos Lilljedahl <[email protected]>
grouville
self-requested a review
June 9, 2026 19:41
marcosnils
added a commit
that referenced
this pull request
Jun 9, 2026
…13363) In a GitHub pull_request build, WithGitLabels resolved the PR head commit by running `git fetch --depth 1` inside the host checkout. That writes .git/shallow and silently turns a full checkout into a depth-1 clone, breaking later git history operations (merge-base, describe, log, ...). Resolve the PR head read-only from the merge commit's second parent (refs/pull/N/merge has the base as parent 1 and the PR head as parent 2), which needs no fetch and never mutates the repo. Fall back to a fetch only when that isn't possible, and gate --depth 1 on the repo already being shallow so the fetch can never shallow a full checkout either. Fixes #13351 Signed-off-by: Marcos Nils <[email protected]> Co-authored-by: Guillaume de Rouville <[email protected]>
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
dagger 0.21.5 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## v0.21.5 - 2026-06-10 ### Added - Added expand option to container.exists by @alexcb in dagger/dagger#13310 - Support both Dang v1 and v2, routed by module engineVersion by @vito in dagger/dagger#13388 ### Changed - Prune local cache during disk pressure by @sipsma in dagger/dagger#13375 - Persist trivial core objects by @sipsma in dagger/dagger#13387 ### Fixed - Correct namespaced type-name mangling and cross-dependency interface dispatch in Dang by @vito in dagger/dagger#13377 - Surface exec errors correctly on the Bun runtime in the TypeScript SDK by @marcosnils in dagger/dagger#13395 - Ignore host xattrs for local filesync import identity by @sipsma in dagger/dagger#13389 - Don't shallow-clone the user's repo for git telemetry labels by @marcosnils in dagger/dagger#13363 - Preserve pending lazy container parents by @sipsma in dagger/dagger#13365 - Preserve withChanges parent layers by @dagger-codex[bot] + @shykes in dagger/dagger#13342 - Treat incomplete image metadata as cache miss by @sipsma in dagger/dagger#13346 - Cache registry image metadata by @dagger-codex[bot] + @shykes in dagger/dagger#13341 - Don't require id field for interface conformance in Dang by @vito in dagger/dagger#13318 - Use module-local check names for scale-out by @dagger-codex[bot] + @tiborvass in dagger/dagger#13329 - Fix snapshot owner lease attach/remove race by @sipsma in dagger/dagger#13321 - Follow source symlinks when copying directory contents in layercopy by @marcosnils in dagger/dagger#13326 ### What to do next? - Read the [documentation](https://docs.dagger.io) - Join our [Discord server](https://discord.gg/dagger-io) - Follow us on [Twitter](https://twitter.com/dagger_io) </pre> <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.5">https://github.com/dagger/dagger/releases/tag/v0.21.5</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11205
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a GitHub pull_request build, WithGitLabels resolved the PR head commit by running
git fetch --depth 1inside the host checkout. That writes .git/shallow and silently turns a full checkout into a depth-1 clone, breaking later git history operations (merge-base, describe, log, ...).Resolve the PR head read-only from the merge commit's second parent (refs/pull/N/merge has the base as parent 1 and the PR head as parent 2), which needs no fetch and never mutates the repo. Fall back to a fetch only when that isn't possible, and gate --depth 1 on the repo already being shallow so the fetch can never shallow a full checkout either.
Fixes #13351