зеркало из https://github.com/mislav/hub.git
Return octokit.PullRequest
This commit is contained in:
Родитель
0e0e61d76a
Коммит
08342b837e
|
@ -55,10 +55,7 @@ func init() {
|
|||
[ attached pull request to issue #123 ]
|
||||
*/
|
||||
func pullRequest(cmd *Command, args *Args) {
|
||||
var (
|
||||
title, body string
|
||||
err error
|
||||
)
|
||||
var title, body string
|
||||
if args.ParamsSize() == 1 {
|
||||
title = args.RemoveParam(0)
|
||||
}
|
||||
|
@ -66,7 +63,10 @@ func pullRequest(cmd *Command, args *Args) {
|
|||
gh := github.New()
|
||||
repo := gh.Project.LocalRepoWith(flagPullRequestBase, flagPullRequestHead)
|
||||
if title == "" && flagPullRequestIssue == "" {
|
||||
title, body, err = writePullRequestTitleAndBody(repo)
|
||||
t, b, err := writePullRequestTitleAndBody(repo)
|
||||
utils.Check(err)
|
||||
title = t
|
||||
body = b
|
||||
}
|
||||
|
||||
if title == "" && flagPullRequestIssue == "" {
|
||||
|
@ -79,14 +79,16 @@ func pullRequest(cmd *Command, args *Args) {
|
|||
pullRequestURL = "PULL_REQUEST_URL"
|
||||
} else {
|
||||
if title != "" {
|
||||
pullRequestURL, err = gh.CreatePullRequest(repo.Base, repo.Head, title, body)
|
||||
pr, err := gh.CreatePullRequest(repo.Base, repo.Head, title, body)
|
||||
utils.Check(err)
|
||||
pullRequestURL = pr.HTMLURL
|
||||
}
|
||||
utils.Check(err)
|
||||
|
||||
if flagPullRequestIssue != "" {
|
||||
pullRequestURL, err = gh.CreatePullRequestForIssue(repo.Base, repo.Head, flagPullRequestIssue)
|
||||
pr, err := gh.CreatePullRequestForIssue(repo.Base, repo.Head, flagPullRequestIssue)
|
||||
utils.Check(err)
|
||||
pullRequestURL = pr.HTMLURL
|
||||
}
|
||||
utils.Check(err)
|
||||
}
|
||||
|
||||
args.Replace("echo", "", pullRequestURL)
|
||||
|
|
|
@ -31,7 +31,7 @@ func (gh *GitHub) PullRequest(id string) (pr *octokit.PullRequest, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (gh *GitHub) CreatePullRequest(base, head, title, body string) (url string, err error) {
|
||||
func (gh *GitHub) CreatePullRequest(base, head, title, body string) (pr *octokit.PullRequest, err error) {
|
||||
client := gh.octokit()
|
||||
prService, err := client.PullRequests(&octokit.PullRequestsURL, octokit.M{"owner": gh.Project.Owner, "repo": gh.Project.Name})
|
||||
if err != nil {
|
||||
|
@ -44,12 +44,10 @@ func (gh *GitHub) CreatePullRequest(base, head, title, body string) (url string,
|
|||
err = result.Err
|
||||
}
|
||||
|
||||
url = pr.HTMLURL
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (url string, err error) {
|
||||
func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (pr *octokit.PullRequest, err error) {
|
||||
client := gh.octokit()
|
||||
prService, err := client.PullRequests(&octokit.PullRequestsURL, octokit.M{"owner": gh.Project.Owner, "repo": gh.Project.Name})
|
||||
if err != nil {
|
||||
|
@ -62,8 +60,6 @@ func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (url strin
|
|||
err = result.Err
|
||||
}
|
||||
|
||||
url = pr.HTMLURL
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче