0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-24 19:06:22 +02:00

Support ForceWithLease push option

This commit is contained in:
Lunny Xiao 2025-11-13 18:04:18 -08:00 committed by Michal Suchanek
parent c287a8cdb5
commit 124d0d4ec4

View File

@ -186,18 +186,21 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error {
// PushOptions options when push to remote // PushOptions options when push to remote
type PushOptions struct { type PushOptions struct {
Remote string Remote string
Branch string Branch string
Force bool Force bool
Mirror bool ForceWithLease string
Env []string Mirror bool
Timeout time.Duration Env []string
Timeout time.Duration
} }
// Push pushs local commits to given remote branch. // Push pushs local commits to given remote branch.
func Push(ctx context.Context, repoPath string, opts PushOptions) error { func Push(ctx context.Context, repoPath string, opts PushOptions) error {
cmd := gitcmd.NewCommand("push") cmd := gitcmd.NewCommand("push")
if opts.Force { if opts.ForceWithLease != "" {
cmd.AddOptionFormat("--force-with-lease=%s", opts.ForceWithLease)
} else if opts.Force {
cmd.AddArguments("-f") cmd.AddArguments("-f")
} }
if opts.Mirror { if opts.Mirror {