prow/github/client.go
func (c *Client) Merge(org, repo string, pr int, details MergeDetails) error {
	c.log("Merge", org, repo, pr, details)
	ge := githubError{}
	ec, err := c.request(&request{
		method:      http.MethodPut,
		path:        fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", org, repo, pr),
		requestBody: &details,
		exitCodes:   []int{200, 405, 409},
	}, &ge)
	if err != nil {
		return err
	}
	if ec == 405 {
		if strings.Contains(ge.Message, "Base branch was modified") {
			return UnmergablePRBaseChangedError(ge.Message)
		}
		if strings.Contains(ge.Message, "You're not authorized to push to this branch") {
			return UnauthorizedToPushError(ge.Message)
		}
		if strings.Contains(ge.Message, "Merge commits are not allowed on this repository") {
			return MergeCommitsForbiddenError(ge.Message)
		}
		return UnmergablePRError(ge.Message)
	} else if ec == 409 {
		return ModifiedHeadError(ge.Message)
	}

	return nil
}
func (c *Client) Merge(org, repo string, pr int, details MergeDetails) error {
	c.log("Merge", org, repo, pr, details)
	ge := githubError{}
	ec, err := c.request(&request{
		method:      http.MethodPut,
		path:        fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", org, repo, pr),
		requestBody: &details,
		exitCodes:   []int{200, 405, 409},
	}, &ge)
	if err != nil {
		return err
	}
	if ec == 405 {
		if strings.Contains(ge.Message, "Base branch was modified") {
			return UnmergablePRBaseChangedError(ge.Message)
		}
		if strings.Contains(ge.Message, "You're not authorized to push to this branch") {
			return UnauthorizedToPushError(ge.Message)
		}
		if strings.Contains(ge.Message, "Merge commits are not allowed on this repository") {
			return MergeCommitsForbiddenError(ge.Message)
		}
		return UnmergablePRError(ge.Message)
	} else if ec == 409 {
		return ModifiedHeadError(ge.Message)
	}

	return nil
}
func ( c * Client ) Merge ( org , repo string , pr int , details MergeDetails ) error { c . log ( " " , org , repo , pr , details ) ge := githubError { } ec , err := c . request ( & request { method : http . MethodPut , path : fmt . Sprintf ( " " , org , repo , pr ) , requestBody : & details , exitCodes : [ ] int { 200 , 405 , 409 } , } , & ge ) if err != nil { return err } if ec == 405 { if strings . Contains ( ge . Message , " " ) { return UnmergablePRBaseChangedError ( ge . Message ) } if strings . Contains ( ge . Message , " " ) { return UnauthorizedToPushError ( ge . Message ) } if strings . Contains ( ge . Message , " " ) { return MergeCommitsForbiddenError ( ge . Message ) } return UnmergablePRError ( ge . Message ) } else if ec == 409 { return ModifiedHeadError ( ge . Message ) } return nil }
// Merge merges a PR.
//
// See https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
Merge merges a PR . See https : // developer . github . com / v3 / pulls / #merge - a - pull - request - merge - button