Skip to content
Snippets Groups Projects
Commit 5a2db7e5 authored by Furkan Ayhan's avatar Furkan Ayhan :two: Committed by Shekhar Patnaik
Browse files

feat(release): "release create --tag-message" flag

parent 3292bb19
No related branches found
No related tags found
1 merge request!1771feat(release): "release create --tag-message" flag
......@@ -34,6 +34,7 @@ type CreateOpts struct {
Name string
Ref string
TagName string
TagMessage string
Notes string
NotesFile string
Milestone []string
......@@ -155,6 +156,7 @@ func NewCmdCreate(f *cmdutils.Factory) *cobra.Command {
cmd.Flags().StringVarP(&opts.Name, "name", "n", "", "The release name or title.")
cmd.Flags().StringVarP(&opts.Ref, "ref", "r", "", "If the specified tag doesn't exist, the release is created from ref and tagged with the specified tag name. It can be a commit SHA, another tag name, or a branch name.")
cmd.Flags().StringVarP(&opts.TagMessage, "tag-message", "T", "", "Message to use if creating a new annotated tag.")
cmd.Flags().StringVarP(&opts.Notes, "notes", "N", "", "The release notes or description. You can use Markdown.")
cmd.Flags().StringVarP(&opts.NotesFile, "notes-file", "F", "", "Read release notes 'file'. Specify '-' as the value to read from stdin.")
cmd.Flags().StringVarP(&opts.ReleasedAt, "released-at", "D", "", "The 'date' when the release was ready. Defaults to the current datetime. Expects ISO 8601 format (2019-03-15T08:00:00Z).")
......@@ -328,6 +330,10 @@ func createRun(opts *CreateOpts) error {
createOpts.Ref = &opts.Ref
}
if opts.TagMessage != "" {
createOpts.TagMessage = &opts.TagMessage
}
if opts.ReleasedAt != "" {
createOpts.ReleasedAt = &releasedAt
}
......
......@@ -31,6 +31,7 @@ func TestReleaseCreate(t *testing.T) {
cli string
expectedDescription string
expectedTagMessage string
}{
{
name: "when a release is created",
......@@ -41,6 +42,11 @@ func TestReleaseCreate(t *testing.T) {
cli: `0.0.1 --notes "bugfix release"`,
expectedDescription: "bugfix release",
},
{
name: "when a release is created with a tag message",
cli: `0.0.1 --tag-message "tag message"`,
expectedTagMessage: "tag message",
},
}
for _, tc := range tests {
......@@ -62,6 +68,9 @@ func TestReleaseCreate(t *testing.T) {
if tc.expectedDescription != "" {
assert.Contains(t, string(rb), `"description":"bugfix release"`)
}
if tc.expectedTagMessage != "" {
assert.Contains(t, string(rb), `"tag_message":"tag message"`)
}
resp, _ := httpmock.NewStringResponse(http.StatusCreated,
`{
"name": "test_release",
......
......@@ -80,6 +80,7 @@ $ glab release create v1.0.1 --assets-links='
-F, --notes-file string Read release notes 'file'. Specify '-' as the value to read from stdin.
-r, --ref string If the specified tag doesn't exist, the release is created from ref and tagged with the specified tag name. It can be a commit SHA, another tag name, or a branch name.
-D, --released-at string The 'date' when the release was ready. Defaults to the current datetime. Expects ISO 8601 format (2019-03-15T08:00:00Z).
-T, --tag-message string Message to use if creating a new annotated tag.
```
## Options inherited from parent commands
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment