1
0
mirror of https://github.com/go-gitea/git.git synced 2026-02-05 06:45:03 +01:00

add options force to push (#52)

This commit is contained in:
Lunny Xiao
2017-05-23 09:47:37 +08:00
committed by GitHub
parent 826198d004
commit f0a094c4f9

16
repo.go
View File

@@ -153,9 +153,21 @@ func Pull(repoPath string, opts PullRemoteOptions) error {
return err
}
// PushOptions options when push to remote
type PushOptions struct {
Remote string
Branch string
Force bool
}
// Push pushs local commits to given remote branch.
func Push(repoPath, remote, branch string) error {
_, err := NewCommand("push", remote, branch).RunInDir(repoPath)
func Push(repoPath string, opts PushOptions) error {
cmd := NewCommand("push")
if opts.Force {
cmd.AddArguments("-f")
}
cmd.AddArguments(opts.Remote, opts.Branch)
_, err := cmd.RunInDir(repoPath)
return err
}