git

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 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 Checkout

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

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

Example
cmdExecutor = cmdExecutorMock

out, _ := Checkout(checkout.NewBranch, checkout.Branch("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 Cond

func Cond(apply bool, option types.Option) func(*types.Cmd)

Cond apply conditionally an option

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 Debuggger

func Debuggger(debug bool) func(*types.Cmd)

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 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 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, remote.Name("upstream"), remote.URL("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

Types

This section is empty.

Jump to

Keyboard shortcuts

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