Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions platform/extension/gitworkspace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["gitworkspace.go"],
importpath = "github.com/uber/submitqueue/platform/extension/gitworkspace",
visibility = ["//visibility:public"],
)
64 changes: 64 additions & 0 deletions platform/extension/gitworkspace/gitworkspace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package gitworkspace defines the pluggable interface for executing git
// commands in a stateful workspace. The OSS implementation runs commands as
// local subprocesses; alternative deployments wrap their backend's exec API
// in the same contract.
package gitworkspace

//go:generate mockgen -source=gitworkspace.go -destination=mock/gitworkspace_mock.go -package=mock

import "context"

// Command is one command to execute in a git workspace.
type Command struct {
// Alias identifies this command's Output in the response.
Alias string
// Bin is the executable name.
Bin string
// Args are the command-line arguments.
Args []string
// Stdin is optional standard input.
Stdin string
}

// Output is the result of one executed command.
type Output struct {
// Alias matches the Command that produced this output.
Alias string
// ExitCode is the process exit code (0 = success, -1 = skipped).
ExitCode int32
// Stdout is the captured standard output.
Stdout string
// Stderr is the captured standard error.
Stderr string
}

// Workspace is a stateful git environment where command batches execute
// sequentially. Commands within one Exec call run in order; a non-zero
// exit code skips the remaining commands in that batch. State persists
// across Exec calls on the same Workspace.
type Workspace interface {
// Exec sends a batch of commands and returns their outputs.
Exec(commands []Command) ([]Output, error)
// Close releases the workspace and its resources.
Close() error
}

// Factory creates Workspace instances bound to a repository.
type Factory interface {
// For returns a Workspace for the given repository.
For(ctx context.Context, repo string) (Workspace, error)
}
12 changes: 12 additions & 0 deletions platform/extension/gitworkspace/mock/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = ["gitworkspace_mock.go"],
importpath = "github.com/uber/submitqueue/platform/extension/gitworkspace/mock",
visibility = ["//visibility:public"],
deps = [
"//platform/extension/gitworkspace:go_default_library",
"@org_uber_go_mock//gomock:go_default_library",
],
)
103 changes: 103 additions & 0 deletions platform/extension/gitworkspace/mock/gitworkspace_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading