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

Commit

Permalink
Fix the update labels method
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Oct 28, 2024
1 parent 098437b commit 2572a74
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ func (s *LabelsService) ListLabels(pid interface{}, opt *ListLabelsOptions, opti
// GetLabel get a single label for a given project.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/labels.html#get-a-single-project-label
func (s *LabelsService) GetLabel(pid interface{}, labelID interface{}, options ...RequestOptionFunc) (*Label, *Response, error) {
func (s *LabelsService) GetLabel(pid interface{}, lid interface{}, options ...RequestOptionFunc) (*Label, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
label, err := parseID(labelID)
label, err := parseID(lid)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -183,15 +183,11 @@ func (s *LabelsService) DeleteLabel(pid interface{}, lid interface{}, opt *Delet
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/labels", PathEscape(project))

if lid != nil {
label, err := parseID(lid)
if err != nil {
return nil, err
}
u = fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label))
label, err := parseID(lid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label))

req, err := s.client.NewRequest(http.MethodDelete, u, opt, options)
if err != nil {
Expand All @@ -205,7 +201,6 @@ func (s *LabelsService) DeleteLabel(pid interface{}, lid interface{}, opt *Delet
//
// GitLab API docs: https://docs.gitlab.com/ee/api/labels.html#edit-an-existing-label
type UpdateLabelOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
NewName *string `url:"new_name,omitempty" json:"new_name,omitempty"`
Color *string `url:"color,omitempty" json:"color,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
Expand All @@ -216,12 +211,16 @@ type UpdateLabelOptions struct {
// one parameter is required, to update the label.
//
// GitLab API docs: https://docs.gitlab.com/ee/api/labels.html#edit-an-existing-label
func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, options ...RequestOptionFunc) (*Label, *Response, error) {
func (s *LabelsService) UpdateLabel(pid interface{}, lid interface{}, opt *UpdateLabelOptions, options ...RequestOptionFunc) (*Label, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/labels", PathEscape(project))
label, err := parseID(lid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/labels/%s", PathEscape(project), PathEscape(label))

req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
if err != nil {
Expand All @@ -243,12 +242,12 @@ func (s *LabelsService) UpdateLabel(pid interface{}, opt *UpdateLabelOptions, op
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/labels.html#subscribe-to-a-label
func (s *LabelsService) SubscribeToLabel(pid interface{}, labelID interface{}, options ...RequestOptionFunc) (*Label, *Response, error) {
func (s *LabelsService) SubscribeToLabel(pid interface{}, lid interface{}, options ...RequestOptionFunc) (*Label, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
label, err := parseID(labelID)
label, err := parseID(lid)
if err != nil {
return nil, nil, err
}
Expand All @@ -274,12 +273,12 @@ func (s *LabelsService) SubscribeToLabel(pid interface{}, labelID interface{}, o
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/labels.html#unsubscribe-from-a-label
func (s *LabelsService) UnsubscribeFromLabel(pid interface{}, labelID interface{}, options ...RequestOptionFunc) (*Response, error) {
func (s *LabelsService) UnsubscribeFromLabel(pid interface{}, lid interface{}, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
label, err := parseID(labelID)
label, err := parseID(lid)
if err != nil {
return nil, err
}
Expand All @@ -297,12 +296,12 @@ func (s *LabelsService) UnsubscribeFromLabel(pid interface{}, labelID interface{
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/labels.html#promote-a-project-label-to-a-group-label
func (s *LabelsService) PromoteLabel(pid interface{}, labelID interface{}, options ...RequestOptionFunc) (*Response, error) {
func (s *LabelsService) PromoteLabel(pid interface{}, lid interface{}, options ...RequestOptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
label, err := parseID(labelID)
label, err := parseID(lid)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2572a74

Please sign in to comment.