git

package
v0.0.0-...-e5f8d4b Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

type Git struct {
	WorkingDir string
}

func (*Git) AddAlias

func (git *Git) AddAlias(alias, command string) error

AddAlias adds a global alias to git config `git config --global alias.<alias> 'command'

func (*Git) Checkout

func (git *Git) Checkout(branch string) error

Checkout checks out a <branch> `git checkout <branch>`

func (*Git) Cherry

func (git *Git) Cherry() ([]string, error)

Cherry returns the diff from branch and upstream `git cherry -v`

func (*Git) CurrentBranch

func (git *Git) CurrentBranch() (string, error)

CurrentBranch returns the name of the current checked out branch `git branch --show-current`

func (*Git) Exec

func (git *Git) Exec(arg ...string) (string, error)

Exec runs a git command with the passed args

func (*Git) Exec2

func (git *Git) Exec2(arg ...string) (Output, error)

func (*Git) ExecSilent

func (git *Git) ExecSilent(arg ...string) error

ExecSilent runs a git command with the passed args and ignores the output

func (*Git) FindMainBranch

func (git *Git) FindMainBranch() (string, error)

FindMainBranch returns the name of the main branch

right now it only looks if either `main` or `master` exist I can later add more generic code to figure out the default branch if it was neither `master` nor `main`

func (*Git) ListBranches

func (git *Git) ListBranches() ([]string, error)

ListBranches returns the names of local branches `git branch --format=%(refname:short)`

func (*Git) Rebase

func (git *Git) Rebase(base, target string) error

Rebase the target branch on top of base branch `git rebase <base> <target>` note that after running `git rebase <base> <target>` the checked out branch becomes <target> so we have to check out the current branch again at the end

TODO: handle failures in rebase --abort

type Output

type Output struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

func Exec

func Exec(arg ...string) (Output, error)

Exec executes a git command within a working directory wd It returns both stdout, and stderr along with an error type Note that git sometimes uses stderr even though process exits with 0

func (*Output) StdoutLines

func (o *Output) StdoutLines() []string

func (*Output) TrimmedStdout

func (o *Output) TrimmedStdout() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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