git

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: Apache-2.0 Imports: 4 Imported by: 14

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Branch added in v0.6.0

func Branch(options ...types.Option) (string, error)

Branch https://git-scm.com/docs/git-branch

Example
cmdExecutor = cmdExecutorMock

out, _ := Branch(branch.DeleteForce, branch.BranchName("myBranch"))

fmt.Println(out)
Output:

git branch -D myBranch

func Checkout

func Checkout(options ...types.Option) (string, error)

Checkout https://git-scm.com/docs/git-checkout

Example
cmdExecutor = cmdExecutorMock

out, _ := Checkout(checkout.NewBranch("myBranchName"))

fmt.Println(out)
Output:

git checkout -b myBranchName

func Clone

func Clone(options ...types.Option) (string, error)

Clone https://git-scm.com/docs/git-clone

Example
cmdExecutor = cmdExecutorMock

out, _ := Clone(clone.Repository("git@github.com:ldez/go-git-cmd-wrapper.git"))

fmt.Println(out)
Output:

git clone git@github.com:ldez/go-git-cmd-wrapper.git

func Commit added in v0.16.0

func Commit(options ...types.Option) (string, error)

Commit https://git-scm.com/docs/git-commit

Example
cmdExecutor = cmdExecutorMock

out, _ := Commit(commit.Amend, commit.Message("chore: foo"))

fmt.Println(out)
Output:

git commit --amend --message="chore: foo"

func Cond

func Cond(apply bool, options ...types.Option) types.Option

Cond apply conditionally some options

Example
cmdExecutor = cmdExecutorMock

param := false
out, _ := Push(push.All, Cond(param, push.DryRun), push.FollowTags, push.ReceivePack("aaa"))

fmt.Print(out)

param = true
out, _ = Push(push.All, Cond(param, push.DryRun), push.FollowTags, push.ReceivePack("aaa"))

fmt.Print(out)
Output:

git push --all --follow-tags --receive-pack=aaa
git push --all --dry-run --follow-tags --receive-pack=aaa

func Config

func Config(options ...types.Option) (string, error)

Config https://git-scm.com/docs/git-config

Example
cmdExecutor = cmdExecutorMock

out, _ := Config(config.Entry("rebase.autoSquash", "true"))

fmt.Println(out)
Output:

git config rebase.autoSquash true

func Debug

func Debug(g *types.Cmd)

Debug display command line

func Debugger added in v0.4.1

func Debugger(debug bool) types.Option

DebugBool display command line

func Fetch

func Fetch(options ...types.Option) (string, error)

Fetch https://git-scm.com/docs/git-fetch

Example
cmdExecutor = cmdExecutorMock

out, _ := Fetch(fetch.NoTags, fetch.Remote("upstream"), fetch.RefSpec("myBranchName"))

fmt.Println(out)
Output:

git fetch --no-tags upstream myBranchName

func Init

func Init(options ...types.Option) (string, error)

Init https://git-scm.com/docs/git-init

Example
cmdExecutor = cmdExecutorMock

out, _ := Init(ginit.Bare, ginit.Quiet, ginit.Directory("foobar"))

fmt.Println(out)
Output:

git init --bare --quiet foobar

func NoOp

func NoOp(g *types.Cmd)

NoOp do nothing.

func Pull added in v0.11.0

func Pull(options ...types.Option) (string, error)

Pull https://git-scm.com/docs/git-pull

Example
cmdExecutor = cmdExecutorMock

out, _ := Pull(pull.All, pull.Force, pull.Repository("upstream"), pull.Refspec("master"))

fmt.Println(out)
Output:

git pull --all --force upstream master

func Push

func Push(options ...types.Option) (string, error)

Push https://git-scm.com/docs/git-push

Example
cmdExecutor = cmdExecutorMock

out, _ := Push(push.All, push.FollowTags, push.ReceivePack("aaa"))

fmt.Println(out)
Output:

git push --all --follow-tags --receive-pack=aaa

func Raw added in v0.9.0

func Raw(cmd string, options ...types.Option) (string, error)

Raw use to execute arbitrary commands.

func Rebase

func Rebase(options ...types.Option) (string, error)

Rebase https://git-scm.com/docs/git-rebase

Example
cmdExecutor = cmdExecutorMock

out, _ := Rebase(rebase.PreserveMerges, rebase.Branch(fmt.Sprintf("%s/%s", "upstream", "master")))

fmt.Println(out)
Output:

git rebase --preserve-merges upstream/master

func Remote

func Remote(options ...types.Option) (string, error)

Remote https://git-scm.com/docs/git-remote

Example
cmdExecutor = cmdExecutorMock

out, _ := Remote(remote.Add("upstream", "git@github.com:johndoe/go-git-cmd-wrapper.git"))

fmt.Println(out)
Output:

git remote add upstream git@github.com:johndoe/go-git-cmd-wrapper.git

func Reset added in v0.16.0

func Reset(options ...types.Option) (string, error)

Reset https://git-scm.com/docs/git-reset

Example
cmdExecutor = cmdExecutorMock

out, _ := Reset(reset.Soft, reset.Commit("e41f083"))

fmt.Println(out)
Output:

git reset --soft e41f083

func RevParse added in v0.9.0

func RevParse(options ...types.Option) (string, error)

RevParse https://git-scm.com/docs/git-rev-parse

Example
cmdExecutor = cmdExecutorMock

out, _ := RevParse(revparse.AbbrevRef(""), revparse.Args("HEAD"))

fmt.Println(out)
Output:

git rev-parse --abbrev-ref HEAD

Types

This section is empty.

Jump to

Keyboard shortcuts

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