git

package module
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 9 Imported by: 0

README

Git

Build Status

Helper functions for Git in use across Commitsar and Release Notary

Documentation

Overview

Package history 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 {

	// DebugLogger flag is passed to make debugging easier during development/problematic deploys
	DebugLogger *log.Logger
	// contains filtered or unexported fields
}

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

func OpenGit

func OpenGit(path string, debugLogger *log.Logger) (*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 added in v2.3.0

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.

type SimpleCommit added in v2.3.0

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

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