diff --git a/out_command.go b/out_command.go index dbb9ea9..8867e92 100644 --- a/out_command.go +++ b/out_command.go @@ -36,8 +36,11 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err return OutResponse{}, err } - body := "" + var body string + bodySpecified := false if request.Params.BodyPath != "" { + bodySpecified = true + body, err = c.fileContents(filepath.Join(sourceDir, request.Params.BodyPath)) if err != nil { return OutResponse{}, err @@ -77,10 +80,13 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err if existingRelease != nil { existingRelease.Name = github.String(name) - existingRelease.Body = github.String(body) existingRelease.TargetCommitish = github.String(targetCommitish) existingRelease.Draft = github.Bool(draft) + if bodySpecified { + existingRelease.Body = github.String(body) + } + for _, asset := range existingRelease.Assets { fmt.Fprintf(c.writer, "clearing existing asset: %s\n", *asset.Name) diff --git a/out_command_test.go b/out_command_test.go index 762e718..a79e58d 100644 --- a/out_command_test.go +++ b/out_command_test.go @@ -140,6 +140,20 @@ var _ = Describe("Out Command", func() { }) }) + Context("when a body is not supplied", func() { + BeforeEach(func() { + request.Params.BodyPath = "" + }) + + It("does not blow away the body", func() { + Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1)) + + updatedRelease := githubClient.UpdateReleaseArgsForCall(0) + Ω(*updatedRelease.Name).Should(Equal("v0.3.12")) + Ω(updatedRelease.Body).Should(BeNil()) + }) + }) + Context("when a commitish is not supplied", func() { It("updates the existing release", func() { Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))