if no body specified, do not update it value

[#102280580]
This commit is contained in:
Alex Suraci
2015-10-27 14:47:27 -07:00
parent d30a1d0197
commit 6c3c5e9cbd
2 changed files with 22 additions and 2 deletions

View File

@@ -36,8 +36,11 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
return OutResponse{}, err return OutResponse{}, err
} }
body := "" var body string
bodySpecified := false
if request.Params.BodyPath != "" { if request.Params.BodyPath != "" {
bodySpecified = true
body, err = c.fileContents(filepath.Join(sourceDir, request.Params.BodyPath)) body, err = c.fileContents(filepath.Join(sourceDir, request.Params.BodyPath))
if err != nil { if err != nil {
return OutResponse{}, err return OutResponse{}, err
@@ -77,10 +80,13 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
if existingRelease != nil { if existingRelease != nil {
existingRelease.Name = github.String(name) existingRelease.Name = github.String(name)
existingRelease.Body = github.String(body)
existingRelease.TargetCommitish = github.String(targetCommitish) existingRelease.TargetCommitish = github.String(targetCommitish)
existingRelease.Draft = github.Bool(draft) existingRelease.Draft = github.Bool(draft)
if bodySpecified {
existingRelease.Body = github.String(body)
}
for _, asset := range existingRelease.Assets { for _, asset := range existingRelease.Assets {
fmt.Fprintf(c.writer, "clearing existing asset: %s\n", *asset.Name) fmt.Fprintf(c.writer, "clearing existing asset: %s\n", *asset.Name)

View File

@@ -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() { Context("when a commitish is not supplied", func() {
It("updates the existing release", func() { It("updates the existing release", func() {
Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1)) Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))