GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@marcosnils

@marcosnils marcosnils commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@marcosnils
marcosnils requested a review from grouville June 8, 2026 13:37
grouville
grouville reviewed Jun 8, 2026
View reviewed changes
Comment thread engine/telemetry/labels.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@marcosnils
marcosnils force-pushed the push-ysmwqwptvkqz branch from 38815d8 to 938ec81 Compare June 8, 2026 20:01
@grouville
grouville self-requested a review June 8, 2026 21:43
marcosnils and others added 4 commits June 8, 2026 14:55
@marcosnils @grouville
fix(telemetry): don't shallow-clone the user's repo for git labels
7f38c12
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]>
@grouville
test(telemetry): cover GitHub PR merge checkout labels
bcb9df4
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]>
@grouville
fix(telemetry): gate PR merge parent lookup on GitHub SHA
5b3af52
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]>
@grouville
test(telemetry): group GitHub PR ref label cases
06c08b4
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
grouville force-pushed the push-ysmwqwptvkqz branch from 662dadc to 06c08b4 Compare June 8, 2026 21:55
grouville
grouville approved these changes Jun 8, 2026
View reviewed changes

@grouville grouville left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM, don't hesitate to change / remove the follow-up commits 🙏

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@grouville

grouville commented Jun 8, 2026

Copy link
Copy Markdown
Member

TestGit is a regression from workspace's merge into main

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@marcosnils marcosnils added this to the v0.21.5 milestone Jun 9, 2026
@marcosnils
make cloneRepo use depth 1 by default as GHA
066039b
removes tests that are not relevant for the case we're trying to verify

Signed-off-by: Marcos Lilljedahl <[email protected]>
@grouville
grouville self-requested a review June 9, 2026 19:41
grouville
grouville approved these changes Jun 9, 2026
View reviewed changes

@grouville grouville left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Amazing, thanks 🙏

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@marcosnils
marcosnils merged commit 2154a82 into dagger:main Jun 9, 2026
76 of 77 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@marcosnils
marcosnils deleted the push-ysmwqwptvkqz branch June 9, 2026 19:54
marcosnils added a commit that referenced this pull request Jun 9, 2026
@marcosnils @grouville
fix(telemetry): don't shallow-clone the user's repo for git labels (#…
3fcfba5
…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]>
@BrewTestBot BrewTestBot mentioned this pull request Jun 10, 2026
dagger 0.21.5 Homebrew/homebrew-core#287292
Merged
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
HarmonybrewBot HarmonybrewBot
!11205 merge bump-dagger-0.21.5 into main
e9e544f
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@grouville grouville grouville approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

v0.21.5

Development

Successfully merging this pull request may close these issues.

Telemetry git-labels run git fetch --depth 1 in the host working tree, shallow-cloning the user's repo on GitHub Actions PR builds

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@marcosnils @grouville
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.