git

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Added    = "+"
	Updated  = "*"
	Removed  = "-"
	NoUpdate = ""
)

Variables

View Source
var CreateGit = func(ctx *context.Context) (Manager, error) {
	r, err := git.PlainOpen(ctx.WorkingDir)
	if err != nil {
		return nil, err
	}

	w, err := r.Worktree()

	if err != nil {
		return nil, err
	}

	return Git{r: r, w: w}, nil
}

Functions

func AddFileToStage

func AddFileToStage(m Manager, path string) error

func AddModifiedFilesToStage

func AddModifiedFilesToStage(m Manager) error

func CheckIfFileStaged

func CheckIfFileStaged(m Manager) bool

func GetImagesNameAdded

func GetImagesNameAdded(ctx *context.Context, m Manager) ([]string, error)

func GetImagesNameRemoved

func GetImagesNameRemoved(m Manager) ([]string, error)

func GetStageFilesChanged

func GetStageFilesChanged(m Manager) []string

func HasUntrackedFiles

func HasUntrackedFiles(m Manager) bool

Types

type Git

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

func (Git) AddWithOptions

func (g Git) AddWithOptions(opts *git.AddOptions) error

func (Git) CommitFileContent

func (g Git) CommitFileContent(hash *plumbing.Hash, path string) (string, error)

func (Git) CreateCommit

func (g Git) CreateCommit(msg string, opts *git.CommitOptions) (plumbing.Hash, error)

func (Git) GetCommitFilesChanged

func (g Git) GetCommitFilesChanged(hash string) ([]string, error)

func (Git) ResolveRevision

func (g Git) ResolveRevision(in plumbing.Revision) (*plumbing.Hash, error)

func (Git) Status

func (g Git) Status() (git.Status, error)

type Manager

type Manager interface {
	Status() (git.Status, error)
	ResolveRevision(in plumbing.Revision) (*plumbing.Hash, error)
	CommitFileContent(hash *plumbing.Hash, path string) (string, error)
	AddWithOptions(opts *git.AddOptions) error
	CreateCommit(msg string, opts *git.CommitOptions) (plumbing.Hash, error)
	GetCommitFilesChanged(hash string) ([]string, error)
}

type Repository

type Repository interface {
	Worktree() (*git.Worktree, error)
	ResolveRevision(in plumbing.Revision) (*plumbing.Hash, error)
	CommitObject(h plumbing.Hash) (*object.Commit, error)
	CommitObjects() (object.CommitIter, error)
}

type Worktree

type Worktree interface {
	Status() (git.Status, error)
	AddWithOptions(opts *git.AddOptions) error
	Commit(msg string, opts *git.CommitOptions) (plumbing.Hash, error)
}

Jump to

Keyboard shortcuts

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