Skip to content

Commit

Permalink
Merge pull request #1377 from erkanzileli/feat/badge-name
Browse files Browse the repository at this point in the history
feat: add project badge names
  • Loading branch information
svanharmelen authored Feb 11, 2022
2 parents dfa5223 + cdc1aa1 commit 60dfa37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion project_badges.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
// https://docs.gitlab.com/ee/api/project_badges.html#list-all-badges-of-a-project
type ProjectBadge struct {
ID int `json:"id"`
Name string `json:"name"`
LinkURL string `json:"link_url"`
ImageURL string `json:"image_url"`
RenderedLinkURL string `json:"rendered_link_url"`
Expand All @@ -48,7 +49,10 @@ type ProjectBadgesService struct {
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_badges.html#list-all-badges-of-a-project
type ListProjectBadgesOptions ListOptions
type ListProjectBadgesOptions struct {
ListOptions
Name *string `url:"name,omitempty" json:"name,omitempty"`
}

// ListProjectBadges gets a list of a project's badges and its group badges.
//
Expand Down Expand Up @@ -107,6 +111,7 @@ func (s *ProjectBadgesService) GetProjectBadge(pid interface{}, badge int, optio
type AddProjectBadgeOptions struct {
LinkURL *string `url:"link_url,omitempty" json:"link_url,omitempty"`
ImageURL *string `url:"image_url,omitempty" json:"image_url,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
}

// AddProjectBadge adds a badge to a project.
Expand Down Expand Up @@ -141,6 +146,7 @@ func (s *ProjectBadgesService) AddProjectBadge(pid interface{}, opt *AddProjectB
type EditProjectBadgeOptions struct {
LinkURL *string `url:"link_url,omitempty" json:"link_url,omitempty"`
ImageURL *string `url:"image_url,omitempty" json:"image_url,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
}

// EditProjectBadge updates a badge of a project.
Expand Down
4 changes: 4 additions & 0 deletions project_badges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestProjectBadgesService_ListProjectBadges(t *testing.T) {

want := []*ProjectBadge{{
ID: 1,
Name: "Coverage",
LinkURL: "http://example.com/ci_status.svg?project={project_path}&ref={default_branch}",
ImageURL: "https://shields.io/my/badge",
RenderedLinkURL: "http://example.com/ci_status.svg?project=example-org/example-project&ref=master",
Expand Down Expand Up @@ -80,6 +81,7 @@ func TestProjectBadgesService_GetProjectBadge(t *testing.T) {

want := &ProjectBadge{
ID: 1,
Name: "Coverage",
LinkURL: "http://example.com/ci_status.svg?project={project_path}&ref={default_branch}",
ImageURL: "https://shields.io/my/badge",
RenderedLinkURL: "http://example.com/ci_status.svg?project=example-org/example-project&ref=master",
Expand Down Expand Up @@ -129,6 +131,7 @@ func TestProjectBadgesService_AddProjectBadge(t *testing.T) {

want := &ProjectBadge{
ID: 1,
Name: "mybadge",
LinkURL: "http://example.com/ci_status.svg?project={project_path}&ref={default_branch}",
ImageURL: "https://shields.io/my/badge",
RenderedLinkURL: "http://example.com/ci_status.svg?project=example-org/example-project&ref=master",
Expand Down Expand Up @@ -178,6 +181,7 @@ func TestProjectBadgesService_EditProjectBadge(t *testing.T) {

want := &ProjectBadge{
ID: 1,
Name: "mybadge",
LinkURL: "http://example.com/ci_status.svg?project={project_path}&ref={default_branch}",
ImageURL: "https://shields.io/my/badge",
RenderedLinkURL: "http://example.com/ci_status.svg?project=example-org/example-project&ref=master",
Expand Down

0 comments on commit 60dfa37

Please sign in to comment.