fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

zoekt-indexserver: Check stderr for git fetch (#603)

Instead of checking stdout, we check the combined output. By default, git fetch writes to stderr.

+7 -12
+7 -12
cmd/zoekt-indexserver/main.go
··· 130 130 // update. 131 131 func fetchGitRepo(dir string) bool { 132 132 cmd := exec.Command("git", "--git-dir", dir, "fetch", "origin") 133 - outBuf := &bytes.Buffer{} 134 - errBuf := &bytes.Buffer{} 135 133 136 - // Prevent prompting 137 - cmd.Stdin = &bytes.Buffer{} 138 - cmd.Stderr = errBuf 139 - cmd.Stdout = outBuf 140 - if err := cmd.Run(); err != nil { 141 - log.Printf("command %s failed: %v\nOUT: %s\nERR: %s", 142 - cmd.Args, err, outBuf.String(), errBuf.String()) 143 - } else { 144 - return len(outBuf.Bytes()) != 0 134 + output, err := cmd.CombinedOutput() 135 + if err != nil { 136 + log.Printf("command %s failed: %v\nCOMBINED_OUT: %s\n", 137 + cmd.Args, err, string(output)) 138 + return false 145 139 } 146 - return false 140 + // When fetch found no updates, it prints nothing out 141 + return len(output) != 0 147 142 } 148 143 149 144 // indexPendingRepos consumes the directories on the repos channel and