Commit 10dacbf0 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Suppress errors from shallow clone detection

They are just noise.
parent 15dcdbd4
......@@ -125,14 +125,8 @@ func handlePostRPC(w http.ResponseWriter, r *http.Request, a *api.Response) {
return
}
isShallowClone, err = scanDeepen(bytes.NewReader(buffer.Bytes()))
isShallowClone = scanDeepen(bytes.NewReader(buffer.Bytes()))
body = io.MultiReader(buffer, r.Body)
if err != nil {
// Do not pass on the error: our failure to parse the
// request body should not abort the request.
helper.LogError(r, fmt.Errorf("parseBody (non-fatal): %v", err))
}
} else {
body = r.Body
}
......
......@@ -18,19 +18,16 @@ func pktFlush(w io.Writer) error {
return err
}
func scanDeepen(body io.Reader) (bool, error) {
hasDeepen := false
func scanDeepen(body io.Reader) bool {
scanner := bufio.NewScanner(body)
scanner.Split(pktLineSplitter)
for scanner.Scan() {
if bytes.HasPrefix(scanner.Bytes(), []byte("deepen")) {
hasDeepen = true
break
if bytes.HasPrefix(scanner.Bytes(), []byte("deepen")) && scanner.Err() == nil {
return true
}
}
return hasDeepen, scanner.Err()
return false
}
func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err error) {
......
......@@ -16,10 +16,7 @@ func TestSuccessfulScanDeepen(t *testing.T) {
}
for _, example := range examples {
hasDeepen, err := scanDeepen(bytes.NewReader([]byte(example.input)))
if err != nil {
t.Fatalf("error scanning %q: %v", example.input, err)
}
hasDeepen := scanDeepen(bytes.NewReader([]byte(example.input)))
if hasDeepen != example.output {
t.Fatalf("scanDeepen %q: expected %v, got %v", example.input, example.output, hasDeepen)
......@@ -35,14 +32,7 @@ func TestFailedScanDeepen(t *testing.T) {
}
for _, example := range examples {
hasDeepen, err := scanDeepen(bytes.NewReader([]byte(example)))
if err == nil {
t.Fatalf("expected error scanning %q", example)
}
t.Log(err)
if hasDeepen == true {
if scanDeepen(bytes.NewReader([]byte(example))) == true {
t.Fatalf("scanDeepen %q: expected result to be false, got true", example)
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment