From 37156df256221b98e44f02dc210dad77d4148b73 Mon Sep 17 00:00:00 2001 From: Etourneau Gwenn Date: Thu, 28 Jul 2016 13:24:03 +0900 Subject: [PATCH] Create body file --- README.md | 1 + in_command.go | 10 ++++++++++ in_command_test.go | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 11c6264..a1c8d84 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Also creates the following files: * `tag` containing the git tag name of the release being fetched. * `version` containing the version determined by the git tag of the release being fetched. +* `body` containing the body text of the release determined by the git tag of the release being fetched. #### Parameters diff --git a/in_command.go b/in_command.go index f1065dd..2e19dfe 100644 --- a/in_command.go +++ b/in_command.go @@ -60,6 +60,16 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) { if err != nil { return InResponse{}, err } + + if foundRelease.Body != nil && *foundRelease.Body != "" { + body := *foundRelease.Body + bodyPath := filepath.Join(destDir, "body") + err = ioutil.WriteFile(bodyPath, []byte(body), 0644) + if err != nil { + return InResponse{}, err + } + } + } assets, err := c.github.ListReleaseAssets(*foundRelease) diff --git a/in_command_test.go b/in_command_test.go index d89a471..d50e70f 100644 --- a/in_command_test.go +++ b/in_command_test.go @@ -144,7 +144,7 @@ var _ = Describe("In Command", func() { Ω(githubClient.DownloadReleaseAssetArgsForCall(1)).Should(Equal(*buildAsset(1, "example.rtf"))) }) - It("does create the tag and version files", func() { + It("does create the body, tag and version files", func() { inResponse, inErr = command.Run(destDir, inRequest) contents, err := ioutil.ReadFile(path.Join(destDir, "tag")) @@ -154,6 +154,10 @@ var _ = Describe("In Command", func() { contents, err = ioutil.ReadFile(path.Join(destDir, "version")) Ω(err).ShouldNot(HaveOccurred()) Ω(string(contents)).Should(Equal("0.35.0")) + + contents, err = ioutil.ReadFile(path.Join(destDir, "body")) + Ω(err).ShouldNot(HaveOccurred()) + Ω(string(contents)).Should(Equal("*markdown*")) }) Context("when include_source_tarball is true", func() {