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

Add a function to access the latest release endpoint #1801

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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
25 changes: 25 additions & 0 deletions releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@ func (s *ReleasesService) GetRelease(pid interface{}, tagName string, options ..
return r, resp, nil
}

// GetLatestRelease returns the latest release for the project.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/releases/#get-the-latest-release
func (s *ReleasesService) GetLatestRelease(pid interface{}, options ...RequestOptionFunc) (*Release, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/releases/permalink/latest", PathEscape(project))

req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
if err != nil {
return nil, nil, err
}

r := new(Release)
resp, err := s.client.Do(req, r)
if err != nil {
return nil, resp, err
}

return r, resp, err
}

// CreateReleaseOptions represents CreateRelease() options.
//
// GitLab API docs:
Expand Down