Skip to content

Commit

Permalink
feat: support setting PR body text on content update (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
isometry authored Sep 19, 2024
1 parent 6567501 commit 01f56d9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func init() {
viper.BindPFlag("pr-title", contentCmd.PersistentFlags().Lookup("pr-title"))
viper.BindEnv("pr-title", "GHUP_PR_TITLE")

contentCmd.PersistentFlags().String("pr-body", "", "pull request body")
viper.BindPFlag("pr-body", contentCmd.PersistentFlags().Lookup("pr-body"))
viper.BindEnv("pr-body", "GHUP_PR_BODY")

contentCmd.PersistentFlags().Bool("pr-draft", false, "create pull request in draft mode")
viper.BindPFlag("pr-draft", contentCmd.PersistentFlags().Lookup("pr-draft"))
viper.BindEnv("pr-draft", "GHUP_PR_DRAFT")
Expand Down Expand Up @@ -174,13 +178,15 @@ func runContentCmd(cmd *cobra.Command, args []string) (err error) {
}

if title := viper.GetString("pr-title"); newBranch && title != "" {
body := githubv4.String(viper.GetString("pr-body"))
log.Infof("opening pull request from %q to %q", branch, baseBranch)
input := githubv4.CreatePullRequestInput{
RepositoryID: repoInfo.NodeID,
BaseRefName: githubv4.String(baseBranch),
Draft: githubv4.NewBoolean(githubv4.Boolean(viper.GetBool("pr-draft"))),
HeadRefName: githubv4.String(branch),
Title: githubv4.String(title),
Body: &body,
}
log.Debugf("CreatePullRequestInput: %+v", input)
pullRequestUrl, err := client.CreatePullRequestV4(input)
Expand Down

0 comments on commit 01f56d9

Please sign in to comment.