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

Commit f0a094c

Browse files
authored
add options force to push (#52)
1 parent 826198d commit f0a094c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

repo.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,21 @@ func Pull(repoPath string, opts PullRemoteOptions) error {
153153
return err
154154
}
155155

156+
// PushOptions options when push to remote
157+
type PushOptions struct {
158+
Remote string
159+
Branch string
160+
Force bool
161+
}
162+
156163
// Push pushs local commits to given remote branch.
157-
func Push(repoPath, remote, branch string) error {
158-
_, err := NewCommand("push", remote, branch).RunInDir(repoPath)
164+
func Push(repoPath string, opts PushOptions) error {
165+
cmd := NewCommand("push")
166+
if opts.Force {
167+
cmd.AddArguments("-f")
168+
}
169+
cmd.AddArguments(opts.Remote, opts.Branch)
170+
_, err := cmd.RunInDir(repoPath)
159171
return err
160172
}
161173

0 commit comments

Comments
 (0)