This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 53d884a043d099891d184a6ee480a074f665fd19
Author: Klesh Wong <[email protected]>
AuthorDate: Tue Apr 9 16:52:29 2024 +0800

    Add more log on gitclone errors (#7300)
    
    * chore: add more log on git clone errors
    
    * fix: ignore debugging binary file generated by vscode
---
 .gitignore                                          |  4 +++-
 backend/plugins/gitextractor/parser/clone_gitcli.go | 11 +++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0aa085362..b62fdf26f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -162,4 +162,6 @@ __pycache__
 venv
 
 /backend/plugins/gitextractor/parser/output*
-/backend/plugins/gitextractor/parser/demo_repo/
\ No newline at end of file
+/backend/plugins/gitextractor/parser/demo_repo/
+
+__debug_bin*
\ No newline at end of file
diff --git a/backend/plugins/gitextractor/parser/clone_gitcli.go 
b/backend/plugins/gitextractor/parser/clone_gitcli.go
index 8f085bacd..dd81b284f 100644
--- a/backend/plugins/gitextractor/parser/clone_gitcli.go
+++ b/backend/plugins/gitextractor/parser/clone_gitcli.go
@@ -128,6 +128,7 @@ func (g *GitcliCloner) CloneRepo(ctx plugin.SubTaskContext, 
localDir string) err
                g.logger.Error(err, "stderr pipe error")
                return errors.Default.New("stderr pipe error")
        }
+       combinedOutput := new(strings.Builder)
        stdoutScanner := bufio.NewScanner(stdout)
        stdoutScanner.Split(bufio.ScanLines)
        stderrScanner := bufio.NewScanner(stderr)
@@ -135,25 +136,27 @@ func (g *GitcliCloner) CloneRepo(ctx 
plugin.SubTaskContext, localDir string) err
        done := make(chan bool)
        go func() {
                for stdoutScanner.Scan() {
-                       fmt.Printf("stdout: %s\n", stdoutScanner.Text())
+                       // TODO: extract progress?
+                       combinedOutput.WriteString(fmt.Sprintf("stdout: %s\n", 
stdoutScanner.Text()))
                }
                done <- true
        }()
        go func() {
+               // TODO: extract progress?
                for stderrScanner.Scan() {
-                       fmt.Printf("stderr: %s\n", stderrScanner.Text())
+                       combinedOutput.WriteString(fmt.Sprintf("stderr: %s\n", 
stderrScanner.Text()))
                }
                done <- true
        }()
        if e := cmd.Start(); e != nil {
-               g.logger.Error(e, "failed to start")
+               g.logger.Error(e, "failed to start\n%s", 
combinedOutput.String())
                return errors.Default.New("failed to start")
        }
        <-done
        <-done
        err = cmd.Wait()
        if err != nil {
-               g.logger.Error(err, "git exited with error")
+               g.logger.Error(err, "git exited with error\n%s", 
combinedOutput.String())
                return errors.Default.New("git exit error")
        }
        return nil

Reply via email to