[logging] Increase jiri logging to allow infra debug checkout issues.
This change increases jiri's logging to allow infra debug recent
checkout issues.
Bug: 35119
Test: Local
Change-Id: I4d774132f43bff01092750e253bcfe561a8935a7
diff --git a/gitutil/git.go b/gitutil/git.go
index 2d5cc7a..ffbe85c 100644
--- a/gitutil/git.go
+++ b/gitutil/git.go
@@ -1249,11 +1249,13 @@
if g.userEmail != "" {
args = append([]string{"-c", fmt.Sprintf("user.email=%s", g.userEmail)}, args...)
}
+ var outbuf bytes.Buffer
+ var errbuf bytes.Buffer
command := exec.Command("git", args...)
command.Dir = g.rootDir
command.Stdin = os.Stdin
- command.Stdout = stdout
- command.Stderr = stderr
+ command.Stdout = io.MultiWriter(stdout, &outbuf)
+ command.Stderr = io.MultiWriter(stderr, &errbuf)
env := g.jirix.Env()
env = envvar.MergeMaps(g.opts, env)
command.Env = envvar.MapToSlice(env)
@@ -1265,8 +1267,9 @@
// ignore error
}
}
- g.jirix.Logger.Tracef("Run: git %s (%s)", strings.Join(args, " "), dir)
- return command.Run()
+ err := command.Run()
+ g.jirix.Logger.Tracef("Run: git %s (%s), \nstdout: %s\nstderr: %s\n", strings.Join(args, " "), dir, outbuf.String(), errbuf.String())
+ return err
}
// Committer encapsulates the process of create a commit.
diff --git a/project/project.go b/project/project.go
index 580a042..80f5e89 100644
--- a/project/project.go
+++ b/project/project.go
@@ -1555,6 +1555,7 @@
if err == nil {
return nil
}
+ jirix.Logger.Debugf("Checkout %s to head revision %s failed, fallback to fetch: %v", project.Name, revision, err)
if project.Revision != "" && project.Revision != "HEAD" {
//might be a tag
if err2 := fetch(jirix, project.Path, "origin", gitutil.FetchTagOpt(project.Revision)); err2 != nil {