git

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotRepository = fmt.Errorf("not a git repository")
	ErrInvalidConfig = fmt.Errorf("invalid configuration")
)

Functions

func IsRepository

func IsRepository(path string) bool

IsRepository checks for .git directory presence to verify repository status.

Types

type Client

type Client struct {
	Runner executil.Runner
}

func New

func New(runner executil.Runner) (*Client, error)

New creates a git client with the provided command runner. Validates git is available to fail fast rather than on first operation.

func (Client) Clone

func (c Client) Clone(ctx context.Context, cfg CloneConfig) error

Clone creates a new local copy of a remote repository. Parent directories are created automatically to avoid manual setup.

func (Client) CloneOrUpdate

func (c Client) CloneOrUpdate(ctx context.Context, cfg CloneConfig) error

CloneOrUpdate ensures a repository exists and is up to date. Useful for idempotent operations where initial state is not important.

func (Client) Update

func (c Client) Update(ctx context.Context, repoPath, ref string) error

Update synchronizes a local repository with the remote ref. Uses reset --hard to discard local changes, ensuring a clean state matching remote.

type CloneConfig

type CloneConfig struct {
	URL       string // URL of the git repository.
	Ref       string // Branch, tag, or commit to checkout.
	LocalPath string // LocalPath where to clone the repository
	Depth     int    // Depth for shallow clone (0 = full clone)
}

CloneConfig configures repository cloning

func (CloneConfig) Validate

func (cfg CloneConfig) Validate() error

Validate config before using it

Jump to

Keyboard shortcuts

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