mirror of
https://github.com/harness/drone.git
synced 2025-05-02 05:30:13 +00:00
* initial work on merging PR * code refactored based on requested changes * requested changes
39 lines
900 B
Go
39 lines
900 B
Go
// Copyright 2022 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package gitrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/harness/gitness/gitrpc/rpc"
|
|
)
|
|
|
|
type MergeBranchParams struct {
|
|
WriteParams
|
|
BaseBranch string
|
|
HeadRepoUID string
|
|
HeadBranch string
|
|
Force bool
|
|
DeleteBranch bool
|
|
}
|
|
|
|
func (c *Client) MergeBranch(ctx context.Context, params *MergeBranchParams) (string, error) {
|
|
if params == nil {
|
|
return "", ErrNoParamsProvided
|
|
}
|
|
|
|
resp, err := c.mergeService.MergeBranch(ctx, &rpc.MergeBranchRequest{
|
|
Base: mapToRPCWriteRequest(params.WriteParams),
|
|
Branch: params.BaseBranch,
|
|
HeadBranch: params.HeadBranch,
|
|
Force: params.Force,
|
|
Delete: params.DeleteBranch,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return resp.CommitId, nil
|
|
}
|