Skip to content

Workspace.git(): contextual information about a workspace's git repository - #13074

Merged
dagger-codex[bot] merged 1 commit into
1.0-betafrom
workspace-git
Jun 3, 2026
Merged

dagger-codex[bot] merged 1 commit into
1.0-betafrom
workspace-git

Conversation

@shykes

@shykes shykes commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

This adds Workspace.git, a local git view for the current workspace.

extend type Workspace {
  """Git state for this workspace. Errors if the workspace is not in a git repository."""
  git: WorkspaceGit!
}

"""Local git state for a workspace."""
type WorkspaceGit {
  """The checked-out HEAD of this workspace."""
  head: GitRef!

  """Uncommitted changes in this workspace, using the same rules as GitRepository.uncommitted."""
  uncommitted: Changeset!
}

Schema diff (tracks latest workspace-git branch / PR head): https://github.com/dagger/dagger/pull/13074/files#diff-1b91750d917ed604e8eb08e4f5325f167511cd697317187b56d84b3736662e5f

uncommitted checks the whole repository, even when the current workspace is a nested directory. Worktrees are not supported yet; .git points outside the workspace boundary, so this returns an explicit unsupported-worktree error instead of following it.

Semver tag helpers are left for the GitCommit proposal in #13086.

Tests

dagger -m github.com/dagger/dagger/toolchains/engine-dev@pull/13074/head call test --progress=report --pkg=./core/workspace --timeout=20m
dagger -m github.com/dagger/dagger/toolchains/engine-dev@pull/13074/head call test --progress=report --pkg=./core/schema --timeout=20m
dagger -m github.com/dagger/dagger/toolchains/engine-dev@pull/13074/head call test --progress=report --pkg=./core/integration --run=TestWorkspace/TestWorkspaceGit --test-verbose --timeout=20m

@shykes
shykes requested review from a team as code owners May 1, 2026 16:25
@shykes shykes changed the title core: add Workspace.git API core API: Workspace.git() May 1, 2026
@shykes shykes changed the title core API: Workspace.git() Workspace.git() May 1, 2026
@shykes shykes changed the title Workspace.git() Workspace.git(): contextual git information about a workspace May 1, 2026
@shykes shykes changed the title Workspace.git(): contextual git information about a workspace Workspace.git(): contextual information about a workspace's git repository May 1, 2026
@shykes
shykes force-pushed the workspace-git branch 3 times, most recently from cb13ac3 to 47e0712 Compare May 5, 2026 07:56
Comment thread core/schema/workspace.go
if err != nil {
return fmt.Errorf("workspace git metadata: %w", err)
}
if st.FileType == core.FileTypeRegular {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: if !st.IsDir() { below would also cover this case if I'm not mistaken.

@shykes

shykes commented May 5, 2026

Copy link
Copy Markdown
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 GitCommit).

@shykes
shykes force-pushed the workspace-git branch 9 times, most recently from 00ebda2 to b684ab1 Compare May 12, 2026 16:51
@dagger-codex
dagger-codex Bot force-pushed the workspace-git branch 2 times, most recently from b19e833 to 6b77086 Compare May 22, 2026 06:09
@dagger-codex
dagger-codex Bot deleted the workspace-git branch June 3, 2026 01:12
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
dagger-codex Bot pushed a commit that referenced this pull request Jun 8, 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 <[email protected]>
dagger-codex Bot pushed a commit that referenced this pull request Jun 8, 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 <[email protected]>
dagger-codex Bot pushed a commit that referenced this pull request Jun 8, 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 <[email protected]>
dagger-codex Bot pushed a commit that referenced this pull request Jun 8, 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 <[email protected]>
dagger-codex Bot pushed a commit that referenced this pull request Jun 9, 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 <[email protected]>
tiborvass pushed a commit that referenced this pull request Jun 10, 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 <[email protected]>
tiborvass pushed a commit to tiborvass/dagger that referenced this pull request Jun 17, 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 dagger#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 (dagger#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 <[email protected]>
shykes added a commit that referenced this pull request Jun 18, 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 <[email protected]>
shykes added a commit that referenced this pull request Jun 18, 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 <[email protected]>
shykes added a commit that referenced this pull request Jun 18, 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 <[email protected]>
shykes added a commit that referenced this pull request Jun 18, 2026
Switch the Go builder's VCS-injection input from a raw
*dagger.GitRepository (+defaultPath="/") to an auto-acquired
*dagger.Workspace, reading HEAD commit and uncommitted state via
Workspace.git. This is the follow-up the TODO in New() referenced
(#13074, now merged).

Workspace.git is lazier (no full repo upload), supports nested
workspaces cleanly, and exposes the same uncommitted/gitignore semantics
the engine already implements.

BLOCKED — needs codegen against a 1.0 engine before it compiles:
Workspace.git is only exposed in the v1.0.0+ API view, so toolchains/go
must depend on a 1.0 engine. engineVersion is bumped to v1.0.0-beta.3
here, but the internal/dagger client bindings and the runtime dispatch
in dagger.gen.go still target v0.21.7 and must be regenerated against a
1.0 engine (DAGGER_X_RELEASE) — e.g. `dagger generate
go:generate-dagger-runtimes`. That regen is intentionally left out of
this commit so it can be done once the repo's modules move to 1.0.

Signed-off-by: Solomon Hykes <[email protected]>
tiborvass pushed a commit that referenced this pull request Jun 29, 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 <[email protected]>
tiborvass pushed a commit to tiborvass/dagger that referenced this pull request Jul 1, 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 dagger#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 (dagger#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 <[email protected]>
tiborvass added a commit that referenced this pull request Jul 2, 2026
Implements the version/build identity foundation from discussion #13287.

This replaces the old Dagger `version` module and its git-tag-walking logic with build identity embedded in the binaries themselves. Native Go builds use the VCS metadata already stamped by the Go toolchain; sandboxed Dagger Go builds inject the same metadata through `github.com/dagger/go/buildinfo` ldflags.

## What changes

- Add `internal/version`, which embeds `internal/version/VERSION` and exposes `Version`, `Commit`, `Dirty`, `CommitTime`, and `Canonical()`.
- Add `github.com/dagger/go/buildinfo` as the wrapper around `runtime/debug.ReadBuildInfo`, with injectable `-ldflags` vars for sandboxed builds.
- Remove the standalone `/version` Dagger module and stop deriving versions by walking tags, merge-bases, or source digests inside Dagger.
- Teach `toolchains/go` to accept a `GitRepository` input and stamp VCS metadata into binaries it builds.
- Keep `engine.Version` and `engine.Tag` as the public version surfaces used by the CLI, engine, SDK defaults, and release code.
- Keep release pipelines able to override `engine.Version` and `engine.Tag` via ldflags.
- If `engine.Tag` is not explicitly set, derive it from the build identity:
  - release build -> `engine.Version`
  - dev build with commit -> commit
  - dev build without commit -> `main`
- Change `dagger version` to a labeled output while preserving the existing operational fields.

## Output

```
$ dagger version
version:     v0.21.3
commit:      3059ea7
dirty:       yes
platform:    linux/amd64
runner-host: image://registry.dagger.io/engine:v0.21.3

$ dagger version -q
v0.21.3+3059ea74.dirty
```

## Why

The old version path mixed several responsibilities: user-facing version strings, engine image tags, git history inspection, source digests, and release metadata. That made version calculation slower, harder to reason about, and dependent on Dagger runtime behavior even though the result is fundamentally build identity.

This PR moves build identity to the binary build step, where Go already has a standard mechanism for VCS metadata. The same identity model now works for native `go build` and sandboxed Dagger builds, while preserving the existing `engine.Version` / `engine.Tag` surfaces for callers that still rely on them.

## Not in this PR

- No release-by-promotion redesign or release manifest work.
- No Helm chart `VERSION` change.
- No SDK migration work beyond regenerated bindings needed for this branch.
- No switch to `Workspace.git`; `toolchains/go` keeps a TODO for that once available.
- No commit-time injection beyond what is already available from Go build info.
- No broader `engine.IsDevVersion` cleanup beyond recognizing `v1.0.0-dev` style prereleases.

Refs: discussion #13287, #13074 (Workspace.git), #13086 (GitCommit proposal).
@shykes shykes mentioned this pull request Jul 15, 2026
shykes added a commit that referenced this pull request Jul 16, 2026
Switch the Go builder's VCS-injection input from an explicit
*dagger.GitRepository to *dagger.Workspace, reading the HEAD commit and
uncommitted state via Workspace.git (#13074, shipped in 1.0).
Workspace.git is lazier than a raw GitRepository (no full repo upload) and
supports nested workspaces cleanly.

The engine only auto-injects a Workspace on a *direct* client call. Module
dependencies do not inherit the caller's workspace, so any module on a
build path that reaches the go toolchain must forward its own
(auto-injected) Workspace explicitly. The workspace arg (`ws`, optional) is
therefore threaded from each direct-call entrypoint down to every dag.Go
call site; when absent, VCS stamping is simply skipped.

Threaded through the build paths only, leaving non-building methods
untouched:
- cli-dev:    New -> go
- engine-dev: New (private field) -> go / cli-dev / internal Builder
- docs-dev:   References -> engine-dev
- dev:        Agent (gopls) and Test -> go / engine-dev
- release:    Publish, TestLocalRelease, PublishWithMockEndpoints

The stamping itself is inlined in go's New(): the HEAD commit and dirty
state are written via -ldflags into github.com/dagger/go/buildinfo's
Injected* vars, whose ReadBuildInfo wrapper overlays them onto the vcs.*
settings so binaries self-report VCS info without a .git in the build
container.

engineVersion is bumped to v1.0.0-beta.6 for every touched module so the
1.0-only Workspace.git field and generated Ws opts fields are in the API
view.

NOTE: requires regenerating the affected module clients against a 1.0
engine before it compiles — Workspace.git and the Ws opts fields are absent
from the checked-in bindings. Regen is intentionally left out (needs a
running engine) and must be run separately.

Signed-off-by: Solomon Hykes <[email protected]>
shykes added a commit that referenced this pull request Jul 16, 2026
Switch the Go builder's VCS-injection input from an explicit
*dagger.GitRepository to *dagger.Workspace, reading the HEAD commit and
uncommitted state via Workspace.git (#13074, shipped in 1.0).
Workspace.git is lazier than a raw GitRepository (no full repo upload) and
supports nested workspaces cleanly.

The engine only auto-injects a Workspace on a *direct* client call. Module
dependencies do not inherit the caller's workspace, so any module on a
build path that reaches the go toolchain must forward its own
(auto-injected) Workspace explicitly. The workspace arg (`ws`, optional) is
therefore threaded from each direct-call entrypoint down to every dag.Go
call site; when absent, VCS stamping is simply skipped.

Threaded through the build paths only, leaving non-building methods
untouched:
- cli-dev:    New -> go
- engine-dev: New (private field) -> go / cli-dev / internal Builder
- docs-dev:   References -> engine-dev
- dev:        Agent (gopls) and Test -> go / engine-dev
- release:    forwards its existing Workspace field (added by #13659) from
              Publish / TestLocalRelease / PublishWithMockEndpoints

The stamping itself is inlined in go's New(): the HEAD commit and dirty
state are written via -ldflags into github.com/dagger/go/buildinfo's
Injected* vars, whose ReadBuildInfo wrapper overlays them onto the vcs.*
settings so binaries self-report VCS info without a .git in the build
container.

engineVersion is bumped to v1.0.0-beta.6 for every touched module so the
1.0-only Workspace.git field and generated Ws opts fields are in the API
view.

NOTE: requires regenerating the affected module clients against a 1.0
engine before it compiles — Workspace.git and the Ws opts fields are absent
from the checked-in bindings. Regen is intentionally left out (needs a
running engine) and must be run separately.

Signed-off-by: Solomon Hykes <[email protected]>
shykes added a commit that referenced this pull request Jul 17, 2026
Switch the Go builder's VCS-injection input from an explicit
*dagger.GitRepository to *dagger.Workspace, reading the HEAD commit and
uncommitted state via Workspace.git (#13074, shipped in 1.0).
Workspace.git is lazier than a raw GitRepository (no full repo upload) and
supports nested workspaces cleanly.

The engine only auto-injects a Workspace on a *direct* client call. Module
dependencies do not inherit the caller's workspace, so any module on a
build path that reaches the go toolchain must forward its own
(auto-injected) Workspace explicitly. The workspace arg (`ws`, optional) is
therefore threaded from each direct-call entrypoint down to every dag.Go
call site; when absent, VCS stamping is simply skipped.

Threaded through the build paths only, leaving non-building methods
untouched:
- cli-dev:    New -> go
- engine-dev: New (private field) -> go / cli-dev / internal Builder
- docs-dev:   References -> engine-dev
- dev:        Agent (gopls) and Test -> go / engine-dev
- release:    forwards its existing Workspace field (added by #13659) from
              Publish / TestLocalRelease / PublishWithMockEndpoints

The stamping itself is inlined in go's New(): the HEAD commit and dirty
state are written via -ldflags into github.com/dagger/go/buildinfo's
Injected* vars, whose ReadBuildInfo wrapper overlays them onto the vcs.*
settings so binaries self-report VCS info without a .git in the build
container.

engineVersion is bumped to v1.0.0-beta.6 for every touched module so the
1.0-only Workspace.git field and generated Ws opts fields are in the API
view.

NOTE: requires regenerating the affected module clients against a 1.0
engine before it compiles — Workspace.git and the Ws opts fields are absent
from the checked-in bindings. Regen is intentionally left out (needs a
running engine) and must be run separately.

Signed-off-by: Solomon Hykes <[email protected]>
shykes added a commit that referenced this pull request Jul 18, 2026
Switch the Go builder's VCS-injection input from an explicit
*dagger.GitRepository to *dagger.Workspace, reading the HEAD commit and
uncommitted state via Workspace.git (#13074, shipped in 1.0).
Workspace.git is lazier than a raw GitRepository (no full repo upload) and
supports nested workspaces cleanly.

The engine only auto-injects a Workspace on a *direct* client call. Module
dependencies do not inherit the caller's workspace, so any module on a
build path that reaches the go toolchain must forward its own
(auto-injected) Workspace explicitly. The workspace arg (`ws`, optional) is
therefore threaded from each direct-call entrypoint down to every dag.Go
call site; when absent, VCS stamping is simply skipped.

Threaded through the build paths only, leaving non-building methods
untouched:
- cli-dev:    New -> go
- engine-dev: New (private field) -> go / cli-dev / internal Builder
- docs-dev:   References -> engine-dev
- dev:        Agent (gopls) and Test -> go / engine-dev
- release:    forwards its existing Workspace field (added by #13659) from
              Publish / TestLocalRelease / PublishWithMockEndpoints

The stamping itself is inlined in go's New(): the HEAD commit and dirty
state are written via -ldflags into github.com/dagger/go/buildinfo's
Injected* vars, whose ReadBuildInfo wrapper overlays them onto the vcs.*
settings so binaries self-report VCS info without a .git in the build
container.

engineVersion is bumped to v1.0.0-beta.6 for every touched module so the
1.0-only Workspace.git field and generated Ws opts fields are in the API
view.

NOTE: requires regenerating the affected module clients against a 1.0
engine before it compiles — Workspace.git and the Ws opts fields are absent
from the checked-in bindings. Regen is intentionally left out (needs a
running engine) and must be run separately.

Signed-off-by: Solomon Hykes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants