Skip to content

Commit 9951c61

Browse files
Sazon, John Bryan Jbzon
authored andcommitted
new_tag: update the description flag usage and add test setup
1 parent 5db3db8 commit 9951c61

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

cmd/new_tag.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ var newTagCmd = &cobra.Command{
2929
Aliases: []string{"t"},
3030
Short: "Create a new tag for a specified project",
3131
Example: `# create tag from master branch for project groupx/myapp
32-
gitlabctl new tag v2.0 --project=groupx/myapp --ref=master`,
32+
gitlabctl new tag v2.0 --project=groupx/myapp --ref=master
33+
34+
# create a tag and create a release from it
35+
gitlabctl new tag v2.1 --project=groupx/myapp --ref=master --description="Released!"
36+
37+
# NOTE: You can also use 'gitlabctl new release' to create a release separately.`,
3338
SilenceErrors: true,
3439
SilenceUsage: true,
3540
DisableAutoGenTag: true,
@@ -49,7 +54,7 @@ func init() {
4954
newTagCmd.Flags().StringP("message", "m", "",
5055
"Creates annotated tag")
5156
newTagCmd.Flags().StringP("description", "d", "",
52-
"Add release notes to the git tag")
57+
"Create a release from the git tag with the description as the release note")
5358
}
5459

5560
func runNewTag(cmd *cobra.Command, tag string) error {
@@ -66,7 +71,7 @@ func runNewTag(cmd *cobra.Command, tag string) error {
6671
return nil
6772
}
6873

69-
func newTag(project string, opts *gitlab.CreateTagOptions ) (*gitlab.Tag, error) {
74+
func newTag(project string, opts *gitlab.CreateTagOptions) (*gitlab.Tag, error) {
7075
git, err := newGitlabClient()
7176
if err != nil {
7277
return nil, err

cmd/new_tag_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ func TestNewTag(t *testing.T) {
3838
"project": "Group1/project1",
3939
"ref": "master",
4040
},
41-
args: []string{"v2.0"},
41+
args: []string{"v2.0-newtag"},
4242
expect: pass,
4343
},
4444
{
4545
name: "create a new tag with release note",
4646
flagsMap: map[string]string{
4747
"project": "Group1/project1",
4848
"ref": "master",
49-
"message": "v2.0",
49+
"message": "v2.0-newtag",
5050
"description": "Sample Release Note",
5151
},
52-
args: []string{"v2.0"},
52+
args: []string{"v2.0-newtag"},
5353
expect: pass,
5454
},
5555
{
@@ -60,6 +60,12 @@ func TestNewTag(t *testing.T) {
6060
}
6161

6262
for _, tc := range tt {
63+
// SETUP
64+
// Ensure that the tag to create is deleted
65+
if tc.expect == pass {
66+
err := deleteTag(tc.flagsMap["project"], tc.args[0])
67+
tInfo(err)
68+
}
6369
t.Run(tc.name, func(t *testing.T) {
6470
execT := execTestCmdFlags{
6571
t: t,

0 commit comments

Comments
 (0)