Skip to content

Commit

Permalink
Create body file
Browse files Browse the repository at this point in the history
  • Loading branch information
shinji62 committed Jul 28, 2016
1 parent 7d10e39 commit 37156df
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions in_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion in_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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() {
Expand Down

0 comments on commit 37156df

Please sign in to comment.