From 373c47a3ab9825843b4536633c209aa58d96afb0 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 15:16:09 +0000 Subject: [PATCH 01/14] Initial attempt to create set command --- commands/badge/badge.go | 25 +++++++ commands/badge/set/set.go | 81 ++++++++++++++++++++ commands/badge/set/set_test.go | 132 +++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100644 commands/badge/badge.go create mode 100644 commands/badge/set/set.go create mode 100644 commands/badge/set/set_test.go diff --git a/commands/badge/badge.go b/commands/badge/badge.go new file mode 100644 index 000000000..d00a1711a --- /dev/null +++ b/commands/badge/badge.go @@ -0,0 +1,25 @@ +package badge + +import ( + badgeSetCmd "gitlab.com/gitlab-org/cli/commands/badge/set" + + "gitlab.com/gitlab-org/cli/commands/cmdutils" + + "github.com/spf13/cobra" +) + +func NewCmdBadge() *cobra.Command { + badgeCmd := &cobra.Command{ + Use: "badge", + Short: "Manage badges", + Long: `Manage badges for your project.`, + } + + cmdutils.EnableRepoOverride(scheduleCmd, f) + + // Add subcommands + badgeCmd.AddCommand(set.NewCmdBadgeSet()) + + return badgeCmd +} + diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go new file mode 100644 index 000000000..91ffe7b57 --- /dev/null +++ b/commands/badge/set/set.go @@ -0,0 +1,81 @@ +package set + +import ( + "fmt" + "net/url" + + "github.com/spf13/cobra" + "gitlab.com/gitlab-org/cli/api" + "gitlab.com/gitlab-org/cli/commands/cmdutils" + "gitlab.com/gitlab-org/cli/pkg/glrepo" +) + +func NewCmdSet(f *cmdutils.Factory) *cobra.Command { + badgeSetCmd := &cobra.Command{ + Use: "set ", + Short: "Set or update a project badge", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + apiClient, err := f.HttpClient() + if err != nil { + return err + } + + repo, err := f.BaseRepo() + if err != nil { + return err + } + + name := args[0] + value := args[1] + + return setBadge(apiClient, repo, name, value) + }, + } + + return badgeSetCmd +} + +func setBadge(apiClient *api.Client, repo glrepo.Interface, name, value string) error { + project := repo.FullName() + + // First, check if the badge exists + badges, err := api.ListProjectBadges(apiClient, project, &api.ListProjectBadgesOptions{}) + if err != nil { + return err + } + + var existingBadge *api.Badge + for _, badge := range badges { + if badge.Name == name { + existingBadge = badge + break + } + } + + imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", url.PathEscape(name), url.PathEscape(value)) + + if existingBadge == nil { + // Badge doesn't exist, create a new one + _, err = api.AddProjectBadge(apiClient, project, &api.AddProjectBadgeOptions{ + ImageURL: &imageURL, + Name: &name, + }) + if err != nil { + return fmt.Errorf("failed to create badge: %w", err) + } + fmt.Printf("Badge '%s' created successfully\n", name) + } else { + // Badge exists, update it + _, err = api.EditProjectBadge(apiClient, project, existingBadge.ID, &api.EditProjectBadgeOptions{ + ImageURL: &imageURL, + Name: &name, + }) + if err != nil { + return fmt.Errorf("failed to update badge: %w", err) + } + fmt.Printf("Badge '%s' updated successfully\n", name) + } + + return nil +} diff --git a/commands/badge/set/set_test.go b/commands/badge/set/set_test.go new file mode 100644 index 000000000..eba4f060d --- /dev/null +++ b/commands/badge/set/set_test.go @@ -0,0 +1,132 @@ +// Create tests for the functions in set.go. Be sure to use the httpmock library for any external calls though. These are the libraries that should be imported: +// "net/http" +// "testing" +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/require" +// "gitlab.com/gitlab-org/cli/commands/cmdtest" +// "gitlab.com/gitlab-org/cli/pkg/httpmock" +// "gitlab.com/gitlab-org/cli/test" +package set + +import ( + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/cli/commands/cmdtest" + "gitlab.com/gitlab-org/cli/pkg/httpmock" + "gitlab.com/gitlab-org/cli/test" +) + +func TestNewCmdSet(t *testing.T) { + tests := []struct { + name string + cli string + wants SetOptions + wantsErr string + }{ + { + name: "valid input", + cli: "project 123 passing", + wants: SetOptions{ + EntityID: "123", + EntityType: "project", + State: "passing", + }, + }, + { + name: "missing arguments", + cli: "", + wantsErr: "accepts 3 arg(s), received 0", + }, + { + name: "invalid entity type", + cli: "invalid 123 passing", + wantsErr: "invalid entity type: invalid", + }, + { + name: "invalid state", + cli: "project 123 invalid", + wantsErr: "invalid state: invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + io, _, _, _ := cmdtest.InitIOStreams(tt.cli, nil) + cmd := NewCmdSet(io) + cmd.SetArgs(cmdtest.SplitArgs(tt.cli)) + cmd.SetIn(&bytes.Buffer{}) + cmd.SetOut(io.Out) + cmd.SetErr(io.ErrOut) + + _, err := cmd.ExecuteC() + if tt.wantsErr != "" { + require.Error(t, err) + assert.Contains(t, err.Error(), tt.wantsErr) + return + } + + require.NoError(t, err) + assert.Equal(t, tt.wants.EntityID, cmd.Flags().Lookup("id").Value.String()) + assert.Equal(t, tt.wants.EntityType, cmd.Flags().Lookup("type").Value.String()) + assert.Equal(t, tt.wants.State, cmd.Flags().Lookup("state").Value.String()) + }) + } +} + +func TestSetRun(t *testing.T) { + reg := httpmock.Registry{} + defer reg.Verify(t) + + reg.Register( + httpmock.REST("POST", "projects/123/badges"), + httpmock.StringResponse(`{"id": 1, "link_url": "https://example.com", "image_url": "https://example.com/badge.svg"}`), + ) + + io, _, stdout, stderr := cmdtest.InitIOStreams("", nil) + + opts := &SetOptions{ + EntityID: "123", + EntityType: "project", + State: "passing", + IO: io, + HTTPClient: func() (*http.Client, error) { + return &http.Client{Transport: ®}, nil + }, + } + + err := setRun(opts) + require.NoError(t, err) + + assert.Equal(t, "", stderr.String()) + assert.Equal(t, "✓ Badge set successfully\n", stdout.String()) +} + +func TestSetRun_Error(t *testing.T) { + reg := httpmock.Registry{} + defer reg.Verify(t) + + reg.Register( + httpmock.REST("POST", "projects/123/badges"), + httpmock.StatusStringResponse(400, `{"message": "Bad Request"}`), + ) + + io, _, _, _ := cmdtest.InitIOStreams("", nil) + + opts := &SetOptions{ + EntityID: "123", + EntityType: "project", + State: "passing", + IO: io, + HTTPClient: func() (*http.Client, error) { + return &http.Client{Transport: ®}, nil + }, + } + + err := setRun(opts) + require.Error(t, err) + assert.Contains(t, err.Error(), "HTTP 400: Bad Request") +} + -- GitLab From 70139ebaeaf00a6336de68a669b886b076671962 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 15:16:23 +0000 Subject: [PATCH 02/14] remove comment from test --- commands/badge/set/set_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/commands/badge/set/set_test.go b/commands/badge/set/set_test.go index eba4f060d..9d8838629 100644 --- a/commands/badge/set/set_test.go +++ b/commands/badge/set/set_test.go @@ -1,11 +1,3 @@ -// Create tests for the functions in set.go. Be sure to use the httpmock library for any external calls though. These are the libraries that should be imported: -// "net/http" -// "testing" -// "github.com/stretchr/testify/assert" -// "github.com/stretchr/testify/require" -// "gitlab.com/gitlab-org/cli/commands/cmdtest" -// "gitlab.com/gitlab-org/cli/pkg/httpmock" -// "gitlab.com/gitlab-org/cli/test" package set import ( -- GitLab From e904135d627c09d69cf21aed678478d2f86c93b3 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 15:24:32 +0000 Subject: [PATCH 03/14] Update file set.go --- commands/badge/set/set.go | 105 ++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 56 deletions(-) diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 91ffe7b57..6b007bc25 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -1,27 +1,19 @@ -package set - -import ( - "fmt" - "net/url" - - "github.com/spf13/cobra" - "gitlab.com/gitlab-org/cli/api" - "gitlab.com/gitlab-org/cli/commands/cmdutils" - "gitlab.com/gitlab-org/cli/pkg/glrepo" -) - func NewCmdSet(f *cmdutils.Factory) *cobra.Command { badgeSetCmd := &cobra.Command{ Use: "set ", - Short: "Set or update a project badge", - Args: cobra.ExactArgs(2), + Short: "Set or update a badge for a project", + Long: heredoc.Doc(` + Set or update a badge for a project. If the badge doesn't exist, it will be created. + If it already exists, it will be updated. + `), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { apiClient, err := f.HttpClient() if err != nil { return err } - repo, err := f.BaseRepo() + project, err := f.BaseRepo() if err != nil { return err } @@ -29,53 +21,54 @@ func NewCmdSet(f *cmdutils.Factory) *cobra.Command { name := args[0] value := args[1] - return setBadge(apiClient, repo, name, value) - }, - } + // Query existing badges + badges, _, err := apiClient.ProjectBadges.ListProjectBadges(project.FullName(), &gitlab.ListProjectBadgesOptions{}) + if err != nil { + return err + } - return badgeSetCmd -} + var existingBadge *gitlab.ProjectBadge + for _, badge := range badges { + if badge.Name == name { + existingBadge = badge + break + } + } -func setBadge(apiClient *api.Client, repo glrepo.Interface, name, value string) error { - project := repo.FullName() + imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", name, value) - // First, check if the badge exists - badges, err := api.ListProjectBadges(apiClient, project, &api.ListProjectBadgesOptions{}) - if err != nil { - return err - } + if existingBadge == nil { + // Create new badge + badgeOptions := &gitlab.AddProjectBadgeOptions{ + LinkURL: gitlab.String(""), + ImageURL: gitlab.String(imageURL), + Name: gitlab.String(name), + } + _, _, err = apiClient.ProjectBadges.AddProjectBadge(project.FullName(), badgeOptions) + } else { + // Update existing badge + badgeOptions := &gitlab.EditProjectBadgeOptions{ + LinkURL: gitlab.String(""), + ImageURL: gitlab.String(imageURL), + Name: gitlab.String(name), + } + _, _, err = apiClient.ProjectBadges.EditProjectBadge(project.FullName(), existingBadge.ID, badgeOptions) + } - var existingBadge *api.Badge - for _, badge := range badges { - if badge.Name == name { - existingBadge = badge - break - } - } + if err != nil { + return err + } - imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", url.PathEscape(name), url.PathEscape(value)) + if existingBadge == nil { + fmt.Printf("Badge '%s' created successfully\n", name) + } else { + fmt.Printf("Badge '%s' updated successfully\n", name) + } - if existingBadge == nil { - // Badge doesn't exist, create a new one - _, err = api.AddProjectBadge(apiClient, project, &api.AddProjectBadgeOptions{ - ImageURL: &imageURL, - Name: &name, - }) - if err != nil { - return fmt.Errorf("failed to create badge: %w", err) - } - fmt.Printf("Badge '%s' created successfully\n", name) - } else { - // Badge exists, update it - _, err = api.EditProjectBadge(apiClient, project, existingBadge.ID, &api.EditProjectBadgeOptions{ - ImageURL: &imageURL, - Name: &name, - }) - if err != nil { - return fmt.Errorf("failed to update badge: %w", err) - } - fmt.Printf("Badge '%s' updated successfully\n", name) + return nil + }, } - return nil + return badgeSetCmd } + -- GitLab From 7b48c4d97bac2e9b671a77ea12e0f43994ebc571 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 15:41:54 +0000 Subject: [PATCH 04/14] add package at top of file --- commands/badge/set/set.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 6b007bc25..f63537940 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -1,3 +1,5 @@ +package set + func NewCmdSet(f *cmdutils.Factory) *cobra.Command { badgeSetCmd := &cobra.Command{ Use: "set ", -- GitLab From f7c94b63d05759d561349827a3bce54711f23661 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 16:44:11 +0000 Subject: [PATCH 05/14] leverage api function --- api/badge.go | 43 ++++++++++++ commands/badge/set/set.go | 73 +++++++------------ commands/badge/set/set_test.go | 124 --------------------------------- 3 files changed, 68 insertions(+), 172 deletions(-) create mode 100644 api/badge.go diff --git a/api/badge.go b/api/badge.go new file mode 100644 index 000000000..08a8d764a --- /dev/null +++ b/api/badge.go @@ -0,0 +1,43 @@ +package api + +import "github.com/xanzy/go-gitlab" + +func UpdateProjectBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) error { + // List existing badges + badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, nil) + if err != nil { + return fmt.Errorf("error listing project badges: %v", err) + } + + // Check if badge exists + var existingBadge *gitlab.ProjectBadge + for _, badge := range badges { + if badge.Name == badgeName { + existingBadge = badge + break + } + } + + // Prepare badge options + badgeOptions := &gitlab.AddProjectBadgeOptions{ + LinkURL: gitlab.String(fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", badgeName, badgeValue)), + ImageURL: gitlab.String(fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", badgeName, badgeValue)), + Name: gitlab.String(badgeName), + } + + if existingBadge == nil { + // Create new badge + _, _, err = client.ProjectBadges.AddProjectBadge(projectID, badgeOptions) + if err != nil { + return fmt.Errorf("error creating project badge: %v", err) + } + } else { + // Update existing badge + _, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, badgeOptions) + if err != nil { + return fmt.Errorf("error updating project badge: %v", err) + } + } + + return nil +} diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index f63537940..8bf2adf20 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -1,70 +1,48 @@ package set +import ( + "fmt" + "strings" + + "gitlab.com/gitlab-org/cli/api" + "gitlab.com/gitlab-org/cli/commands/cmdutils" + "github.com/MakeNowJust/heredoc/v2" + "github.com/spf13/cobra" + "github.com/xanzy/go-gitlab" +) + func NewCmdSet(f *cmdutils.Factory) *cobra.Command { badgeSetCmd := &cobra.Command{ - Use: "set ", - Short: "Set or update a badge for a project", - Long: heredoc.Doc(` - Set or update a badge for a project. If the badge doesn't exist, it will be created. - If it already exists, it will be updated. + Use: "set ", + Short: "Set a badge for a project", + Long: heredoc.Docf(` + Set a badge for a project. + + The badge will be created if it doesn't exist, or updated if it already exists. `), - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { apiClient, err := f.HttpClient() if err != nil { return err } - project, err := f.BaseRepo() - if err != nil { - return err - } - - name := args[0] - value := args[1] + project := args[0] + name := args[1] + value := args[2] - // Query existing badges - badges, _, err := apiClient.ProjectBadges.ListProjectBadges(project.FullName(), &gitlab.ListProjectBadgesOptions{}) + projectID, err := api.ProjectID(apiClient, project) if err != nil { return err } - var existingBadge *gitlab.ProjectBadge - for _, badge := range badges { - if badge.Name == name { - existingBadge = badge - break - } - } - - imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", name, value) - - if existingBadge == nil { - // Create new badge - badgeOptions := &gitlab.AddProjectBadgeOptions{ - LinkURL: gitlab.String(""), - ImageURL: gitlab.String(imageURL), - Name: gitlab.String(name), - } - _, _, err = apiClient.ProjectBadges.AddProjectBadge(project.FullName(), badgeOptions) - } else { - // Update existing badge - badgeOptions := &gitlab.EditProjectBadgeOptions{ - LinkURL: gitlab.String(""), - ImageURL: gitlab.String(imageURL), - Name: gitlab.String(name), - } - _, _, err = apiClient.ProjectBadges.EditProjectBadge(project.FullName(), existingBadge.ID, badgeOptions) - } - + badge, err := api.UpdateProjectBadge(apiClient, projectID, name, value) if err != nil { return err } - if existingBadge == nil { - fmt.Printf("Badge '%s' created successfully\n", name) - } else { - fmt.Printf("Badge '%s' updated successfully\n", name) + if badge != nil { + fmt.Fprintf(f.IO.StdOut, "Badge '%s' set for project '%s'\n", name, project) } return nil @@ -73,4 +51,3 @@ func NewCmdSet(f *cmdutils.Factory) *cobra.Command { return badgeSetCmd } - diff --git a/commands/badge/set/set_test.go b/commands/badge/set/set_test.go index 9d8838629..e69de29bb 100644 --- a/commands/badge/set/set_test.go +++ b/commands/badge/set/set_test.go @@ -1,124 +0,0 @@ -package set - -import ( - "net/http" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/cli/commands/cmdtest" - "gitlab.com/gitlab-org/cli/pkg/httpmock" - "gitlab.com/gitlab-org/cli/test" -) - -func TestNewCmdSet(t *testing.T) { - tests := []struct { - name string - cli string - wants SetOptions - wantsErr string - }{ - { - name: "valid input", - cli: "project 123 passing", - wants: SetOptions{ - EntityID: "123", - EntityType: "project", - State: "passing", - }, - }, - { - name: "missing arguments", - cli: "", - wantsErr: "accepts 3 arg(s), received 0", - }, - { - name: "invalid entity type", - cli: "invalid 123 passing", - wantsErr: "invalid entity type: invalid", - }, - { - name: "invalid state", - cli: "project 123 invalid", - wantsErr: "invalid state: invalid", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - io, _, _, _ := cmdtest.InitIOStreams(tt.cli, nil) - cmd := NewCmdSet(io) - cmd.SetArgs(cmdtest.SplitArgs(tt.cli)) - cmd.SetIn(&bytes.Buffer{}) - cmd.SetOut(io.Out) - cmd.SetErr(io.ErrOut) - - _, err := cmd.ExecuteC() - if tt.wantsErr != "" { - require.Error(t, err) - assert.Contains(t, err.Error(), tt.wantsErr) - return - } - - require.NoError(t, err) - assert.Equal(t, tt.wants.EntityID, cmd.Flags().Lookup("id").Value.String()) - assert.Equal(t, tt.wants.EntityType, cmd.Flags().Lookup("type").Value.String()) - assert.Equal(t, tt.wants.State, cmd.Flags().Lookup("state").Value.String()) - }) - } -} - -func TestSetRun(t *testing.T) { - reg := httpmock.Registry{} - defer reg.Verify(t) - - reg.Register( - httpmock.REST("POST", "projects/123/badges"), - httpmock.StringResponse(`{"id": 1, "link_url": "https://example.com", "image_url": "https://example.com/badge.svg"}`), - ) - - io, _, stdout, stderr := cmdtest.InitIOStreams("", nil) - - opts := &SetOptions{ - EntityID: "123", - EntityType: "project", - State: "passing", - IO: io, - HTTPClient: func() (*http.Client, error) { - return &http.Client{Transport: ®}, nil - }, - } - - err := setRun(opts) - require.NoError(t, err) - - assert.Equal(t, "", stderr.String()) - assert.Equal(t, "✓ Badge set successfully\n", stdout.String()) -} - -func TestSetRun_Error(t *testing.T) { - reg := httpmock.Registry{} - defer reg.Verify(t) - - reg.Register( - httpmock.REST("POST", "projects/123/badges"), - httpmock.StatusStringResponse(400, `{"message": "Bad Request"}`), - ) - - io, _, _, _ := cmdtest.InitIOStreams("", nil) - - opts := &SetOptions{ - EntityID: "123", - EntityType: "project", - State: "passing", - IO: io, - HTTPClient: func() (*http.Client, error) { - return &http.Client{Transport: ®}, nil - }, - } - - err := setRun(opts) - require.Error(t, err) - assert.Contains(t, err.Error(), "HTTP 400: Bad Request") -} - -- GitLab From 633ff935458c2cdb75d869146c80b6941b44b71b Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 16:51:55 +0000 Subject: [PATCH 06/14] fix syntax --- api/badge.go | 2 +- commands/badge/set/set.go | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/api/badge.go b/api/badge.go index 08a8d764a..55a010a97 100644 --- a/api/badge.go +++ b/api/badge.go @@ -39,5 +39,5 @@ func UpdateProjectBadge(client *gitlab.Client, projectID int, badgeName, badgeVa } } - return nil + return err } diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 8bf2adf20..4b078f7b0 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -2,13 +2,11 @@ package set import ( "fmt" - "strings" - "gitlab.com/gitlab-org/cli/api" - "gitlab.com/gitlab-org/cli/commands/cmdutils" "github.com/MakeNowJust/heredoc/v2" "github.com/spf13/cobra" - "github.com/xanzy/go-gitlab" + "gitlab.com/gitlab-org/cli/api" + "gitlab.com/gitlab-org/cli/commands/cmdutils" ) func NewCmdSet(f *cmdutils.Factory) *cobra.Command { @@ -27,23 +25,16 @@ func NewCmdSet(f *cmdutils.Factory) *cobra.Command { return err } - project := args[0] - name := args[1] - value := args[2] - - projectID, err := api.ProjectID(apiClient, project) + // rewrite project := args[0] so that args[0] is an int + projectID, err := cmdutils.ParseID(args[0]) if err != nil { - return err + return fmt.Errorf("failed to parse project ID: %w", err) } - badge, err := api.UpdateProjectBadge(apiClient, projectID, name, value) - if err != nil { - return err - } + name := args[1] + value := args[2] - if badge != nil { - fmt.Fprintf(f.IO.StdOut, "Badge '%s' set for project '%s'\n", name, project) - } + api.UpdateProjectBadge(apiClient, projectID, name, value) return nil }, -- GitLab From 328cc806a78159227d5b9bde1765680e283164de Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 21:32:27 +0000 Subject: [PATCH 07/14] First commit --- api/badge.go | 93 +++++++++++++++++++--------------- commands/badge/badge.go | 24 --------- commands/badge/set/set.go | 43 ---------------- commands/badge/set/set_test.go | 2 + 4 files changed, 55 insertions(+), 107 deletions(-) diff --git a/api/badge.go b/api/badge.go index 55a010a97..5ea25fc93 100644 --- a/api/badge.go +++ b/api/badge.go @@ -1,43 +1,56 @@ package api -import "github.com/xanzy/go-gitlab" - -func UpdateProjectBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) error { - // List existing badges - badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, nil) - if err != nil { - return fmt.Errorf("error listing project badges: %v", err) - } - - // Check if badge exists - var existingBadge *gitlab.ProjectBadge - for _, badge := range badges { - if badge.Name == badgeName { - existingBadge = badge - break - } - } - - // Prepare badge options - badgeOptions := &gitlab.AddProjectBadgeOptions{ - LinkURL: gitlab.String(fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", badgeName, badgeValue)), - ImageURL: gitlab.String(fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", badgeName, badgeValue)), - Name: gitlab.String(badgeName), - } - - if existingBadge == nil { - // Create new badge - _, _, err = client.ProjectBadges.AddProjectBadge(projectID, badgeOptions) - if err != nil { - return fmt.Errorf("error creating project badge: %v", err) - } - } else { - // Update existing badge - _, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, badgeOptions) - if err != nil { - return fmt.Errorf("error updating project badge: %v", err) - } - } - - return err +import ( + "fmt" + "net/url" + + "github.com/xanzy/go-gitlab" +) + +var CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) (*gitlab.ProjectBadge, error) { + // List existing badges + badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, nil) + if err != nil { + return nil, fmt.Errorf("error listing project badges: %w", err) + } + + // Check if badge exists + var existingBadge *gitlab.ProjectBadge + for _, badge := range badges { + if badge.Name == badgeName { + existingBadge = badge + break + } + } + + // Prepare badge options + imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", url.PathEscape(badgeName), url.PathEscape(badgeValue)) + badgeOptions := &gitlab.AddProjectBadgeOptions{ + LinkURL: gitlab.String("https://example.com"), // You might want to customize this + ImageURL: gitlab.String(imageURL), + Name: gitlab.String(badgeName), + } + + var badge *gitlab.ProjectBadge + + if existingBadge == nil { + // Create new badge + badge, _, err = client.ProjectBadges.AddProjectBadge(projectID, badgeOptions) + if err != nil { + return nil, fmt.Errorf("error creating project badge: %w", err) + } + } else { + // Update existing badge + updateOptions := &gitlab.EditProjectBadgeOptions{ + LinkURL: badgeOptions.LinkURL, + ImageURL: badgeOptions.ImageURL, + Name: badgeOptions.Name, + } + badge, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, updateOptions) + if err != nil { + return nil, fmt.Errorf("error updating project badge: %w", err) + } + } + + return badge, nil } diff --git a/commands/badge/badge.go b/commands/badge/badge.go index d00a1711a..3ec866892 100644 --- a/commands/badge/badge.go +++ b/commands/badge/badge.go @@ -1,25 +1 @@ package badge - -import ( - badgeSetCmd "gitlab.com/gitlab-org/cli/commands/badge/set" - - "gitlab.com/gitlab-org/cli/commands/cmdutils" - - "github.com/spf13/cobra" -) - -func NewCmdBadge() *cobra.Command { - badgeCmd := &cobra.Command{ - Use: "badge", - Short: "Manage badges", - Long: `Manage badges for your project.`, - } - - cmdutils.EnableRepoOverride(scheduleCmd, f) - - // Add subcommands - badgeCmd.AddCommand(set.NewCmdBadgeSet()) - - return badgeCmd -} - diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 4b078f7b0..05e26e380 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -1,44 +1 @@ package set - -import ( - "fmt" - - "github.com/MakeNowJust/heredoc/v2" - "github.com/spf13/cobra" - "gitlab.com/gitlab-org/cli/api" - "gitlab.com/gitlab-org/cli/commands/cmdutils" -) - -func NewCmdSet(f *cmdutils.Factory) *cobra.Command { - badgeSetCmd := &cobra.Command{ - Use: "set ", - Short: "Set a badge for a project", - Long: heredoc.Docf(` - Set a badge for a project. - - The badge will be created if it doesn't exist, or updated if it already exists. - `), - Args: cobra.ExactArgs(3), - RunE: func(cmd *cobra.Command, args []string) error { - apiClient, err := f.HttpClient() - if err != nil { - return err - } - - // rewrite project := args[0] so that args[0] is an int - projectID, err := cmdutils.ParseID(args[0]) - if err != nil { - return fmt.Errorf("failed to parse project ID: %w", err) - } - - name := args[1] - value := args[2] - - api.UpdateProjectBadge(apiClient, projectID, name, value) - - return nil - }, - } - - return badgeSetCmd -} diff --git a/commands/badge/set/set_test.go b/commands/badge/set/set_test.go index e69de29bb..082fdc524 100644 --- a/commands/badge/set/set_test.go +++ b/commands/badge/set/set_test.go @@ -0,0 +1,2 @@ +package set + \ No newline at end of file -- GitLab From 4d9e36f2e9889baee43b25af3e4622507372e257 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 21:36:07 +0000 Subject: [PATCH 08/14] apply from local machine --- api/badge.go | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/api/badge.go b/api/badge.go index 5ea25fc93..18407b41d 100644 --- a/api/badge.go +++ b/api/badge.go @@ -7,11 +7,11 @@ import ( "github.com/xanzy/go-gitlab" ) -var CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) (*gitlab.ProjectBadge, error) { +func createOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) (*gitlab.ProjectBadge, error) { // List existing badges - badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, nil) + badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, &gitlab.ListProjectBadgesOptions{}) if err != nil { - return nil, fmt.Errorf("error listing project badges: %w", err) + return nil, fmt.Errorf("error listing badges: %v", err) } // Check if badge exists @@ -23,32 +23,29 @@ var CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeVa } } - // Prepare badge options + // Prepare badge data imageURL := fmt.Sprintf("https://img.shields.io/badge/%s-%s-blue", url.PathEscape(badgeName), url.PathEscape(badgeValue)) - badgeOptions := &gitlab.AddProjectBadgeOptions{ - LinkURL: gitlab.String("https://example.com"), // You might want to customize this - ImageURL: gitlab.String(imageURL), - Name: gitlab.String(badgeName), - } var badge *gitlab.ProjectBadge - if existingBadge == nil { + badgeOptions := &gitlab.AddProjectBadgeOptions{ + Name: gitlab.Ptr(badgeName), + ImageURL: gitlab.Ptr(imageURL), + } // Create new badge badge, _, err = client.ProjectBadges.AddProjectBadge(projectID, badgeOptions) if err != nil { - return nil, fmt.Errorf("error creating project badge: %w", err) + return nil, fmt.Errorf("error creating badge: %v", err) } } else { - // Update existing badge - updateOptions := &gitlab.EditProjectBadgeOptions{ - LinkURL: badgeOptions.LinkURL, - ImageURL: badgeOptions.ImageURL, - Name: badgeOptions.Name, + badgeOptions := &gitlab.EditProjectBadgeOptions{ + Name: gitlab.Ptr(badgeName), + ImageURL: gitlab.Ptr(imageURL), } - badge, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, updateOptions) + // Update existing badge + badge, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, badgeOptions) if err != nil { - return nil, fmt.Errorf("error updating project badge: %w", err) + return nil, fmt.Errorf("error updating badge: %v", err) } } -- GitLab From 116aad77240ca3792f363707fbe1a25b8c86cf26 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 22:01:36 +0000 Subject: [PATCH 09/14] add NewCmdSet --- api/badge.go | 2 +- commands/badge/set/set.go | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/api/badge.go b/api/badge.go index 18407b41d..25f996160 100644 --- a/api/badge.go +++ b/api/badge.go @@ -7,7 +7,7 @@ import ( "github.com/xanzy/go-gitlab" ) -func createOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) (*gitlab.ProjectBadge, error) { +func CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeValue string) (*gitlab.ProjectBadge, error) { // List existing badges badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, &gitlab.ListProjectBadgesOptions{}) if err != nil { diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 05e26e380..41583f4b3 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -1 +1,51 @@ package set + +import ( + "fmt" + "github.com/spf13/cobra" + "github.com/xanzy/go-gitlab" + "gitlab.com/gitlab-org/cli/api" + "gitlab.com/gitlab-org/cli/commands/cmdutils" + "gitlab.com/gitlab-org/cli/internal/glrepo" + "gitlab.com/gitlab-org/cli/pkg/iostreams" +) + +type BadgeOptions struct { + ProjectID int + APIClient *gitlab.Client + + IO *iostreams.IOStreams + Repo glrepo.Interface +} + +func NewCmdSet(f *cmdutils.Factory) *cobra.Command { + badgeSetCmd := &cobra.Command{ + Use: "set ", + Short: "Set a badge for a project", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + apiClient, err := f.HttpClient() + if err != nil { + return err + } + + opts := &BadgeOptions{} + + badgeName := args[0] + badgeValue := args[1] + + badge, err := api.CreateOrUpdateBadge(apiClient, opts.ProjectID, badgeName, badgeValue) + if err != nil { + return fmt.Errorf("error setting badge: %v", err) + } + + if badge != nil { + fmt.Fprintf(f.IO.StdOut, "Badge '%s' set successfully with value '%s'\n", badgeName, badgeValue) + } + + return nil + }, + } + + return badgeSetCmd +} -- GitLab From f7bd85339b5d0ab52260aee1935c946c112c6258 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Wed, 18 Sep 2024 22:13:43 +0000 Subject: [PATCH 10/14] re-run gofumpt --- commands/badge/set/set.go | 1 + commands/badge/set/set_test.go | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index 41583f4b3..a79ed0e9c 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -2,6 +2,7 @@ package set import ( "fmt" + "github.com/spf13/cobra" "github.com/xanzy/go-gitlab" "gitlab.com/gitlab-org/cli/api" diff --git a/commands/badge/set/set_test.go b/commands/badge/set/set_test.go index 082fdc524..05e26e380 100644 --- a/commands/badge/set/set_test.go +++ b/commands/badge/set/set_test.go @@ -1,2 +1 @@ package set - \ No newline at end of file -- GitLab From 41534c3434dfea6c654f4765793fa1c80d585002 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Thu, 19 Sep 2024 00:47:54 +0000 Subject: [PATCH 11/14] First full run --- api/badge.go | 32 ++++++++++++++++++++++ commands/badge/badge.go | 20 ++++++++++++++ commands/badge/remove/remove.go | 48 +++++++++++++++++++++++++++++++++ commands/badge/set/set.go | 11 ++++++++ commands/root.go | 2 ++ 5 files changed, 113 insertions(+) create mode 100644 commands/badge/remove/remove.go diff --git a/api/badge.go b/api/badge.go index 25f996160..17d05b49a 100644 --- a/api/badge.go +++ b/api/badge.go @@ -31,6 +31,7 @@ func CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeV badgeOptions := &gitlab.AddProjectBadgeOptions{ Name: gitlab.Ptr(badgeName), ImageURL: gitlab.Ptr(imageURL), + LinkURL: gitlab.Ptr(imageURL), } // Create new badge badge, _, err = client.ProjectBadges.AddProjectBadge(projectID, badgeOptions) @@ -41,6 +42,7 @@ func CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeV badgeOptions := &gitlab.EditProjectBadgeOptions{ Name: gitlab.Ptr(badgeName), ImageURL: gitlab.Ptr(imageURL), + LinkURL: gitlab.Ptr(imageURL), } // Update existing badge badge, _, err = client.ProjectBadges.EditProjectBadge(projectID, existingBadge.ID, badgeOptions) @@ -51,3 +53,33 @@ func CreateOrUpdateBadge(client *gitlab.Client, projectID int, badgeName, badgeV return badge, nil } + +// create a func to delete a badget given the project id and badge name +func DeleteBadge(client *gitlab.Client, projectID int, badgeName string) error { + // List existing badges + badges, _, err := client.ProjectBadges.ListProjectBadges(projectID, &gitlab.ListProjectBadgesOptions{}) + if err != nil { + return fmt.Errorf("error listing badges: %v", err) + } + + // Find the badge with the given name + var badgeID int + for _, badge := range badges { + if badge.Name == badgeName { + badgeID = badge.ID + break + } + } + + if badgeID == 0 { + return fmt.Errorf("badge with name '%s' not found", badgeName) + } + + // Delete the badge + _, err = client.ProjectBadges.DeleteProjectBadge(projectID, badgeID) + if err != nil { + return fmt.Errorf("error deleting badge: %v", err) + } + + return nil +} diff --git a/commands/badge/badge.go b/commands/badge/badge.go index 3ec866892..c1a51a592 100644 --- a/commands/badge/badge.go +++ b/commands/badge/badge.go @@ -1 +1,21 @@ package badge + +import ( + "github.com/spf13/cobra" + "gitlab.com/gitlab-org/cli/commands/badge/remove" + "gitlab.com/gitlab-org/cli/commands/badge/set" + "gitlab.com/gitlab-org/cli/commands/cmdutils" +) + +func NewCmdBadge(f *cmdutils.Factory) *cobra.Command { + badgeCmd := &cobra.Command{ + Use: "badge", + Short: "Manage project badges", + Long: `Work with GitLab project badges`, + } + + badgeCmd.AddCommand(set.NewCmdSet(f)) + badgeCmd.AddCommand(remove.NewCmdRemove(f)) + + return badgeCmd +} diff --git a/commands/badge/remove/remove.go b/commands/badge/remove/remove.go new file mode 100644 index 000000000..d76668222 --- /dev/null +++ b/commands/badge/remove/remove.go @@ -0,0 +1,48 @@ +package remove + +import ( + "fmt" + + "github.com/spf13/cobra" + "gitlab.com/gitlab-org/cli/api" + "gitlab.com/gitlab-org/cli/commands/cmdutils" +) + +// create NewCmdRemove function that relies upon the DeleteBadge function +func NewCmdRemove(f *cmdutils.Factory) *cobra.Command { + badgeRemoveCmd := &cobra.Command{ + Use: "remove ", + Short: "Remove a badge from a project", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + apiClient, err := f.HttpClient() + if err != nil { + return err + } + + projectID, err := cmd.Flags().GetInt("project-id") + if err != nil { + return err + } + + if projectID <= 0 { + return fmt.Errorf("error removing badge: --project-id is required") + } + + badgeName := args[0] + + err = api.DeleteBadge(apiClient, projectID, badgeName) + if err != nil { + return fmt.Errorf("error removing badge: %v", err) + } + + fmt.Fprintf(f.IO.StdOut, "Badge '%s' removed successfully\n", badgeName) + return nil + }, + } + + badgeRemoveCmd.Flags().Int("project-id", 0, "The ID of the project") + _ = badgeRemoveCmd.MarkFlagRequired("project-id") + + return badgeRemoveCmd +} diff --git a/commands/badge/set/set.go b/commands/badge/set/set.go index a79ed0e9c..afcaa164b 100644 --- a/commands/badge/set/set.go +++ b/commands/badge/set/set.go @@ -32,6 +32,13 @@ func NewCmdSet(f *cmdutils.Factory) *cobra.Command { opts := &BadgeOptions{} + // Set the config file + if s, _ := cmd.Flags().GetInt("project-id"); s > 0 { + opts.ProjectID = s + } else { + return fmt.Errorf("error setting badge without --project-id") + } + badgeName := args[0] badgeValue := args[1] @@ -48,5 +55,9 @@ func NewCmdSet(f *cmdutils.Factory) *cobra.Command { }, } + // changelogGenerateCmd.Flags().StringP("config-file", "", "", "Path of the changelog configuration file in the project's Git repository. Defaults to '.gitlab/changelog_config.yml'.") + // add a flag for project-id + badgeSetCmd.Flags().Int("project-id", 0, "The ID of the project") + return badgeSetCmd } diff --git a/commands/root.go b/commands/root.go index 9917f6b70..a5aa0cf5c 100644 --- a/commands/root.go +++ b/commands/root.go @@ -9,6 +9,7 @@ import ( aliasCmd "gitlab.com/gitlab-org/cli/commands/alias" apiCmd "gitlab.com/gitlab-org/cli/commands/api" authCmd "gitlab.com/gitlab-org/cli/commands/auth" + badgeCmd "gitlab.com/gitlab-org/cli/commands/badge" changelogCmd "gitlab.com/gitlab-org/cli/commands/changelog" pipelineCmd "gitlab.com/gitlab-org/cli/commands/ci" clusterCmd "gitlab.com/gitlab-org/cli/commands/cluster" @@ -105,6 +106,7 @@ func NewCmdRoot(f *cmdutils.Factory, version, buildDate string) *cobra.Command { // Child commands rootCmd.AddCommand(aliasCmd.NewCmdAlias(f)) + rootCmd.AddCommand(badgeCmd.NewCmdBadge(f)) rootCmd.AddCommand(configCmd.NewCmdConfig(f)) rootCmd.AddCommand(completionCmd.NewCmdCompletion(f.IO)) rootCmd.AddCommand(versionCmd.NewCmdVersion(f.IO, version, buildDate)) -- GitLab From da637f1377001bfd284d6ba6776d45aa1b42f300 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Thu, 19 Sep 2024 00:54:06 +0000 Subject: [PATCH 12/14] Add docs --- docs/source/badge/help.md | 24 ++++++++++++++++++++++++ docs/source/badge/index.md | 28 ++++++++++++++++++++++++++++ docs/source/badge/remove.md | 30 ++++++++++++++++++++++++++++++ docs/source/badge/set.md | 30 ++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 docs/source/badge/help.md create mode 100644 docs/source/badge/index.md create mode 100644 docs/source/badge/remove.md create mode 100644 docs/source/badge/set.md diff --git a/docs/source/badge/help.md b/docs/source/badge/help.md new file mode 100644 index 000000000..2438b6869 --- /dev/null +++ b/docs/source/badge/help.md @@ -0,0 +1,24 @@ +--- +stage: Create +group: Code Review +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments +--- + + + +# `glab badge help` + +Help about any command + +```plaintext +glab badge help [command] [flags] +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for this command. +``` diff --git a/docs/source/badge/index.md b/docs/source/badge/index.md new file mode 100644 index 000000000..934b6c6a3 --- /dev/null +++ b/docs/source/badge/index.md @@ -0,0 +1,28 @@ +--- +stage: Create +group: Code Review +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments +--- + + + +# `glab badge` + +Manage project badges + +## Synopsis + +Work with GitLab project badges +## Options inherited from parent commands + +```plaintext + --help Show help for this command. +``` + +## Subcommands + +- [`remove`](remove.md) +- [`set`](set.md) diff --git a/docs/source/badge/remove.md b/docs/source/badge/remove.md new file mode 100644 index 000000000..50c7a30a1 --- /dev/null +++ b/docs/source/badge/remove.md @@ -0,0 +1,30 @@ +--- +stage: Create +group: Code Review +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments +--- + + + +# `glab badge remove` + +Remove a badge from a project + +```plaintext +glab badge remove [flags] +``` + +## Options + +```plaintext + --project-id int The ID of the project +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for this command. +``` diff --git a/docs/source/badge/set.md b/docs/source/badge/set.md new file mode 100644 index 000000000..faca067cc --- /dev/null +++ b/docs/source/badge/set.md @@ -0,0 +1,30 @@ +--- +stage: Create +group: Code Review +info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments +--- + + + +# `glab badge set` + +Set a badge for a project + +```plaintext +glab badge set [flags] +``` + +## Options + +```plaintext + --project-id int The ID of the project +``` + +## Options inherited from parent commands + +```plaintext + --help Show help for this command. +``` -- GitLab From 334942d2ef31a3991a1f1a5beeddaaac03111d42 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Thu, 19 Sep 2024 00:57:20 +0000 Subject: [PATCH 13/14] Add space in docs --- docs/source/badge/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/badge/index.md b/docs/source/badge/index.md index 934b6c6a3..5f0d2ef10 100644 --- a/docs/source/badge/index.md +++ b/docs/source/badge/index.md @@ -16,6 +16,7 @@ Manage project badges ## Synopsis Work with GitLab project badges + ## Options inherited from parent commands ```plaintext -- GitLab From 73145915deb585ab00d584ede0309d2560f31049 Mon Sep 17 00:00:00 2001 From: Tim Poffenbarger Date: Thu, 19 Sep 2024 01:05:31 +0000 Subject: [PATCH 14/14] feat(badges): add badges to projects - set a badge - remove a badge Delivers #7658 --- commands/badge/badge.go | 1 - docs/source/badge/index.md | 4 ---- 2 files changed, 5 deletions(-) diff --git a/commands/badge/badge.go b/commands/badge/badge.go index c1a51a592..85707df2b 100644 --- a/commands/badge/badge.go +++ b/commands/badge/badge.go @@ -11,7 +11,6 @@ func NewCmdBadge(f *cmdutils.Factory) *cobra.Command { badgeCmd := &cobra.Command{ Use: "badge", Short: "Manage project badges", - Long: `Work with GitLab project badges`, } badgeCmd.AddCommand(set.NewCmdSet(f)) diff --git a/docs/source/badge/index.md b/docs/source/badge/index.md index 5f0d2ef10..51fb3e73b 100644 --- a/docs/source/badge/index.md +++ b/docs/source/badge/index.md @@ -13,10 +13,6 @@ Please do not edit this file directly. Run `make gen-docs` instead. Manage project badges -## Synopsis - -Work with GitLab project badges - ## Options inherited from parent commands ```plaintext -- GitLab