git

package
v0.0.0-...-ba4a4a7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UncommittedID      = "0000000000000000000000000000000000000000"
	UncommittedSID     = "000000"
	PartialLogCommitID = "ffffffffffffffffffffffffffffffffffffffff"
)

Variables

View Source
var ErrConflicts = errors.New("merge resulted in conflict(s)")

Functions

func StripRemotePrefix

func StripRemotePrefix(name string) string

func ToSid

func ToSid(commitID string) string

func Version

func Version() string

GitVersion returns the git version

func WorkingTreeRoot

func WorkingTreeRoot(path string) (string, error)

Types

type Branch

type Branch struct {
	Name             string
	DisplayName      string
	TipID            string
	IsCurrent        bool
	IsRemote         bool
	RemoteName       string
	IsDetached       bool
	AheadCount       int
	BehindCount      int
	IsRemoteMissing  bool
	TipCommitMessage string
}

func (*Branch) String

func (t *Branch) String() string

type Branches

type Branches []Branch

func (Branches) MustByName

func (bs Branches) MustByName(name string) Branch

func (Branches) MustCurrent

func (bs Branches) MustCurrent() Branch

type Commit

type Commit struct {
	ID         string
	SID        string
	ParentIDs  []string
	Subject    string
	Message    string
	Author     string
	AuthorTime time.Time
	CommitTime time.Time
}

func (*Commit) String

func (c *Commit) String() string

type CommitDiff

type CommitDiff struct {
	Id        string
	Author    string
	Date      string
	Message   string
	FileDiffs []FileDiff
}

type Commits

type Commits []Commit

func (Commits) MustBySubject

func (cs Commits) MustBySubject(subject string) Commit

func (Commits) String

func (cs Commits) String() string

type DiffMode

type DiffMode int
const (
	DiffModified DiffMode = iota
	DiffAdded
	DiffRemoved
	DiffSame
	DiffConflicts
	DiffConflictStart
	DiffConflictSplit
	DiffConflictEnd
)

type FileDiff

type FileDiff struct {
	PathBefore   string
	PathAfter    string
	IsRenamed    bool
	DiffMode     DiffMode
	SectionDiffs []SectionDiff
}

type Git

type Git interface {
	RepoPath() string
	GetLog() (Commits, error)
	GetLogMax(maxCommitCount int) (Commits, error)
	GetStatus() (Status, error)
	GetBranches() (Branches, error)
	GetFiles(ref string) ([]string, error)

	InitRepo() error
	InitRepoBare() error
	Clone(uri, path string) error
	ConfigUser(name, email string) error

	IsIgnored(path string) bool
	CommitDiff(id string) (CommitDiff, error)
	FileDiff(path string) ([]CommitDiff, error)
	Checkout(name string) error
	Commit(message string) error
	Fetch() error
	PushBranch(name string) error
	CreateBranch(name string) error
	CreateBranchAt(name string, id string) error
	MergeBranch(name string) error
	MergeSquashBranch(name string) error
	DeleteRemoteBranch(name string) error
	DeleteLocalBranch(name string, isForced bool) error
	GetTags() ([]Tag, error)
	PullCurrentBranch() error
	PullBranch(name string) error
	GetKeyValue(key string) (string, error)
	SetKeyValue(key, value string) error
	PushKeyValue(key string) error
	PullKeyValue(key string) error
	UndoCommit(id string) error
	UncommitLastCommit() error
	UndoAllUncommittedChanges() error
	UndoUncommittedFileChanges(path string) error
	CleanWorkingFolder() error
}

func New

func New(path string) Git

func NewWithCmd

func NewWithCmd(cmd gitCommander) Git

type LinesDiff

type LinesDiff struct {
	DiffMode DiffMode
	Line     string
}

type SectionDiff

type SectionDiff struct {
	ChangedIndexes string
	LeftLine       int
	LeftCount      int
	RightLine      int
	RightCount     int
	LinesDiffs     []LinesDiff
}

type Status

type Status struct {
	Modified       int
	Added          int
	Deleted        int
	Conflicted     int
	IsMerging      bool
	MergeMessage   string
	AddedFiles     []string
	ConflictsFiles []string
}

func (*Status) String

func (t *Status) String() string

type Tag

type Tag struct {
	CommitID string
	TagName  string
}

Jump to

Keyboard shortcuts

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