aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/error.go')
-rw-r--r--modules/git/error.go40
1 files changed, 9 insertions, 31 deletions
diff --git a/modules/git/error.go b/modules/git/error.go
index 91d25eca69..10fb37be07 100644
--- a/modules/git/error.go
+++ b/modules/git/error.go
@@ -4,28 +4,14 @@
package git
import (
+ "context"
+ "errors"
"fmt"
"strings"
- "time"
"code.gitea.io/gitea/modules/util"
)
-// ErrExecTimeout error when exec timed out
-type ErrExecTimeout struct {
- Duration time.Duration
-}
-
-// IsErrExecTimeout if some error is ErrExecTimeout
-func IsErrExecTimeout(err error) bool {
- _, ok := err.(ErrExecTimeout)
- return ok
-}
-
-func (err ErrExecTimeout) Error() string {
- return fmt.Sprintf("execution is timeout [duration: %v]", err.Duration)
-}
-
// ErrNotExist commit not exist error
type ErrNotExist struct {
ID string
@@ -62,21 +48,6 @@ func IsErrBadLink(err error) bool {
return ok
}
-// ErrUnsupportedVersion error when required git version not matched
-type ErrUnsupportedVersion struct {
- Required string
-}
-
-// IsErrUnsupportedVersion if some error is ErrUnsupportedVersion
-func IsErrUnsupportedVersion(err error) bool {
- _, ok := err.(ErrUnsupportedVersion)
- return ok
-}
-
-func (err ErrUnsupportedVersion) Error() string {
- return fmt.Sprintf("Operation requires higher version [required: %s]", err.Required)
-}
-
// ErrBranchNotExist represents a "BranchNotExist" kind of error.
type ErrBranchNotExist struct {
Name string
@@ -185,3 +156,10 @@ func IsErrMoreThanOne(err error) bool {
func (err *ErrMoreThanOne) Error() string {
return fmt.Sprintf("ErrMoreThanOne Error: %v: %s\n%s", err.Err, err.StdErr, err.StdOut)
}
+
+func IsErrCanceledOrKilled(err error) bool {
+ // When "cancel()" a git command's context, the returned error of "Run()" could be one of them:
+ // - context.Canceled
+ // - *exec.ExitError: "signal: killed"
+ return err != nil && (errors.Is(err, context.Canceled) || err.Error() == "signal: killed")
+}