git

package
v0.31.117 Latest Latest
Warning

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

Go to latest
Published: May 1, 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) 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)

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 Diff

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

type DiffOptions

type DiffOptions struct {
	StartDir string
	Path     string
	Staged   bool
}

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"
)

type MutationOptions added in v0.31.109

type MutationOptions struct {
	StartDir string
	Action   MutationAction
	Path     string
	Branch   string
	Message  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"`
	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"`
}

Jump to

Keyboard shortcuts

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