Exemplo n.º 1
0
func writePullRequestTitleAndBody(repo *github.Repo) (title, body string, err error) {
	messageFile, err := git.PullReqMsgFile()
	if err != nil {
		return
	}

	err = writePullRequestChanges(repo, messageFile)
	if err != nil {
		return
	}

	editorPath, err := git.EditorPath()
	if err != nil {
		return
	}

	err = editTitleAndBody(editorPath, messageFile)
	if err != nil {
		return
	}

	title, body, err = readTitleAndBody(messageFile)
	if err != nil {
		return
	}

	err = os.Remove(messageFile)

	return
}
Exemplo n.º 2
0
Arquivo: pull.go Projeto: prsimp/gh
func pull(cmd *Command, args []string) {
	var title, body string
	if len(args) == 1 {
		title = args[0]
	}

	gh := github.New()
	repo := gh.Project.LocalRepoWith(flagPullRequestBase, flagPullRequestHead)
	if title == "" && flagPullRequestIssue == "" {
		messageFile, err := git.PullReqMsgFile()
		utils.Check(err)

		err = writePullRequestChanges(repo, messageFile)
		utils.Check(err)

		editorPath, err := git.EditorPath()
		utils.Check(err)

		err = editTitleAndBody(editorPath, messageFile)
		utils.Check(err)

		title, body, err = readTitleAndBody(messageFile)
		utils.Check(err)
	}

	if title == "" && flagPullRequestIssue == "" {
		log.Fatal("Aborting due to empty pull request title")
	}

	var pullRequestURL string
	var err error
	if title != "" {
		pullRequestURL, err = gh.CreatePullRequest(repo.Base, repo.Head, title, body)
	}
	if flagPullRequestIssue != "" {
		pullRequestURL, err = gh.CreatePullRequestForIssue(repo.Base, repo.Head, flagPullRequestIssue)
	}

	utils.Check(err)

	fmt.Println(pullRequestURL)
}