Revert "Checkout SHA of origin/master rather than merging"
This reverts commit 0dbc6d8277
.
This commit is contained in:
parent
0dbc6d8277
commit
481298db83
1 changed files with 7 additions and 20 deletions
|
@ -82,8 +82,11 @@ func gitCheckout(path, sha string) error {
|
||||||
return runGitCommand(path, []string{"checkout", sha})
|
return runGitCommand(path, []string{"checkout", sha})
|
||||||
}
|
}
|
||||||
|
|
||||||
func gitFetch(path string) error {
|
func gitFetchAndMerge(path string) error {
|
||||||
return runGitCommand(path, []string{"fetch"})
|
if err := runGitCommand(path, []string{"fetch"}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return runGitCommand(path, []string{"merge", "origin/master"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGitCommand(path string, args []string) error {
|
func runGitCommand(path string, args []string) error {
|
||||||
|
@ -142,7 +145,7 @@ type server struct {
|
||||||
// generateAt generates spec from repo at sha.
|
// generateAt generates spec from repo at sha.
|
||||||
// Returns the path where the generation was done.
|
// Returns the path where the generation was done.
|
||||||
func (s *server) generateAt(sha string) (dst string, err error) {
|
func (s *server) generateAt(sha string) (dst string, err error) {
|
||||||
err = gitFetch(s.matrixDocCloneURL)
|
err = gitFetchAndMerge(s.matrixDocCloneURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -159,27 +162,11 @@ func (s *server) generateAt(sha string) (dst string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) getSHAOf(ref string) (string, error) {
|
|
||||||
cmd := exec.Command("git", "rev-list", ref, "-n1")
|
|
||||||
cmd.Dir = path.Join(s.matrixDocCloneURL)
|
|
||||||
var b bytes.Buffer
|
|
||||||
cmd.Stdout = &b
|
|
||||||
err := cmd.Run()
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("error generating spec: %v\nOutput from gendoc:\n%v", err, b.String())
|
|
||||||
}
|
|
||||||
return strings.TrimSpace(b.String()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) serveSpec(w http.ResponseWriter, req *http.Request) {
|
func (s *server) serveSpec(w http.ResponseWriter, req *http.Request) {
|
||||||
var sha string
|
var sha string
|
||||||
|
|
||||||
if strings.ToLower(req.URL.Path) == "/spec/head" {
|
if strings.ToLower(req.URL.Path) == "/spec/head" {
|
||||||
originHead, err := s.getSHAOf("origin/master")
|
sha = "HEAD"
|
||||||
if err != nil {
|
|
||||||
writeError(w, 500, err)
|
|
||||||
}
|
|
||||||
sha = originHead
|
|
||||||
} else {
|
} else {
|
||||||
pr, err := lookupPullRequest(*req.URL, "/spec")
|
pr, err := lookupPullRequest(*req.URL, "/spec")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue