git

package module
v0.0.0-...-277ae46 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(paths ...string) error

Add does a `git add`

func Amend

func Amend() error

Amend runs `git commit --amend` to amend the details of the last commit. It binds to the terminal so that in-terminal editors like vim can be used "normally"

func AmendNoEdit

func AmendNoEdit() error

Amend runs `git commit --amend --no-edit` to amend the details of the last commit

func AmendWithMessage

func AmendWithMessage(message string) error

AmendWithMessage runs `git commit --amend -m <message>`

func AppendNotes

func AppendNotes(object, note string) error

AppendNote appends the supplied note to any existing notes associated with the specified object.

func ApplyPatch

func ApplyPatch(r io.Reader) error

ApplyPatch applies the patch in buf to the working tree but doesn't add or commit it.

func BranchExists

func BranchExists(name string) bool

BranchExists returns whether or not the specified branch name exists

func Checkout

func Checkout(ref string) error

Checkout the specified ref

func Commit

func Commit(message string) error

Commit triggers a commit, bringing up the default editor with the specified message

func CreateAndSwitchToBranch

func CreateAndSwitchToBranch(branchName string) error

CreateAndSwitchToBranch creates a new branch and switches to it (`git checkout -b`)

func CreateBranch

func CreateBranch(branchName string) error

CreateBranch creates a branch at HEAD but doesn't switch to it

func CreateBranchForced

func CreateBranchForced(branchName, ref string) error

CreateBranchForced creates a branch at ref but doesn't switch to it.

func Diff

func Diff(ref1, ref2 string) (buf *bytes.Buffer, err error)

Diff shows the diff/patch between two specific commits. If it succeeds, buf contains the patch and err is nil. If it fails, buf contains the error output and err contains the error returned from Run()

func ForceAddNotes

func ForceAddNotes(object, note string) error

ForceAddNote replaces the note associated with the specified object.

func ForceDeleteBranch

func ForceDeleteBranch(branchName string) error

ForceDeleteBranch force-deletes the specified branch

func ForcePushBranch

func ForcePushBranch(branch string) error

ForcePushBranch pushes a branch to its default remote without switching to it.

func FormatShowRefDescription

func FormatShowRefDescription(ref, format string) (s string, err error)

ShowRefDescription gets the description for the specified commit ref. If it succeeds, s contains the description and err is nil. If it fails, s contains the error output and err contains the error returned from Run().

func GetCurrentBranchName

func GetCurrentBranchName() (name string, err error)

GetCurrentBranchName gets the current branch name

func GetForkPoint

func GetForkPoint(ref string, arg ...string) (string, error)

GetForkPoint returns the common ancestor commit of the specified refs

func GetPushRemoteForBranch

func GetPushRemoteForBranch(branch string) (string, error)

GetPushRemoteForBranch gets the name for the default push remote for the specified branch

func Git

func Git(arg ...string) error

func GitOutput

func GitOutput(arg ...string) (string, error)

func HasChanges

func HasChanges() (bool, error)

HasChanges returns true if there are changes that have not been committed in the working tree

func IsAncestor

func IsAncestor(ref1, ref2 string) (bool, error)

IsAncestor returns if the first ref is an ancestor of the second

func IsDifferent

func IsDifferent(ref1, ref2 string) (bool, error)

func Log

func Log(arg ...string) (string, error)

Log returns a log as per the provided arguments

func Push

func Push() error

Push does a `git push`

func PushAndSetUpstream

func PushAndSetUpstream(remote, branch string) error

PushAndSetUpstream sets the remote tracking branch and pushes

func PushBranch

func PushBranch(branch string) error

PushBranch pushes a branch to its default remote without switching to it.

func Rebase

func Rebase(base, topic string) error

Rebase does a `git rebase`

func RevParse

func RevParse(ref string) (string, error)

RevParse gets the hash for a ref

func ShowNotes

func ShowNotes(object string) (string, error)

ShowNotes shows the notes associated with the specified object

Types

type Cmd

type Cmd struct {
	*exec.Cmd
}

func GitCmd

func GitCmd(arg ...string) *Cmd

func (*Cmd) FormatOutput

func (cmd *Cmd) FormatOutput(output []byte, err error) (string, error)

Jump to

Keyboard shortcuts

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