mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-17 17:08:38 +00:00
Refactor git command context & pipeline (#36406)
Less and simpler code, fewer bugs
This commit is contained in:
28
modules/git/gitcmd/context.go
Normal file
28
modules/git/gitcmd/context.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package gitcmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Context interface {
|
||||
context.Context
|
||||
|
||||
// CancelWithCause is a helper function to cancel the context with a specific error cause
|
||||
// And it returns the same error for convenience, to break the PipelineFunc easily
|
||||
CancelWithCause(err error) error
|
||||
|
||||
// In the future, this interface will be extended to support stdio pipe readers/writers
|
||||
}
|
||||
|
||||
type cmdContext struct {
|
||||
context.Context
|
||||
cmd *Command
|
||||
}
|
||||
|
||||
func (c *cmdContext) CancelWithCause(err error) error {
|
||||
c.cmd.cmdCancel(err)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user