mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Change git.cmd to RunWithContext (#18693)
Change all `cmd...Pipeline` commands to `cmd.RunWithContext`. #18553 Co-authored-by: Martin Scholz <martin.scholz@versasec.com>
This commit is contained in:
		@@ -25,7 +25,12 @@ func RevListAllObjects(ctx context.Context, revListWriter *io.PipeWriter, wg *sy
 | 
			
		||||
	stderr := new(bytes.Buffer)
 | 
			
		||||
	var errbuf strings.Builder
 | 
			
		||||
	cmd := git.NewCommand(ctx, "rev-list", "--objects", "--all")
 | 
			
		||||
	if err := cmd.RunInDirPipeline(basePath, revListWriter, stderr); err != nil {
 | 
			
		||||
	if err := cmd.RunWithContext(&git.RunContext{
 | 
			
		||||
		Timeout: -1,
 | 
			
		||||
		Dir:     basePath,
 | 
			
		||||
		Stdout:  revListWriter,
 | 
			
		||||
		Stderr:  stderr,
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		log.Error("git rev-list --objects --all [%s]: %v - %s", basePath, err, errbuf.String())
 | 
			
		||||
		err = fmt.Errorf("git rev-list --objects --all [%s]: %v - %s", basePath, err, errbuf.String())
 | 
			
		||||
		_ = revListWriter.CloseWithError(err)
 | 
			
		||||
@@ -40,7 +45,12 @@ func RevListObjects(ctx context.Context, revListWriter *io.PipeWriter, wg *sync.
 | 
			
		||||
	stderr := new(bytes.Buffer)
 | 
			
		||||
	var errbuf strings.Builder
 | 
			
		||||
	cmd := git.NewCommand(ctx, "rev-list", "--objects", headSHA, "--not", baseSHA)
 | 
			
		||||
	if err := cmd.RunInDirPipeline(tmpBasePath, revListWriter, stderr); err != nil {
 | 
			
		||||
	if err := cmd.RunWithContext(&git.RunContext{
 | 
			
		||||
		Timeout: -1,
 | 
			
		||||
		Dir:     tmpBasePath,
 | 
			
		||||
		Stdout:  revListWriter,
 | 
			
		||||
		Stderr:  stderr,
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		log.Error("git rev-list [%s]: %v - %s", tmpBasePath, err, errbuf.String())
 | 
			
		||||
		errChan <- fmt.Errorf("git rev-list [%s]: %v - %s", tmpBasePath, err, errbuf.String())
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user