git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	WorkDir string
	Logger  *slog.Logger
	// contains filtered or unexported fields
}

Client wraps git command execution with a global file-based lock for process safety.

func NewClient

func NewClient(workDir string, logger *slog.Logger) *Client

NewClient creates a new git client for the given working directory.

func (*Client) Add

func (c *Client) Add(files ...string) error

Add adds files to the stage.

func (*Client) Commit

func (c *Client) Commit(msg string) error

Commit records changes to the repository.

func (*Client) HasRemote

func (c *Client) HasRemote() bool

HasRemote checks if there is a 'origin' remote configured. For now, we hardcode 'origin' as the default remote to check.

func (*Client) Init

func (c *Client) Init() error

Init initializes a new git repository if one doesn't exist.

func (*Client) Lock

func (c *Client) Lock() (func(), error)

Lock acquires a file-based lock. It blocks until the lock is acquired.

func (*Client) Rm

func (c *Client) Rm(files ...string) error

Rm removes files from the working tree and from the index.

func (*Client) Run

func (c *Client) Run(args ...string) (string, error)

Run executes a raw git command in the working directory. NOTE: It does NOT acquire the lock automatically. The caller must manage transaction safety via Client.Lock().

func (*Client) Status

func (c *Client) Status() (string, error)

Status returns the porcelain status of the repo.

func (*Client) Sync

func (c *Client) Sync() error

Sync performs a pull --rebase and then a push. It assumes the caller handles locking if necessary, though git operations themselves are somewhat atomic, coordinating multiple git commands usually requires a lock to prevent state changes in between.

Jump to

Keyboard shortcuts

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