forked from forgejo/forgejo
Migrations: Use Process Manager to create own Context (#13792)
This commit is contained in:
parent
fd1c3519c3
commit
2b4a08e962
7 changed files with 34 additions and 15 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue