Documentation
¶
Index ¶
- func Branch(options ...types.Option) (string, error)
- func Checkout(options ...types.Option) (string, error)
- func Clone(options ...types.Option) (string, error)
- func Commit(options ...types.Option) (string, error)
- func Cond(apply bool, options ...types.Option) types.Option
- func Config(options ...types.Option) (string, error)
- func Debug(g *types.Cmd)
- func Debugger(debug bool) types.Option
- func Fetch(options ...types.Option) (string, error)
- func Init(options ...types.Option) (string, error)
- func NoOp(g *types.Cmd)
- func Pull(options ...types.Option) (string, error)
- func Push(options ...types.Option) (string, error)
- func Raw(cmd string, options ...types.Option) (string, error)
- func Rebase(options ...types.Option) (string, error)
- func Remote(options ...types.Option) (string, error)
- func Reset(options ...types.Option) (string, error)
- func RevParse(options ...types.Option) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Branch ¶ added in v0.6.0
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 ¶
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 ¶
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
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 ¶
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 ¶
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 Fetch ¶
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 ¶
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 Pull ¶ added in v0.11.0
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 ¶
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 ¶
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 ¶
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
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
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.