git

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCommitMessage is the default commit message.
	DefaultCommitMessage = "Apply changes from Holon"

	// DefaultRemote is the default remote name.
	DefaultRemote = "origin"

	// WorkspaceEnv is the environment variable for workspace directory.
	WorkspaceEnv = "HOLON_WORKSPACE"

	// GitTokenEnv is the environment variable for git authentication token.
	GitTokenEnv = "GIT_TOKEN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GitClient

type GitClient struct {
	// WorkspaceDir is the path to the Git workspace
	WorkspaceDir string

	// Token is the optional authentication token for push operations
	Token string
}

GitClient handles Git operations.

func NewGitClient

func NewGitClient(workspaceDir, token string) *GitClient

NewGitClient creates a new Git client.

func (*GitClient) ApplyPatch

func (g *GitClient) ApplyPatch(ctx context.Context, patchPath string) (bool, error)

ApplyPatch applies a patch file to the workspace using git apply --3way. Returns true if patch was applied, false if patch file was empty/missing.

func (*GitClient) CommitChanges

func (g *GitClient) CommitChanges(message string) (string, error)

CommitChanges commits all changes with the given message. Returns the commit hash if successful.

func (*GitClient) CreateBranch

func (g *GitClient) CreateBranch(branchName string) error

CreateBranch creates a new branch or checks out an existing one.

func (*GitClient) EnsureRepository

func (g *GitClient) EnsureRepository() error

EnsureRepository ensures the workspace is a Git repository.

func (*GitClient) Push

func (g *GitClient) Push(branchName, remoteName string) error

Push pushes the current branch to the specified remote.

type GitPublisherConfig

type GitPublisherConfig struct {
	// Branch is the branch name to create or checkout (optional)
	Branch string

	// Commit if true, commits changes after applying patch
	Commit bool

	// CommitMessage is the commit message (if empty, uses default)
	CommitMessage string

	// Push if true, pushes commits to remote
	Push bool

	// Remote is the remote name to push to (default: origin)
	Remote string

	// WorkspaceDir is the path to the git workspace
	WorkspaceDir string
}

GitPublisherConfig contains configuration for git publishing.

type Publisher

type Publisher struct{}

Publisher publishes Holon outputs to git.

func NewPublisher

func NewPublisher() *Publisher

NewPublisher creates a new git publisher instance.

func (*Publisher) Name

func (p *Publisher) Name() string

Name returns the provider name.

func (*Publisher) Publish

Publish sends Holon outputs to git.

Note: If branch creation succeeds but a subsequent step (patch application, commit, or push) fails, the repository will be left on the newly created/checked out branch. This behavior is intentional to preserve state for debugging.

func (*Publisher) Validate

func (p *Publisher) Validate(req publisher.PublishRequest) error

Validate checks if the request is valid for this publisher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL