From 560637e9fda044bbf663133a2c59e314b6f7a374 Mon Sep 17 00:00:00 2001 From: Angela Chin Date: Wed, 18 Nov 2015 12:42:41 -0800 Subject: [PATCH] Include ability to add tag_prefix Signed-off-by: Zachary Gershman --- README.md | 3 +++ out_command.go | 2 ++ out_command_test.go | 26 ++++++++++++++++++++++++++ resources.go | 1 + 4 files changed, 32 insertions(+) diff --git a/README.md b/README.md index d402516..3ca5464 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,9 @@ matching the patterns in `globs` to the release. * `tag`: *Required.* A path to a file containing the name of the Git tag to use for the release. +* `tag_prefix`: *Optional.* If specified, the tag read from the file will be +prepended with this string. This is useful for adding v in front of version numbers. + * `commitish`: *Optional.* A path to a file containing the commitish (SHA, tag, branch name) that the release should be associated with. diff --git a/out_command.go b/out_command.go index 7c6b388..cfefacd 100644 --- a/out_command.go +++ b/out_command.go @@ -36,6 +36,8 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err return OutResponse{}, err } + tag = request.Params.TagPrefix + tag + var body string bodySpecified := false if request.Params.BodyPath != "" { diff --git a/out_command_test.go b/out_command_test.go index a79e58d..748b3e7 100644 --- a/out_command_test.go +++ b/out_command_test.go @@ -347,5 +347,31 @@ var _ = Describe("Out Command", func() { Ω(err).Should(MatchError("could not find file that matches glob '*.gif'")) }) }) + + Context("when the tag_prefix is set", func() { + BeforeEach(func() { + namePath := filepath.Join(sourcesDir, "name") + tagPath := filepath.Join(sourcesDir, "tag") + + file(namePath, "v0.3.12") + file(tagPath, "0.3.12") + + request = resource.OutRequest{ + Params: resource.OutParams{ + NamePath: "name", + TagPath: "tag", + TagPrefix: "version-", + }, + } + }) + + It("appends the TagPrefix onto the TagName", func() { + Ω(githubClient.CreateReleaseCallCount()).Should(Equal(1)) + release := githubClient.CreateReleaseArgsForCall(0) + + Ω(*release.Name).Should(Equal("v0.3.12")) + Ω(*release.TagName).Should(Equal("version-0.3.12")) + }) + }) }) }) diff --git a/resources.go b/resources.go index ce5ab74..30167b4 100644 --- a/resources.go +++ b/resources.go @@ -41,6 +41,7 @@ type OutParams struct { BodyPath string `json:"body"` TagPath string `json:"tag"` CommitishPath string `json:"commitish"` + TagPrefix string `json:"tag_prefix"` Globs []string `json:"globs"` }