prow/github/client.go
func (c *Client) CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error) {
	c.log("CreatePullRequest", org, repo, title)
	data := struct {
		Title string `json:"title"`
		Body  string `json:"body"`
		Head  string `json:"head"`
		Base  string `json:"base"`
		// MaintainerCanModify allows maintainers of the repo to modify this
		// pull request, eg. push changes to it before merging.
		MaintainerCanModify bool `json:"maintainer_can_modify"`
	}{
		Title: title,
		Body:  body,
		Head:  head,
		Base:  base,

		MaintainerCanModify: canModify,
	}
	var resp struct {
		Num int `json:"number"`
	}
	_, err := c.request(&request{
		// allow the description and draft fields
		// https://developer.github.com/changes/2018-02-22-label-description-search-preview/
		// https://developer.github.com/changes/2019-02-14-draft-pull-requests/
		accept:      "application/vnd.github.symmetra-preview+json, application/vnd.github.shadow-cat-preview",
		method:      http.MethodPost,
		path:        fmt.Sprintf("/repos/%s/%s/pulls", org, repo),
		requestBody: &data,
		exitCodes:   []int{201},
	}, &resp)
	if err != nil {
		return 0, err
	}
	return resp.Num, nil
}
func (c *Client) CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error) {
	c.log("CreatePullRequest", org, repo, title)
	data := struct {
		Title string `json:"title"`
		Body  string `json:"body"`
		Head  string `json:"head"`
		Base  string `json:"base"`
		// MaintainerCanModify allows maintainers of the repo to modify this
		// pull request, eg. push changes to it before merging.
		MaintainerCanModify bool `json:"maintainer_can_modify"`
	}{
		Title: title,
		Body:  body,
		Head:  head,
		Base:  base,

		MaintainerCanModify: canModify,
	}
	var resp struct {
		Num int `json:"number"`
	}
	_, err := c.request(&request{
		// allow the description and draft fields
		// https://developer.github.com/changes/2018-02-22-label-description-search-preview/
		// https://developer.github.com/changes/2019-02-14-draft-pull-requests/
		accept:      "application/vnd.github.symmetra-preview+json, application/vnd.github.shadow-cat-preview",
		method:      http.MethodPost,
		path:        fmt.Sprintf("/repos/%s/%s/pulls", org, repo),
		requestBody: &data,
		exitCodes:   []int{201},
	}, &resp)
	if err != nil {
		return 0, err
	}
	return resp.Num, nil
}
func ( c * Client ) CreatePullRequest ( org , repo , title , body , head , base string , canModify bool ) ( int , error ) { c . log ( " " , org , repo , title ) data := struct { Title string `json:"title"` Body string `json:"body"` Head string `json:"head"` Base string `json:"base"` // MaintainerCanModify allows maintainers of the repo to modify this // pull request, eg. push changes to it before merging. MaintainerCanModify bool `json:"maintainer_can_modify"` } { Title : title , Body : body , Head : head , Base : base , MaintainerCanModify : canModify , } var resp struct { Num int `json:"number"` } _ , err := c . request ( & request { // allow the description and draft fields // https://developer.github.com/changes/2018-02-22-label-description-search-preview/ // https://developer.github.com/changes/2019-02-14-draft-pull-requests/ accept : " " , method : http . MethodPost , path : fmt . Sprintf ( " " , org , repo ) , requestBody : & data , exitCodes : [ ] int { 201 } , } , & resp ) if err != nil { return 0 , err } return resp . Num , nil }
// CreatePullRequest creates a new pull request and returns its number if
// the creation is successful, otherwise any error that is encountered.
//
// See https://developer.github.com/v3/pulls/#create-a-pull-request
CreatePullRequest creates a new pull request and returns its number if the creation is successful otherwise any error that is encountered . See https : // developer . github . com / v3 / pulls / #create - a - pull - request