diff --git a/gitinfo.go b/gitinfo.go index 31360a5..807a3a5 100644 --- a/gitinfo.go +++ b/gitinfo.go @@ -119,13 +119,6 @@ func runCommand(gitPath string, args ...string) (string, error) { return string(ret), nil } -func firstLine(s string) string { - if idx := strings.Index(s, "\n"); idx >= 0 { - return s[:idx] - } - return s -} - var varNames = [...]string{ "GIT_BRANCH", diff --git a/goveralls.go b/goveralls.go index a9a6374..126feb7 100644 --- a/goveralls.go +++ b/goveralls.go @@ -265,7 +265,7 @@ func processParallelFinish(jobID, token string) error { defer res.Body.Close() bodyBytes, err := ioutil.ReadAll(res.Body) if err != nil { - return fmt.Errorf("Unable to read response body from coveralls: %s", err) + return fmt.Errorf("unable to read response body from coveralls: %s", err) } if res.StatusCode >= http.StatusInternalServerError && *shallow { @@ -274,12 +274,12 @@ func processParallelFinish(jobID, token string) error { } if res.StatusCode != 200 { - return fmt.Errorf("Bad response status from coveralls: %d\n%s", res.StatusCode, bodyBytes) + return fmt.Errorf("bad response status from coveralls: %d\n%s", res.StatusCode, bodyBytes) } var response WebHookResponse if err = json.Unmarshal(bodyBytes, &response); err != nil { - return fmt.Errorf("Unable to unmarshal response JSON from coveralls: %s\n%s", err, bodyBytes) + return fmt.Errorf("unable to unmarshal response JSON from coveralls: %s\n%s", err, bodyBytes) } if !response.Done { @@ -499,7 +499,7 @@ func process() error { defer res.Body.Close() bodyBytes, err := ioutil.ReadAll(res.Body) if err != nil { - return fmt.Errorf("Unable to read response body from coveralls: %s", err) + return fmt.Errorf("unable to read response body from coveralls: %s", err) } if res.StatusCode >= http.StatusInternalServerError && *shallow { @@ -508,11 +508,11 @@ func process() error { } if res.StatusCode != 200 { - return fmt.Errorf("Bad response status from coveralls: %d\n%s", res.StatusCode, bodyBytes) + return fmt.Errorf("bad response status from coveralls: %d\n%s", res.StatusCode, bodyBytes) } var response Response if err = json.Unmarshal(bodyBytes, &response); err != nil { - return fmt.Errorf("Unable to unmarshal response JSON from coveralls: %s\n%s", err, bodyBytes) + return fmt.Errorf("unable to unmarshal response JSON from coveralls: %s\n%s", err, bodyBytes) } if response.Error { return errors.New(response.Message) diff --git a/goveralls_test.go b/goveralls_test.go index 4bbb556..c7a24bd 100644 --- a/goveralls_test.go +++ b/goveralls_test.go @@ -54,6 +54,10 @@ func fakeServer() *httptest.Server { func fakeServerWithPayloadChannel(payload chan Job) *httptest.Server { return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { body, err := ioutil.ReadAll(r.Body) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } // query params are used for the body payload vals, err := url.ParseQuery(string(body)) if err != nil {