Repository navigation
core: add GitCommit type - #13088
Merged
Merged
core: add GitCommit type#13088
Conversation
shykes
force-pushed
the
core-git-commit
branch
6 times, most recently
from
May 11, 2026 17:39
dab65fd to
a907efb
Compare
shykes
marked this pull request as ready for review
May 12, 2026 17:38
dagger-codex
Bot
force-pushed
the
core-git-commit
branch
from
May 21, 2026 00:21
f017705 to
7adf9ca
Compare
Contributor
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Contributor
|
Bump, not stale 😄 |
3 tasks
Contributor
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Contributor
|
This PR was closed because it has been stalled for 7 days with no activity. |
vito
force-pushed
the
core-git-commit
branch
3 times, most recently
from
July 30, 2026 20:55
a500ef0 to
526494d
Compare
vito
force-pushed
the
core-git-commit
branch
2 times, most recently
from
August 5, 2026 13:48
c9c3fc4 to
3bc308b
Compare
grouville
self-requested a review
August 5, 2026 19:37
grouville
approved these changes
Aug 5, 2026
grouville
left a comment
Member
There was a problem hiding this comment.
LGTM, found 2 edge cases. No storng opinion on those
vito
force-pushed
the
core-git-commit
branch
2 times, most recently
from
August 6, 2026 04:01
d840670 to
be1b4ff
Compare
Adds GitCommit as the commit-metadata object for the core Git API. Refs can resolve to it with GitRef.asCommit, and direct commit lookup returns it in the current schema. Breaking change: for current clients, GitRepository.commit(id:) changes return type from GitRef to GitCommit. Code that used git(...).commit(id).commit should use git(...).commit(id).sha; code that needs ref behavior should use git(...).ref(id). Older schema views keep the previous GitRef return for compatibility. Signed-off-by: Solomon Hykes <[email protected]>
Keep GitCommit keyed by its SHA so commit tree checkouts do not inherit branch or tag identity. Keep the original ref name only as a fetch fallback for remotes that cannot fetch by SHA. Cache commit metadata on the GitCommit object and share the GitRef/GitCommit repo attachment code. Signed-off-by: Solomon Hykes <[email protected]>
Adds commitSHA and name as clearer aliases for commit and ref. Deprecates the old field names so the API can move away from commit later. Signed-off-by: Solomon Hykes <[email protected]>
Renames GitRef.asCommit to targetCommit and regenerates the Go SDK so clients use the clearer field name. Signed-off-by: Solomon Hykes <[email protected]>
GitCommit now has releaseTag and ancestorReleaseTag. They choose the latest semver tag without running git fetch --tags. For local repositories, the lookup combines local tags with tags from the default fetch remote and errors if the same tag name points at two different commits. Signed-off-by: Solomon Hykes <[email protected]>
MergeBase already knew how to mount a set of refs with full history: refs sharing a repository go through a single backend mount, refs from different repositories get joined into a temporary repository. Pull that topology out into mountRefs so other multi-ref git operations can reuse it, and rewrite MergeBase on top of it. No behavior change. Signed-off-by: Alex Suraci <[email protected]>
GitRef.log lists the commits reachable from a ref as GitCommit values, newest first, starting with the commit the ref resolves to. It takes a limit (default 10), an optional set of paths to restrict the log to commits touching them, and an optional base ref whose reachable commits are excluded, i.e. base..ref. The base ref may live in a different repository, which is why this builds on mountRefs. Each entry is built by selecting the repository's commit field for its SHA rather than constructed inline, so a log entry is the same object, with the same ID and cache entry, as the commit looked up directly by that SHA. Since the whole log is read within a single mount, the metadata is prefilled onto each commit, sparing an N-commit log N further mounts to read its fields back. Reading a log fetches the full history of the refs involved, the same tradeoff commonAncestor already makes; local repositories are unaffected. A shallow local checkout silently truncates at its boundary, and a base ref with no common ancestor is not an error - it just excludes nothing. Workspaces inherit this for free: workspace.git.head is an ordinary GitRef. Signed-off-by: Alex Suraci <[email protected]>
The point of returning GitCommit from GitRef.log rather than bare metadata is that each entry is a whole commit, so a workspace can walk from its own git state to the tree as of any commit in its history. Assert that end to end: each log entry's tree checks out that commit's content, not HEAD's. Signed-off-by: Alex Suraci <[email protected]>
GitRef.commit and GitRef.ref were deprecated in favor of commitSHA and name, which resolve through the same underlying resolvers, so the switch is purely cosmetic. Updating the callers clears the SA1019 staticcheck warnings without changing any assertions. Signed-off-by: Alex Suraci <[email protected]>
Gate the GitCommit class itself behind v1.0.0-0, following the same pattern as Volume and the Workspace types. The class-level view filter propagates through the install hooks, so the GitCommitID scalar, loadGitCommitFromID, and the Env/Binding extensions are all hidden from older module views by the single InstallObject call. The new GitRef fields (targetCommit, commitSHA, name) get the same gate; targetCommit previously claimed AllVersion despite returning a type old views cannot see. The commit and ref deprecations are split into view-scoped definitions so pre-v1.0.0 views keep the undecorated fields they shipped with, keeping the base schema allowlist byte-identical - the deprecation reasons point at replacement fields those views do not have. GitCommit.tree also reused GitRef.tree's args struct, dragging the pre-v0.12.0 sshKnownHosts/sshAuthSocket compat args onto a brand-new type; it now has its own args struct without them. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Splitting commit() into a GitCommit resolver and a legacy commitRef dropped
the strict-refs guard from the legacy path, which serves every view before
v1.0.0-0. Views in [v0.19.0, v1.0.0-0) regressed to resolving arbitrary
refs: commit("main") silently resolved the branch instead of erroring, and
worse, entered the workspace lockfile path that non-SHA lookups trigger in
ref(), recording lock entries the strict guard used to make unreachable.
Restore the guard in commitRef, and pin a legacy test inside the affected
window; existing coverage only exercised the latest view and a pre-v0.19.0
module, bracketing the regression on both sides without hitting it.
Signed-off-by: Alex Suraci <[email protected]>
reconcileGitTagRefs errored whenever a tag name resolved to different commits locally and remotely, and it ran before the semver filter, so a moved nightly/latest tag or any local-only divergence failed the whole releaseTag query even when the offending tag could never be selected. The error was dubious anyway: mistakes happen, people push over semver tags, and a local checkout that predates a force-push is stale, not broken. An error that clears up by asking a different engine - one whose checkout postdates the force-push - is not protecting anything. Drop the conflict check and let the remote SHA win, which is what a fresh clone would report. Signed-off-by: Alex Suraci <[email protected]>
For local repositories, releaseTag consulted the default fetch remote via ls-remote on the mounted checkout and failed the whole field if that call failed. The mounted local repo is a bare CLI with none of the auth wiring RemoteGitRepository sets up (SSH sock, tokens, headers, resolv override), so a private origin, an SSH remote, or an offline machine turned a tag lookup into an error even though the local tags could answer it. Make the remote consultation best-effort: on ls-remote failure, warn and fall back to local tags. Context cancellation still propagates as an error rather than masquerading as an empty remote. Signed-off-by: Alex Suraci <[email protected]>
The release tag fixture had no fetch remote at all, so the remote consultation path was never exercised. Point origin at an unreachable host and assert the lookup still answers from local tags instead of propagating the ls-remote failure. Signed-off-by: Alex Suraci <[email protected]>
parseGitTimezoneOffset required exactly +/-HHMM, but git reads the digits as hours*100+minutes at any width, so offsets like +051800 (real, common in history imported from CVS/SVN) parse fine for git and errored here. Since every GitCommit field funnels through Metadata() and GitRef.log parses each commit in the window inline, one such commit anywhere in the range failed the entire log call. Parse offsets the way git does, and when the result is garbage or beyond what RFC3339 can express (+/-23:59), render the date in UTC instead of erroring: the timestamp is exact regardless, only the displayed zone degrades. Signed-off-by: Alex Suraci <[email protected]>
The content digests for GitRef and GitCommit hash the repository URL plus the resolved SHA, but URL is only populated for remote backends, so every local repository hashed as "". Two different local checkouts at the same commit unified to one cache entry. That was latent for GitRef (the checked-out tree is the same either way), but releaseTag and ancestorReleaseTag are the first fields whose answer depends on which repository you're standing in - local tag sets differ - so the collision became observable, e.g. a fork and an upstream clone on the same host. Mix the backing Directory's content digest into both results for local backends. As a bonus this keys cached answers to the actual repository state, so re-tagging a local repo produces a fresh digest instead of a stale cached releaseTag. Signed-off-by: Alex Suraci <[email protected]>
A commit is identified by its URL and SHA, so the same GitCommit result is shared across sessions - including the GitRepository it hangs off, and the ls-remote snapshot taken when that repository was resolved. Tags aren't immutable, so releaseTag and ancestorReleaseTag could answer a later session from an older session's advertised tags, and keep doing so forever: a tag pushed after the first lookup would never show up. Scope both fields per-session and have selectGitReleaseTag re-resolve the remote rather than reading the snapshot carried by the commit. Both parts are needed - per-session scoping alone still computes the answer from the shared parent's stale snapshot. This leaves the commit's identity alone, so tagging a repository no longer invalidates cached metadata and trees for every commit in it, and it covers local repositories too, whose tag lookups consult their fetch remote the same way. The freshness guarantee now matches GitRepository.tags and latestVersion: one resolution per session, against that session's remote. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
grouville
force-pushed
the
core-git-commit
branch
from
August 6, 2026 05:55
be1b4ff to
357e2b5
Compare
TomChv
approved these changes
Aug 6, 2026
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.
Summary
This adds a
GitCommitobject to the Git API, plus commit-oriented helpers onGitRef.GitRef.targetCommitto get commit details from a branch, tag, or ref. UseGitRepository.commit(id:)to look up a commit directly.GitRef.logto list the commits reachable from a ref asGitCommitvalues, newest first — with an optional path filter and an optionalbaseref to exclude (i.e.base..ref; the base may even live in a different repository).GitCommit.releaseTag/ancestorReleaseTagto find the latest semver tag pointing at (or reachable from) a commit, without runninggit fetch --tags.GitRefgainscommitSHAandnameas clearer names forcommitandref, which are now deprecated.All of the new surface is version-gated behind
v1.0.0-0; older module views are unchanged.Schema diff: https://github.com/dagger/dagger/pull/13088/files#diff-bb8fba2a10b96c16befe2b145e4e580f38839f20e0518cfd8c678d2296c27cb1
Notes
GitCommitis keyed by its SHA, so a log entry is the same object — same ID, same cache entry — as the commit looked up directly viaGitRepository.commit. Reading a log prefills the metadata onto each entry, so an N-commit log doesn't cost N further mounts.GitRef.logfetches the full history of the refs involved (the same tradeoffcommonAncestormakes); local repositories are unaffected. A shallow local checkout silently truncates at its boundary, and abasewith no common ancestor simply excludes nothing.workspace.git.headis an ordinaryGitRef, so a workspace can walk from its own git state to the tree as of any commit in its history.git fetch --tags; for local repositories they overlay the default fetch remote's tags over the local ones (the remote wins if a tag diverges, e.g. after a force-push), and fall back to local tags alone when the remote can't be reached.Breaking Change
For current clients,
GitRepository.commit(id:)changes return type fromGitReftoGitCommit. Code that usedgit(...).commit(id).commitshould usegit(...).commit(id).sha; code that needs ref behavior should usegit(...).ref(id).Older schema views keep the previous
GitRefreturn for compatibility, along with the undecoratedcommit/reffields they shipped with.Fixes #13086