git

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch interface {
	// Checkout a new branch with the specified name
	Checkout(name string) error
	// Current returns the name of the current branch
	Current() (string, error)
	// ValidateName checks if a given name is a potentially valid branch name
	ValidateName(name string) error
}

Branch is the interface to abstract git branch handling

func NewBranch

func NewBranch(gitObj Git) Branch

NewBranch returns an instance of Branch interface with default values

type CommandError

type CommandError struct {
	Err error
	// The actually executed OS command
	Cmd *exec.Cmd
	// Human readable string of the command output
	Output string
}

CommandError in case a git command execution fails

func NewCommandError

func NewCommandError(err error, cmd *exec.Cmd, cmdOutput []byte) *CommandError

NewCommandError returns an new instance of CommandError with specified values

func (CommandError) Error

func (err CommandError) Error() string

Error returns the actual error message

type Commit

type Commit interface {
	// New creates a new git commit with the specified message
	New(message string) error
	// LogsBetweenVersions returns a log between two commit versions
	// If used with empty strings as versionA and B it returns the full current log
	LogsBetweenVersions(versionA, versionB string) ([]CommitLog, error)
}

Commit is the interface to abstract git commit handling

func NewCommit

func NewCommit(gitObj Git) Commit

NewCommit returns an instance of Commit interface with default values

type CommitLog

type CommitLog struct {
	// Author (name) of the commit
	Author string
	// AuthorEmail of the commit
	AuthorEmail string
	// Hash to identify the commit
	Hash string
	// Message of the commit
	Message   string
	Timestamp string
}

CommitLog is the data structure for a log of a git commit

type Git

type Git interface {
	ExecCommand(args []string) (string, int, error)
}

Git is the git package interface to abstract git command executions

func New

func New(executable string) Git

New returns a new pointer instance of Git interface with specified 'git' executable

type InvalidBranchNameError

type InvalidBranchNameError struct {
	Err  error
	Name string
}

InvalidBranchNameError is returned if a branch has a invalid name

func NewInvalidBranchNameError

func NewInvalidBranchNameError(err error, name string) *InvalidBranchNameError

NewInvalidBranchNameError returns an new instance of InvalidBranchNameError

func (InvalidBranchNameError) Error

func (err InvalidBranchNameError) Error() string

Error returns the actual error message

type Remote

type Remote interface {
	// GetHttpURL returns the URL of the given remote name in HTTP(S) format
	GetHttpURL(name string) (string, error)
	// GetProject returns the project part of the remote remote URL
	GetProject(name string) (string, error)
	// GetProjectByHttpURL extracts the project name of a given repo HTTP url
	GetProjectByHttpURL(httpURL string) (string, error)
	// GetURL returns the URL of the given remote name
	GetURL(name string) (*url.URL, error)
}

Remote is the interface to manage git remotes

func NewRemote

func NewRemote(gitObj Git) Remote

NewRemote returns an instance of Remote interface with default values

type Tag

type Tag interface {
	// GenerateNew a new tag or use the backupTag if no tag exists yet
	GenerateNew(backupTag string) (string, error)
	// Latest tag
	Latest() (string, error)
	// List all available git tags accross all branches sorted by date commited
	List() (TagList, error)
}

func NewTag

func NewTag(gitObj Git) Tag

NewTag returns an new instance of Tag interface with default values

type TagList

type TagList []string

TagList is a list of git tags

func (TagList) GenerateNew

func (tl TagList) GenerateNew() (string, error)

func (TagList) Includes

func (tl TagList) Includes(element string) bool

Includes the specified element

func (TagList) Latest

func (tl TagList) Latest() string

Latest entry of the list

Jump to

Keyboard shortcuts

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