Skip to content

Commit 124d0d4

Browse files
lunnyhramrach
authored andcommitted
Support ForceWithLease push option
1 parent c287a8c commit 124d0d4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

modules/git/repo.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,21 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error {
186186

187187
// PushOptions options when push to remote
188188
type PushOptions struct {
189-
Remote string
190-
Branch string
191-
Force bool
192-
Mirror bool
193-
Env []string
194-
Timeout time.Duration
189+
Remote string
190+
Branch string
191+
Force bool
192+
ForceWithLease string
193+
Mirror bool
194+
Env []string
195+
Timeout time.Duration
195196
}
196197

197198
// Push pushs local commits to given remote branch.
198199
func Push(ctx context.Context, repoPath string, opts PushOptions) error {
199200
cmd := gitcmd.NewCommand("push")
200-
if opts.Force {
201+
if opts.ForceWithLease != "" {
202+
cmd.AddOptionFormat("--force-with-lease=%s", opts.ForceWithLease)
203+
} else if opts.Force {
201204
cmd.AddArguments("-f")
202205
}
203206
if opts.Mirror {

0 commit comments

Comments
 (0)