git

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectGit

func DetectGit(path string) (string, error)

DetectGit determines if a given path or any of its parents has a .git directory.

Types

type Commit

type Commit struct {
	Hash      string
	Author    Signature
	Committer Signature
	Message   string
	Parents   []string
}

Commit represents a Git commit.

func (Commit) After

func (c Commit) After(d Commit) bool

After determines if a given commit is chronologically after another commit.

func (Commit) Before

func (c Commit) Before(d Commit) bool

Before determines if a given commit is chronologically before another commit.

func (Commit) Equal

func (c Commit) Equal(d Commit) bool

Equal determines if two commits are the same. Two commits are the same if they both have the same hash.

func (Commit) ShortMessage

func (c Commit) ShortMessage() string

ShortMessage returns a one-line truncated commit message.

func (Commit) String

func (c Commit) String() string

func (Commit) Text

func (c Commit) Text() string

Text returns a multi-line commit string.

type Commits

type Commits []Commit

Commits is a map of Git commits.

type Git

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

Git provides Git functionalities.

func Open

func Open(path string) (*Git, error)

Open creates a new Git service for an existing git repository.

func (*Git) CommitsIn

func (g *Git) CommitsIn(rev string) (Commits, error)

CommitsIn returns all commits reachable from a revision.

func (*Git) Path

func (g *Git) Path() (string, error)

Path returns the root path of the Git repository.

func (*Git) Remote

func (g *Git) Remote(name string) (string, string, error)

Remote returns the domain part and path part of a Git remote repository URL. It assumes the remote repository is named origin.

func (*Git) Tags

func (g *Git) Tags() (Tags, error)

Tags returns the list of all tags.

type Signature

type Signature struct {
	Name  string
	Email string
	Time  time.Time
}

Signature determines who and when created a commit or tag.

func (Signature) After

func (s Signature) After(t Signature) bool

After determines if a given signature is chronologically after another signature.

func (Signature) Before

func (s Signature) Before(t Signature) bool

Before determines if a given signature is chronologically before another signature.

func (Signature) String

func (s Signature) String() string

type Tag

type Tag struct {
	Type    TagType
	Hash    string
	Name    string
	Tagger  *Signature
	Message *string
	Commit  Commit
}

Tag represents a Git tag.

func (Tag) After

func (t Tag) After(u Tag) bool

After determines if a given tag is chronologically after another tag. Two tags are compared using the commits they refer to.

func (Tag) Before

func (t Tag) Before(u Tag) bool

Before determines if a given tag is chronologically before another tag. Two tags are compared using the commits they refer to.

func (Tag) Equal

func (t Tag) Equal(u Tag) bool

Equal determines if two tags are the same. Two tags are the same if they both have the same name.

func (Tag) IsZero

func (t Tag) IsZero() bool

IsZero determines if a tag is a zero tag instance.

func (Tag) String

func (t Tag) String() string

type TagType

type TagType int

TagType determines type a Git tag.

const (
	// Lightweight is a lightweight Git tag.
	Lightweight TagType = iota
	// Annotated is an annotated Git tag.
	Annotated
)

func (TagType) String

func (t TagType) String() string

type Tags

type Tags []Tag

Tags is a list of Git tags.

func (Tags) First

func (t Tags) First(f func(Tag) bool) (Tag, bool)

First returns the first tag that satisifies the given predicate. If you pass a nil function, the first tag will be returned.

func (Tags) Last

func (t Tags) Last(f func(Tag) bool) (Tag, bool)

Last returns the last tag that satisifies the given predicate. If you pass a nil function, the last tag will be returned.

func (Tags) Select

func (t Tags) Select(f func(Tag) bool) (Tags, Tags)

Select partitions a list of tags by a given predicate. The first return value is the collection of selected tags (satisfying the predicate). The second return value is the collection of unselected tags (not satisfying the predicate).

Jump to

Keyboard shortcuts

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