Unverified Commit 2dc14fdc authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Add MergeBase repo method. (#506)

Fixes #505
parent eb6ccd3e
......@@ -230,8 +230,7 @@ func (c Contributor) String() string {
return Stringify(c)
}
// ListContributorsOptions represents the available ListContributorsOptions()
// options.
// ListContributorsOptions represents the available ListContributors() options.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/repositories.html#contributors
type ListContributorsOptions ListOptions
......@@ -259,3 +258,37 @@ func (s *RepositoriesService) Contributors(pid interface{}, opt *ListContributor
return c, resp, err
}
// MergeBaseOptions represents the available MergeBase() options.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/repositories.html#merge-base
type MergeBaseOptions struct {
Ref []string `url:"refs[],omitempty" json:"refs,omitempty"`
}
// MergeBase gets the common ancestor for 2 refs (commit SHAs, branch
// names or tags).
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/repositories.html#merge-base
func (s *RepositoriesService) MergeBase(pid interface{}, opt *MergeBaseOptions, options ...OptionFunc) (*Commit, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("projects/%s/repository/merge_base", url.QueryEscape(project))
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
return nil, nil, err
}
c := new(Commit)
resp, err := s.client.Do(req, c)
if err != nil {
return nil, resp, err
}
return c, resp, err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment