From 20f0284155ed5d1a5cfe8146071f395559e93866 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 11 Sep 2015 14:40:52 +0100 Subject: [PATCH 1/2] speculator: Unified diff for rst diff --- scripts/speculator/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/speculator/main.go b/scripts/speculator/main.go index 3775ad86..d30c199c 100644 --- a/scripts/speculator/main.go +++ b/scripts/speculator/main.go @@ -182,7 +182,7 @@ func serveRstDiff(w http.ResponseWriter, req *http.Request) { return } - diffCmd := exec.Command("diff", path.Join(base, "scripts", "tmp", "full_spec.rst"), path.Join(head, "scripts", "tmp", "full_spec.rst")) + diffCmd := exec.Command("diff", "-u", path.Join(base, "scripts", "tmp", "full_spec.rst"), path.Join(head, "scripts", "tmp", "full_spec.rst")) var diff bytes.Buffer diffCmd.Stdout = &diff if err := ignoreExitCodeOne(diffCmd.Run()); err != nil { From b6dab0009d5533161dff92b1bdad3c664d3a5c6f Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 11 Sep 2015 14:43:26 +0100 Subject: [PATCH 2/2] speculator: Don't ignore errors --- scripts/speculator/main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/speculator/main.go b/scripts/speculator/main.go index 3775ad86..1a474277 100644 --- a/scripts/speculator/main.go +++ b/scripts/speculator/main.go @@ -67,13 +67,18 @@ func gitCheckout(path, sha string) error { return nil } -func lookupPullRequest(prNumber string) (PullRequest, error) { - resp, _ := http.Get("https://api.github.com/repos/matrix-org/matrix-doc/pulls/" + prNumber) +func lookupPullRequest(prNumber string) (*PullRequest, error) { + resp, err := http.Get("https://api.github.com/repos/matrix-org/matrix-doc/pulls/" + prNumber) defer resp.Body.Close() + if err != nil { + return nil, fmt.Errorf("error getting pulls: %v", err) + } dec := json.NewDecoder(resp.Body) var pr PullRequest - _ = dec.Decode(&pr) - return pr, nil + if err := dec.Decode(&pr); err != nil { + return nil, fmt.Errorf("error decoding pulls: %v", err) + } + return &pr, nil } func generate(dir string) error {