mirror of
https://github.com/go-gitea/git.git
synced 2026-02-05 15:45:40 +01:00
add options force to push (#52)
This commit is contained in:
16
repo.go
16
repo.go
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user