From f224bc5a453e2151d86ae5bb68158c18e204b98d Mon Sep 17 00:00:00 2001 From: Dr Nic Williams Date: Sat, 25 Apr 2015 12:14:32 -0700 Subject: [PATCH] [in] creates file 'tag' containing git tag for the release being fetched --- README.md | 2 ++ in_command.go | 7 +++++++ in_command_test.go | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 6ff426c..0583482 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ Fetches artifacts from the given release version. If the version is not specified, the latest version is chosen using [semver](http://semver.org) semantics. +Creates a file `tag` containing the tag name/version of the release being fetched. + #### Parameters * `globs`: *Optional.* A list of globs for files that will be downloaded from diff --git a/in_command.go b/in_command.go index 9da0ec4..f5fee94 100644 --- a/in_command.go +++ b/in_command.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "net/http" "os" "path/filepath" @@ -58,6 +59,12 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) { return InResponse{}, fmt.Errorf("could not find release with tag: %s", request.Version.Tag) } + tagPath := filepath.Join(destDir, "tag") + err = ioutil.WriteFile(tagPath, []byte(*foundRelease.TagName), 0644) + if err != nil { + return InResponse{}, err + } + assets, err := c.github.ListReleaseAssets(foundRelease) if err != nil { return InResponse{}, err diff --git a/in_command_test.go b/in_command_test.go index 8cc0473..ca64477 100644 --- a/in_command_test.go +++ b/in_command_test.go @@ -236,6 +236,16 @@ var _ = Describe("In Command", func() { )) }) + It("stores tag in a file", func() { + _, err := os.Stat(filepath.Join(destDir, "tag")) + Ω(err).ShouldNot(HaveOccurred()) + + tag, err := ioutil.ReadFile(filepath.Join(destDir, "tag")) + Ω(err).ShouldNot(HaveOccurred()) + + Ω(string(tag)).Should(Equal("v0.35.0")) + }) + It("fetches from the latest release", func() { _, err := os.Stat(filepath.Join(destDir, "example.txt")) Ω(err).ShouldNot(HaveOccurred())