fix: [CODE-2583]: fix dry-running merge without merge method (#2852)

* fix: [CODE-2583]: fix dry-running merge without merge method
pull/3576/head
Johannes Batzill 2024-10-22 23:06:12 +00:00 committed by Harness
parent 32e817888a
commit 7b5490ac10
1 changed files with 7 additions and 1 deletions

View File

@ -102,9 +102,15 @@ func (c *Controller) Merge(
pullreqNum int64, pullreqNum int64,
in *MergeInput, in *MergeInput,
) (*types.MergeResponse, *types.MergeViolations, error) { ) (*types.MergeResponse, *types.MergeViolations, error) {
// keep track of original method in case it's empty, as it is optional for dry-run.
originalMergeMethod := in.Method
if err := in.sanitize(); err != nil { if err := in.sanitize(); err != nil {
return nil, nil, err return nil, nil, err
} }
if originalMergeMethod != "" {
// use sanitized version if a non-empty merge method was provided.
originalMergeMethod = in.Method
}
requiredPermission := enum.PermissionRepoPush requiredPermission := enum.PermissionRepoPush
if in.DryRun { if in.DryRun {
@ -212,7 +218,7 @@ func (c *Controller) Merge(
SourceRepo: sourceRepo, SourceRepo: sourceRepo,
PullReq: pr, PullReq: pr,
Reviewers: reviewers, Reviewers: reviewers,
Method: in.Method, Method: originalMergeMethod,
CheckResults: checkResults, CheckResults: checkResults,
CodeOwners: codeOwnerWithApproval, CodeOwners: codeOwnerWithApproval,
}) })