git

package
v0.0.0-...-f286f3f Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoration

type Decoration struct {
	Name string
	Type string // "head", "branch" or "tag"
}

Decoration is a ref label (HEAD, branch, tag) attached to a commit.

type Diff

type Diff struct {
	Name struct {
		Old string
		New string
	}
	TextFragments []TextFragment
	IsBinary      bool
	IsNew         bool
	IsDelete      bool
}

type GitRepo

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

func Open

func Open(path string, ref string) (*GitRepo, error)

func (*GitRepo) Branches

func (g *GitRepo) Branches() ([]*plumbing.Reference, error)

func (*GitRepo) Commits

func (g *GitRepo) Commits() ([]*object.Commit, error)

func (*GitRepo) Decorations

func (g *GitRepo) Decorations() map[string][]Decoration

Decorations maps commit hashes to the refs pointing at them.

func (*GitRepo) Diff

func (g *GitRepo) Diff() (*NiceDiff, error)

func (*GitRepo) FileContent

func (g *GitRepo) FileContent(path string) (string, error)

func (*GitRepo) FileContentBytes

func (g *GitRepo) FileContentBytes(path string) ([]byte, error)

FileContentBytes returns the raw bytes of a blob, including binary files (unlike FileContent, which substitutes a placeholder).

func (*GitRepo) FileTree

func (g *GitRepo) FileTree(path string) ([]NiceTree, error)

func (*GitRepo) FindMainBranch

func (g *GitRepo) FindMainBranch(branches []string) (string, error)

func (*GitRepo) LastCommit

func (g *GitRepo) LastCommit() (*object.Commit, error)

func (*GitRepo) Tags

func (g *GitRepo) Tags() ([]*TagReference, error)

func (*GitRepo) WriteTar

func (g *GitRepo) WriteTar(w io.Writer, prefix string) error

WriteTar writes itself from a tree into a binary tar file format. prefix is root folder to be appended.

type NiceDiff

type NiceDiff struct {
	Commit struct {
		Message string
		Author  object.Signature
		This    string
		Parent  string
	}
	Stat struct {
		FilesChanged int
		Insertions   int
		Deletions    int
	}
	Diff []Diff
}

A nicer git diff representation.

type NiceTree

type NiceTree struct {
	Name      string
	Mode      string
	Size      int64
	IsFile    bool
	IsSubtree bool
}

A nicer git tree representation.

type TagList

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

func (*TagList) Len

func (self *TagList) Len() int

func (*TagList) Less

func (self *TagList) Less(i, j int) bool

sorting tags in reverse chronological order

func (*TagList) Swap

func (self *TagList) Swap(i, j int)

type TagReference

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

TagReference is used to list both tag and non-annotated tags. Non-annotated tags should only contains a reference. Annotated tags should contain its reference and its tag information.

func (*TagReference) Message

func (t *TagReference) Message() string

func (*TagReference) Name

func (t *TagReference) Name() string

type TextFragment

type TextFragment struct {
	Header string
	Lines  []gitdiff.Line
}

Jump to

Keyboard shortcuts

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