git

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 5 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{}

Client provides git operations.

func NewClient

func NewClient() *Client

NewClient creates a new git client.

func (*Client) Add added in v0.20.0

func (c *Client) Add(dir string, paths ...string) error

Add stages the given paths. dir sets the working directory for the command.

func (*Client) Commit added in v0.20.0

func (c *Client) Commit(dir string, message string, paths ...string) error

Commit creates a commit with the given message. When paths are provided, only those paths are included in the commit - other staged changes are left untouched. This is equivalent to running `git commit -m <msg> -- <paths>`, which scopes the commit to the specified paths without the --only flag. dir sets the working directory for the command.

func (*Client) GetMainWorktreeRoot added in v0.20.0

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

GetMainWorktreeRoot returns the root directory of the main worktree. Returns an error if not in a git repo or not in a worktree.

func (*Client) GetRepoRoot

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

GetRepoRoot returns the repository root directory. Returns an error if not in a git repository.

func (*Client) GetUserName

func (c *Client) GetUserName() string

GetUserName returns the configured git user.name. Returns empty string if git is unavailable or user.name is not configured.

func (*Client) IsRepo

func (c *Client) IsRepo() bool

IsRepo returns true if the current directory is inside a git repository.

func (*Client) IsRepoAt added in v0.20.0

func (c *Client) IsRepoAt(dir string) bool

IsRepoAt returns true if the given directory is inside a git repository.

func (*Client) IsWorktree added in v0.20.0

func (c *Client) IsWorktree() bool

IsWorktree returns true if the current directory is inside a git worktree (not the main worktree). Returns false if not in a git repo.

func (*Client) StatusPorcelain added in v0.20.0

func (c *Client) StatusPorcelain(dir string, paths ...string) (string, error)

StatusPorcelain returns `git status --porcelain` output for the given paths. Empty output means no changes. dir sets the working directory for the command.

Jump to

Keyboard shortcuts

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