diff --git a/scripts/speculator/main.go b/scripts/speculator/main.go index b4fe2aef..2609fa7e 100644 --- a/scripts/speculator/main.go +++ b/scripts/speculator/main.go @@ -136,20 +136,30 @@ func generateAt(repo, sha string) (dst string, err error) { } func serveSpec(w http.ResponseWriter, req *http.Request) { - pr, err := lookupPullRequest(*req.URL, "/spec") - if err != nil { - writeError(w, 400, err) - return - } + var cloneURL string + var sha string + + if strings.ToLower(req.URL.Path) == "/spec/head" { + cloneURL = "https://github.com/matrix-org/matrix-doc.git" + sha = "HEAD" + } else { + pr, err := lookupPullRequest(*req.URL, "/spec") + if err != nil { + writeError(w, 400, err) + return + } - // We're going to run whatever Python is specified in the pull request, which - // may do bad things, so only trust people we trust. - if err := checkAuth(pr); err != nil { - writeError(w, 403, err) - return + // We're going to run whatever Python is specified in the pull request, which + // may do bad things, so only trust people we trust. + if err := checkAuth(pr); err != nil { + writeError(w, 403, err) + return + } + cloneURL = pr.Head.Repo.CloneURL + sha = pr.Head.SHA } - dst, err := generateAt(pr.Head.Repo.CloneURL, pr.Head.SHA) + dst, err := generateAt(cloneURL, sha) defer os.RemoveAll(dst) if err != nil { writeError(w, 500, err) @@ -287,7 +297,7 @@ func listPulls(w http.ResponseWriter, req *http.Request) { s += fmt.Sprintf(`
  • %d: %s: %s: spec spec diff rst diff
  • `, pull.Number, pull.User.HTMLURL, pull.User.Login, pull.HTMLURL, pull.Title, pull.Number, pull.Number, pull.Number) } - s += "" + s += `
    View the spec at head
    ` io.WriteString(w, s) }