GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — fix(telemetry): don't shallow-clone the user's repo for git labels by marcosnils · Pull Request #13363 · dagger/dagger Conversation
Contributor
In a GitHub pull_request build, WithGitLabels resolved the PR head commit by running 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
grouville
reviewed
Uh oh!
There was an error while loading. Please reload this page.
marcosnils
force-pushed
the
push-ysmwqwptvkqz
branch
from
38815d8 to
938ec81
Compare
grouville
self-requested a review
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
662dadc to
06c08b4
Compare
grouville
approved these changes
|
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
removes tests that are not relevant for the case we're trying to verify Signed-off-by: Marcos Lilljedahl <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Amazing, thanks 🙏
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…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]>
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
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Telemetry git-labels rungit fetch --depth 1 in the host working tree, shallow-cloning the user's repo on GitHub Actions PR builds
There was an error while loading. Please reload this page.