// CreatePullRequest creates a pull request using the specified properties.
// returning the PR URL.
CreatePullRequest creates a pull request using the specified properties.
returning the PR URL.
// CreatePullRequest creates a pull request using the specified properties . // returning the PR URL .
func (r repo) CreatePullRequest(title, body, baseBranch, headBranch string) (PRURL string, err error) {
	apiURI := fmt.Sprintf("/repos/%s/pulls", r)
	PRJSON := fmt.Sprintf(`{"title":"%s","body":"%s","base":"%s","head":"%s"}`, title, body, baseBranch, headBranch)
	resp, err := r.Client.MakeAPIRequestWithData(http.MethodPost, apiURI, []byte(PRJSON))
	if err != nil {
		return "", err
	}
	if resp.StatusCode != http.StatusCreated {
		return "", fmt.Errorf("HTTP %d for %s while creating pull request in repository %q, base branch %q, and head branch %q", resp.StatusCode, apiURI, r, baseBranch, headBranch)
	}
	var PRAPIResp struct {
		HTMLURL *string `json:"html_url"`
	}
	err = json.NewDecoder(resp.Body).Decode(&PRAPIResp)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	if PRAPIResp.HTMLURL == nil {
		return "", errors.New("the Github API did not return a pull request HTML URL")
	}
	return *PRAPIResp.HTMLURL, nil
}
func ( r repo ) CreatePullRequest ( title , body , baseBranch , headBranch string ) ( PRURL string , err error ) { apiURI := fmt . Sprintf ( " " , r ) PRJSON := fmt . Sprintf ( `{"title":"%s","body":"%s","base":"%s","head":"%s"}` , title , body , baseBranch , headBranch ) resp , err := r . Client . MakeAPIRequestWithData ( http . MethodPost , apiURI , [ ] byte ( PRJSON ) ) if err != nil { return " " , err } if resp . StatusCode != http . StatusCreated { return " " , fmt . Errorf ( " " , resp . StatusCode , apiURI , r , baseBranch , headBranch ) } var PRAPIResp struct { HTMLURL * string `json:"html_url"` } err = json . NewDecoder ( resp . Body ) . Decode ( & PRAPIResp ) if err != nil { return " " , err } defer resp . Body . Close ( ) if PRAPIResp . HTMLURL == nil { return " " , errors . New ( " " ) } return * PRAPIResp . HTMLURL , nil }
CreatePullRequest creates a pull request using the specified properties.
CreatePullRequest creates a pull request using the specified properties .