From 124d0d4ec45e57b269d32fc3d92069413b4294c0 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 13 Nov 2025 18:04:18 -0800 Subject: [PATCH] Support ForceWithLease push option --- modules/git/repo.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/git/repo.go b/modules/git/repo.go index 7e86b10de9..88acbd30e6 100644 --- a/modules/git/repo.go +++ b/modules/git/repo.go @@ -186,18 +186,21 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error { // PushOptions options when push to remote type PushOptions struct { - Remote string - Branch string - Force bool - Mirror bool - Env []string - Timeout time.Duration + Remote string + Branch string + Force bool + ForceWithLease string + Mirror bool + Env []string + Timeout time.Duration } // Push pushs local commits to given remote branch. func Push(ctx context.Context, repoPath string, opts PushOptions) error { 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") } if opts.Mirror {