...

Source file src/github.com/google/go-github/v33/github/repos_merging.go

Documentation: github.com/google/go-github/v33/github

     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  
     6  package github
     7  
     8  import (
     9  	"context"
    10  	"fmt"
    11  )
    12  
    13  // RepositoryMergeRequest represents a request to merge a branch in a
    14  // repository.
    15  type RepositoryMergeRequest struct {
    16  	Base          *string `json:"base,omitempty"`
    17  	Head          *string `json:"head,omitempty"`
    18  	CommitMessage *string `json:"commit_message,omitempty"`
    19  }
    20  
    21  // Merge a branch in the specified repository.
    22  //
    23  // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#merge-a-branch
    24  func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) {
    25  	u := fmt.Sprintf("repos/%v/%v/merges", owner, repo)
    26  	req, err := s.client.NewRequest("POST", u, request)
    27  	if err != nil {
    28  		return nil, nil, err
    29  	}
    30  
    31  	commit := new(RepositoryCommit)
    32  	resp, err := s.client.Do(ctx, req, commit)
    33  	if err != nil {
    34  		return nil, resp, err
    35  	}
    36  
    37  	return commit, resp, nil
    38  }
    39  

View as plain text