git

package
v0.32.17 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotRepository = errors.New("not a git repository")

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Name     string `json:"name"`
	Current  bool   `json:"current,omitempty"`
	Upstream string `json:"upstream,omitempty"`
	Remote   bool   `json:"remote,omitempty"`
	Head     string `json:"head,omitempty"`
}

type Branches

type Branches struct {
	IsGit    bool     `json:"is_git"`
	Root     string   `json:"root"`
	Branches []Branch `json:"branches"`
}

type Client

type Client struct{}

func NewClient

func NewClient() *Client

func (*Client) Branches

func (c *Client) Branches(ctx context.Context, startDir string) (Branches, error)

func (*Client) CommitDetail added in v0.31.154

func (c *Client) CommitDetail(ctx context.Context, startDir, hash string) (CommitDetail, error)

func (*Client) Diff

func (c *Client) Diff(ctx context.Context, opts DiffOptions) (Diff, error)

func (*Client) Log

func (c *Client) Log(ctx context.Context, startDir string, limit int) (Log, error)

func (*Client) Mutate added in v0.31.109

func (c *Client) Mutate(ctx context.Context, opts MutationOptions) (MutationResult, error)

func (*Client) RepositoryRoot

func (c *Client) RepositoryRoot(ctx context.Context, startDir string) (string, error)

func (*Client) Status

func (c *Client) Status(ctx context.Context, startDir string) (Status, error)

func (*Client) Worktrees added in v0.31.154

func (c *Client) Worktrees(ctx context.Context, startDir string) (Worktrees, error)

type Commit

type Commit struct {
	Hash      string `json:"hash"`
	ShortHash string `json:"short_hash"`
	Author    string `json:"author,omitempty"`
	Date      string `json:"date,omitempty"`
	Subject   string `json:"subject"`
}

type CommitDetail added in v0.31.154

type CommitDetail struct {
	IsGit     bool         `json:"is_git"`
	Root      string       `json:"root"`
	Hash      string       `json:"hash"`
	ShortHash string       `json:"short_hash"`
	Author    string       `json:"author,omitempty"`
	Email     string       `json:"email,omitempty"`
	Date      string       `json:"date,omitempty"`
	Parents   []string     `json:"parents,omitempty"`
	Subject   string       `json:"subject"`
	Body      string       `json:"body,omitempty"`
	Files     []CommitFile `json:"files"`
}

type CommitFile added in v0.31.154

type CommitFile struct {
	Path      string `json:"path"`
	OldPath   string `json:"old_path,omitempty"`
	Status    string `json:"status"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Binary    bool   `json:"binary,omitempty"`
}

type Diff

type Diff struct {
	IsGit  bool   `json:"is_git"`
	Root   string `json:"root"`
	Path   string `json:"path,omitempty"`
	Staged bool   `json:"staged"`
	Hash   string `json:"hash,omitempty"`
	Patch  string `json:"patch"`
}

type DiffOptions

type DiffOptions struct {
	StartDir string
	Path     string
	Staged   bool
	Hash     string
}

type Log

type Log struct {
	IsGit   bool     `json:"is_git"`
	Root    string   `json:"root"`
	Commits []Commit `json:"commits"`
}

type MutationAction added in v0.31.109

type MutationAction string
const (
	MutationStage          MutationAction = "stage"
	MutationUnstage        MutationAction = "unstage"
	MutationDiscard        MutationAction = "discard"
	MutationCommit         MutationAction = "commit"
	MutationSwitchBranch   MutationAction = "switch_branch"
	MutationCheckoutCommit MutationAction = "checkout_commit"
	MutationWorktreeAdd    MutationAction = "worktree_add"
	MutationWorktreeRemove MutationAction = "worktree_remove"
	MutationFetch          MutationAction = "fetch"
)

type MutationOptions added in v0.31.109

type MutationOptions struct {
	StartDir     string
	Action       MutationAction
	Path         string
	Branch       string
	Message      string
	Hash         string
	WorktreePath string
	NewBranch    string
}

type MutationResult added in v0.31.109

type MutationResult struct {
	IsGit        bool           `json:"is_git"`
	Root         string         `json:"root"`
	Action       MutationAction `json:"action"`
	Path         string         `json:"path,omitempty"`
	Branch       string         `json:"branch,omitempty"`
	Message      string         `json:"message,omitempty"`
	Hash         string         `json:"hash,omitempty"`
	WorktreePath string         `json:"worktree_path,omitempty"`
	NewBranch    string         `json:"new_branch,omitempty"`
	Destructive  bool           `json:"destructive,omitempty"`
	Output       string         `json:"output,omitempty"`
}

type Remote

type Remote struct {
	Name     string `json:"name"`
	FetchURL string `json:"fetch_url,omitempty"`
	PushURL  string `json:"push_url,omitempty"`
}

type Status

type Status struct {
	IsGit    bool         `json:"is_git"`
	Root     string       `json:"root"`
	Branch   string       `json:"branch,omitempty"`
	Head     string       `json:"head,omitempty"`
	Upstream string       `json:"upstream,omitempty"`
	Remotes  []Remote     `json:"remotes,omitempty"`
	Files    []StatusFile `json:"files,omitempty"`
}

type StatusFile

type StatusFile struct {
	Path      string `json:"path"`
	OldPath   string `json:"old_path,omitempty"`
	Index     string `json:"index,omitempty"`
	Worktree  string `json:"worktree,omitempty"`
	Status    string `json:"status"`
	Staged    bool   `json:"staged"`
	Unstaged  bool   `json:"unstaged"`
	Untracked bool   `json:"untracked,omitempty"`
}

type Worktree added in v0.31.154

type Worktree struct {
	Path        string `json:"path"`
	Head        string `json:"head,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Detached    bool   `json:"detached,omitempty"`
	Locked      bool   `json:"locked,omitempty"`
	LockReason  string `json:"lock_reason,omitempty"`
	Prunable    bool   `json:"prunable,omitempty"`
	PruneReason string `json:"prune_reason,omitempty"`
	Bare        bool   `json:"bare,omitempty"`
	Current     bool   `json:"current,omitempty"`
}

type Worktrees added in v0.31.154

type Worktrees struct {
	IsGit     bool       `json:"is_git"`
	Root      string     `json:"root"`
	Worktrees []Worktree `json:"worktrees"`
}

Jump to

Keyboard shortcuts

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