Skip to content

Commit

Permalink
merge API: return if the branch is deleted (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-gacesa authored and Harness committed Oct 20, 2023
1 parent fcc8c0b commit 8d82daf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/api/controller/pullreq/merge.go
Expand Up @@ -247,6 +247,7 @@ func (c *Controller) Merge(
SourceSHA: mergeOutput.HeadSHA,
})

var branchDeleted bool
if ruleOut.DeleteSourceBranch {
errDelete := c.gitRPCClient.DeleteBranch(ctx, &gitrpc.DeleteBranchParams{
WriteParams: sourceWriteParams,
Expand All @@ -255,11 +256,14 @@ func (c *Controller) Merge(
if errDelete != nil {
// non-critical error
log.Ctx(ctx).Err(errDelete).Msgf("failed to delete source branch after merging")
} else {
branchDeleted = true
}
}

return types.MergeResponse{
SHA: sha,
BranchDeleted: branchDeleted,
RuleViolations: violations,
}, nil
}
1 change: 1 addition & 0 deletions types/pullreq.go
Expand Up @@ -140,6 +140,7 @@ type PullReqFileView struct {

type MergeResponse struct {
SHA string `json:"sha,omitempty"`
BranchDeleted bool `json:"branch_deleted"`
ConflictFiles []string `json:"conflict_files,omitempty"`
RuleViolations []RuleViolations `json:"rule_violations,omitempty"`
}

0 comments on commit 8d82daf

Please sign in to comment.