Workspace.git(): contextual information about a workspace's git repository#13074
Merged
Conversation
cb13ac3 to
47e0712
Compare
alexcb
reviewed
May 5, 2026
| if err != nil { | ||
| return fmt.Errorf("workspace git metadata: %w", err) | ||
| } | ||
| if st.FileType == core.FileTypeRegular { |
Collaborator
There was a problem hiding this comment.
nit: if !st.IsDir() { below would also cover this case if I'm not mistaken.
alexcb
approved these changes
May 5, 2026
Contributor
Author
|
I'm reducing the scope of this - removing fields related to semver tags. Moving that part to #13086 instead (it's cleaner attached to |
00ebda2 to
b684ab1
Compare
b19e833 to
6b77086
Compare
da07a4f to
e161c1e
Compare
1537f05 to
20de32d
Compare
20de32d to
15d1fbe
Compare
Expose local git state from the current Workspace without requiring users to model the workspace as a remote-oriented GitRepository.
Workspace.git returns a WorkspaceGit object. WorkspaceGit.head returns the checked-out HEAD as a GitRef, and WorkspaceGit.uncommitted returns the same Changeset shape and dirty/clean semantics as GitRepository.uncommitted.
On 1.0-beta, workspace detection is already rooted at the git boundary, so Workspace.git validates the .git entry at call time instead of persisting a separate HasGit bit. The repository is materialized from the workspace root, not the current workspace cwd, so nested cwd calls still report whole-repository dirty state.
Git worktrees remain an explicit first-pass boundary because their .git file points at metadata outside the workspace boundary.
Generated GraphQL docs and SDK bindings were refreshed with:
DAGGER_CLOUD_ENGINE=1 dagger --cloud generate --progress=plain -y
Verification:
GOMAXPROCS=2 go test ./core/workspace ./core/schema
DAGGER_CLOUD_ENGINE=1 dagger --cloud -m toolchains/engine-dev call test --progress=plain --pkg=./core/integration --run=TestWorkspace/TestWorkspaceGit --test-verbose --timeout=20m
Signed-off-by: Solomon Hykes <solomon@dagger.io>
15d1fbe to
06ac58c
Compare
tiborvass
pushed a commit
that referenced
this pull request
Jun 3, 2026
Add an auto-acquired *dagger.GitRepository input to the Go builder's New constructor. When present (default: the workspace root), read HEAD commit and uncommitted state, and append -X github.com/dagger/go/buildinfo.Injected*= values to the -ldflags pipeline. Binaries that import buildinfo (transitively via github.com/dagger/dagger/internal/version, after P1) self-report VCS info through runtime/debug.ReadBuildInfo without needing .git inside the build container. GitRepository was chosen over a Directory input because it's lazier — no full repo upload, the engine fetches only what GraphQL operations actually need. The dirty signal uses GitRepository.uncommitted, which the engine already implements with the right gitignore semantics. Inspection errors are swallowed silently — builds proceed without VCS info rather than aborting (matches the deleted version/ module's failure mode). TODO: switch to Workspace.git (PR #13074) when Dagger >= 1.0.0-beta.2. It's lazier still, supports nested workspaces cleanly, and will expose commit time once the GitCommit proposal (#13086) lands. No caller changes needed: cli-dev/engine-dev/release continue calling dag.Go(GoOpts{...}) unchanged. The new input auto-acquires from the workspace root at module-call time. dagger.gen.go for consumers will pick up the new optional field next time they run `dagger develop`.
tiborvass
pushed a commit
that referenced
this pull request
Jun 3, 2026
Add an auto-acquired *dagger.GitRepository input to the Go builder's New constructor. When present (default: the workspace root), read HEAD commit and uncommitted state, and append -X github.com/dagger/go/buildinfo.Injected*= values to the -ldflags pipeline. Binaries that import buildinfo (transitively via github.com/dagger/dagger/internal/version, after P1) self-report VCS info through runtime/debug.ReadBuildInfo without needing .git inside the build container. GitRepository was chosen over a Directory input because it's lazier — no full repo upload, the engine fetches only what GraphQL operations actually need. The dirty signal uses GitRepository.uncommitted, which the engine already implements with the right gitignore semantics. Inspection errors are swallowed silently — builds proceed without VCS info rather than aborting (matches the deleted version/ module's failure mode). TODO: switch to Workspace.git (PR #13074) when Dagger >= 1.0.0-beta.2. It's lazier still, supports nested workspaces cleanly, and will expose commit time once the GitCommit proposal (#13086) lands. No caller changes needed: cli-dev/engine-dev/release continue calling dag.Go(GoOpts{...}) unchanged. The new input auto-acquires from the workspace root at module-call time. dagger.gen.go for consumers will pick up the new optional field next time they run `dagger develop`. Signed-off-by: Solomon Hykes <solomon@dagger.io>
tiborvass
pushed a commit
that referenced
this pull request
Jun 4, 2026
Add an auto-acquired *dagger.GitRepository input to the Go builder's New constructor. When present (default: the workspace root), read HEAD commit and uncommitted state, and append -X github.com/dagger/go/buildinfo.Injected*= values to the -ldflags pipeline. Binaries that import buildinfo (transitively via github.com/dagger/dagger/internal/version, after P1) self-report VCS info through runtime/debug.ReadBuildInfo without needing .git inside the build container. GitRepository was chosen over a Directory input because it's lazier — no full repo upload, the engine fetches only what GraphQL operations actually need. The dirty signal uses GitRepository.uncommitted, which the engine already implements with the right gitignore semantics. Inspection errors are swallowed silently — builds proceed without VCS info rather than aborting (matches the deleted version/ module's failure mode). TODO: switch to Workspace.git (PR #13074) when Dagger >= 1.0.0-beta.2. It's lazier still, supports nested workspaces cleanly, and will expose commit time once the GitCommit proposal (#13086) lands. No caller changes needed: cli-dev/engine-dev/release continue calling dag.Go(GoOpts{...}) unchanged. The new input auto-acquires from the workspace root at module-call time. dagger.gen.go for consumers will pick up the new optional field next time they run `dagger develop`. Signed-off-by: Solomon Hykes <solomon@dagger.io>
dagger-codex Bot
pushed a commit
that referenced
this pull request
Jun 4, 2026
Add an auto-acquired *dagger.GitRepository input to the Go builder's New constructor. When present (default: the workspace root), read HEAD commit and uncommitted state, and append -X github.com/dagger/go/buildinfo.Injected*= values to the -ldflags pipeline. Binaries that import buildinfo (transitively via github.com/dagger/dagger/internal/version, after P1) self-report VCS info through runtime/debug.ReadBuildInfo without needing .git inside the build container. GitRepository was chosen over a Directory input because it's lazier — no full repo upload, the engine fetches only what GraphQL operations actually need. The dirty signal uses GitRepository.uncommitted, which the engine already implements with the right gitignore semantics. Inspection errors are swallowed silently — builds proceed without VCS info rather than aborting (matches the deleted version/ module's failure mode). TODO: switch to Workspace.git (PR #13074) when Dagger >= 1.0.0-beta.2. It's lazier still, supports nested workspaces cleanly, and will expose commit time once the GitCommit proposal (#13086) lands. No caller changes needed: cli-dev/engine-dev/release continue calling dag.Go(GoOpts{...}) unchanged. The new input auto-acquires from the workspace root at module-call time. dagger.gen.go for consumers will pick up the new optional field next time they run `dagger develop`. Signed-off-by: Solomon Hykes <solomon@dagger.io>
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.
This adds
Workspace.git, a local git view for the current workspace.Schema diff (tracks latest
workspace-gitbranch / PR head): https://github.com/dagger/dagger/pull/13074/files#diff-1b91750d917ed604e8eb08e4f5325f167511cd697317187b56d84b3736662e5funcommittedchecks the whole repository, even when the current workspace is a nested directory. Worktrees are not supported yet;.gitpoints outside the workspace boundary, so this returns an explicit unsupported-worktree error instead of following it.Semver tag helpers are left for the
GitCommitproposal in #13086.Tests