You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

  1. // Copyright 2014 The go-github AUTHORS. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file.
  5. package github
  6. import (
  7. "context"
  8. "fmt"
  9. )
  10. // RepositoryMergeRequest represents a request to merge a branch in a
  11. // repository.
  12. type RepositoryMergeRequest struct {
  13. Base *string `json:"base,omitempty"`
  14. Head *string `json:"head,omitempty"`
  15. CommitMessage *string `json:"commit_message,omitempty"`
  16. }
  17. // Merge a branch in the specified repository.
  18. //
  19. // GitHub API docs: https://developer.github.com/v3/repos/merging/#merge-a-branch
  20. func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) {
  21. u := fmt.Sprintf("repos/%v/%v/merges", owner, repo)
  22. req, err := s.client.NewRequest("POST", u, request)
  23. if err != nil {
  24. return nil, nil, err
  25. }
  26. commit := new(RepositoryCommit)
  27. resp, err := s.client.Do(ctx, req, commit)
  28. if err != nil {
  29. return nil, resp, err
  30. }
  31. return commit, resp, nil
  32. }