git

package module
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 8 Imported by: 1

README

Git

Build Status

Helper functions for Git in use across Commitsar and Release Notary

Documentation

Overview

Package git is a wrapper for Git actions. The main purpose is the unify some functionality in this package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCommitNotOnTag is returned by CurrentTag if the commit is not on a tag
	ErrCommitNotOnTag = errors.New("current commit is not on a tag")
)
View Source
var ErrCommonCommitFound = errors.New("common commit found")

ErrCommonCommitFound is used for identifying when the iterator has reached the common commit

View Source
var (
	// ErrPrevTagNotAvailable is returned when no previous tag is found.
	ErrPrevTagNotAvailable = errors.New("previous tag is not available")
)

Functions

This section is empty.

Types

type Git

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

Git is the struct used to house all methods in use in Commitsar.

func OpenGit

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

OpenGit loads Repo on path and returns a new Git struct to work with.

func (*Git) BranchDiffCommits

func (g *Git) BranchDiffCommits(branchA string, branchB string) ([]plumbing.Hash, error)

BranchDiffCommits compares commits from 2 branches and returns of a diff of them.

func (*Git) Commit

func (g *Git) Commit(hash plumbing.Hash) (*object.Commit, error)

Commit find a commit based on commit hash and returns the Commit object

func (*Git) CommitsBetween

func (g *Git) CommitsBetween(from plumbing.Hash, to plumbing.Hash) ([]plumbing.Hash, error)

CommitsBetween returns a slice of commit hashes between two commits

func (*Git) CommitsOnBranch

func (g *Git) CommitsOnBranch(
	branchCommit plumbing.Hash,
) ([]plumbing.Hash, error)

CommitsOnBranch iterates through all references and returns commit hashes on given branch. \n Important to note is that this will provide all commits from anything the branch is connected to.

func (*Git) CommitsOnBranchSimple

func (g *Git) CommitsOnBranchSimple(
	branchCommit plumbing.Hash,
) ([]SimpleCommit, error)

CommitsOnBranchSimple iterates through all references and returns simpleCommits on given branch. \n Important to note is that this will provide all commits from anything the branch is connected to.

func (*Git) CurrentBranch

func (g *Git) CurrentBranch() (*plumbing.Reference, error)

CurrentBranch returns the reference HEAD is at right now

func (*Git) CurrentCommit

func (g *Git) CurrentCommit() (*object.Commit, error)

CurrentCommit returns the commit that HEAD is at

func (*Git) CurrentTag

func (g *Git) CurrentTag() (*Tag, error)

CurrentTag returns a Tag if the current HEAD is on a tag

func (*Git) LatestCommitOnBranch

func (g *Git) LatestCommitOnBranch(desiredBranch string) (*object.Commit, error)

LatestCommitOnBranch resolves a revision and then returns the latest commit on it.

func (*Git) PreviousTag

func (g *Git) PreviousTag(currentHash plumbing.Hash) (*Tag, error)

PreviousTag sorts tags based on when their commit happened and returns the one previous to the current.

func (*Git) Tags added in v3.1.0

func (g *Git) Tags() ([]*Tag, error)

type SimpleCommit

type SimpleCommit struct {
	Hash    [20]byte
	Message string
}

SimpleCommit is a slimed down commit object of just Hash and Message

type Tag

type Tag struct {
	Name string
	Hash plumbing.Hash
	Date time.Time
}

Tag houses some common info about tags.

Jump to

Keyboard shortcuts

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