git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Init

func Init(dir string, options ...Option) (*Client, error)

func Open

func Open(dir string, options ...Option) (*Client, error)

func (*Client) Add

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

func (*Client) Commit

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

func (*Client) Config

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

func (*Client) DirtyFiles

func (c *Client) DirtyFiles(excludePatterns ...string) ([]string, error)

DirtyFiles returns a list of files that have been modified in any way, including: new (untracked), contents changed, deleted, renamed, copied, unmerged, whether the changes have been staged or not. It also includes files that are ignored by the standard ignore files. The list is sorted using strings.Sort.

func (*Client) GetRemoteNamed

func (c *Client) GetRemoteNamed(name string) (*config.RemoteConfig, error)

func (*Client) HeadCommit

func (c *Client) HeadCommit() (Commit, error)

func (*Client) Log

func (c *Client) Log(n int) ([]Commit, error)

func (*Client) RepoRelativeDir

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

func (*Client) RootDir

func (c *Client) RootDir() string

func (*Client) WorkDir

func (c *Client) WorkDir() string

func (*Client) WorktreeState

func (c *Client) WorktreeState(opts ...WorktreeStateOption) (WorktreeState, error)

SourceInfo returns the SourceInfo of the repo.

type ClientOptions

type ClientOptions struct {
	// contains filtered or unexported fields
}

type Commit

type Commit struct {
	ID          string
	AuthorName  string
	AuthorEmail string
	AuthorTime  time.Time
	Message     string
	Date        time.Time
}

type Config

type Config = config.Config

type Option

type Option func(*ClientOptions)

func WithAuthor

func WithAuthor(name, email string) Option

type WorktreeState

type WorktreeState struct {
	Head Commit
	// SourceHash is the SHA1 Git Commit ID of Head if the worktree is not dirty.
	// Otherwise it's a SHA1 hash of the head commit along with the full
	// contents of all changed files.
	// SHA1 is used for both so that you get a consistent 40 char hex string.
	SourceHash string
	// DirtyFiles is a list of all files flagged as dirty in the worktree.
	DirtyFiles []string
}

func (WorktreeState) IsDirty

func (ws WorktreeState) IsDirty() bool

IsDirty returns true if the source hash isn't exactly the same as the head commit ID.

type WorktreeStateConfig

type WorktreeStateConfig struct {
	// contains filtered or unexported fields
}

type WorktreeStateOption

type WorktreeStateOption func(*WorktreeStateConfig)

func WorktreeStateIgnorePatterns

func WorktreeStateIgnorePatterns(patterns ...string) WorktreeStateOption

Jump to

Keyboard shortcuts

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