Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

feat: add project badge names #1377

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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