aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-12-02 19:36:06 +0100
committerGitHub <noreply@github.com>2020-12-02 18:36:06 +0000
commit2b4a08e9621e052845062ecd71ebfd37453c0383 (patch)
tree31d7ac557f570ea6aba5ca7e5bfd1f28a36f5729 /modules/git
parentfd1c3519c3435cbd09a2c065a6eeeb48bd81644e (diff)
downloadgitea-2b4a08e9621e052845062ecd71ebfd37453c0383.tar.gz
gitea-2b4a08e9621e052845062ecd71ebfd37453c0383.zip
Migrations: Use Process Manager to create own Context (#13792)
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/git.go1
-rw-r--r--modules/git/repo.go12
2 files changed, 10 insertions, 3 deletions
diff --git a/modules/git/git.go b/modules/git/git.go
index cce5cc738d..6b15138a5c 100644
--- a/modules/git/git.go
+++ b/modules/git/git.go
@@ -32,6 +32,7 @@ var (
GitExecutable = "git"
// DefaultContext is the default context to run git commands in
+ // will be overwritten by Init with HammerContext
DefaultContext = context.Background()
gitVersion *version.Version
diff --git a/modules/git/repo.go b/modules/git/repo.go
index ae370d3da9..9b1da87a32 100644
--- a/modules/git/repo.go
+++ b/modules/git/repo.go
@@ -8,6 +8,7 @@ package git
import (
"bytes"
"container/list"
+ "context"
"errors"
"fmt"
"os"
@@ -166,19 +167,24 @@ type CloneRepoOptions struct {
// Clone clones original repository to target path.
func Clone(from, to string, opts CloneRepoOptions) (err error) {
+ return CloneWithContext(DefaultContext, from, to, opts)
+}
+
+// CloneWithContext clones original repository to target path.
+func CloneWithContext(ctx context.Context, from, to string, opts CloneRepoOptions) (err error) {
cargs := make([]string, len(GlobalCommandArgs))
copy(cargs, GlobalCommandArgs)
- return CloneWithArgs(from, to, cargs, opts)
+ return CloneWithArgs(ctx, from, to, cargs, opts)
}
// CloneWithArgs original repository to target path.
-func CloneWithArgs(from, to string, args []string, opts CloneRepoOptions) (err error) {
+func CloneWithArgs(ctx context.Context, from, to string, args []string, opts CloneRepoOptions) (err error) {
toDir := path.Dir(to)
if err = os.MkdirAll(toDir, os.ModePerm); err != nil {
return err
}
- cmd := NewCommandNoGlobals(args...).AddArguments("clone")
+ cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
if opts.Mirror {
cmd.AddArguments("--mirror")
}