Skip to content

Commit 078cfad

Browse files
committed
Add a check for when the command is canceled by the program on Windows OS.
1 parent 9043584 commit 078cfad

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/git/command.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"io"
1313
"os"
1414
"os/exec"
15+
"runtime"
1516
"strings"
1617
"time"
1718

@@ -344,6 +345,17 @@ func (c *Command) Run(opts *RunOpts) error {
344345
log.Debug("slow git.Command.Run: %s (%s)", c, elapsed)
345346
}
346347

348+
// We need to check if the context is canceled by the program on Windows.
349+
// This is because Windows does not have signal checking when terminating the process.
350+
// It always returns exit code 1, unlike Linux, which has many exit codes for signals.
351+
if runtime.GOOS == "windows" &&
352+
err != nil &&
353+
err.Error() == "" &&
354+
cmd.ProcessState.ExitCode() == 1 &&
355+
ctx.Err() == context.Canceled {
356+
return ctx.Err()
357+
}
358+
347359
if err != nil && ctx.Err() != context.DeadlineExceeded {
348360
return err
349361
}

0 commit comments

Comments
 (0)