Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

add options force to push #52

Merged
merged 1 commit into from
May 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down