Skip to content

Commit

Permalink
Merge pull request #1801 from lugray/latest_release
Browse files Browse the repository at this point in the history
Add a function to access the latest release endpoint
  • Loading branch information
svanharmelen authored Sep 25, 2023
2 parents 6357587 + 6ec8874 commit 0113e62
Showing 1 changed file with 25 additions and 0 deletions.
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

0 comments on commit 0113e62

Please sign in to comment.