cosmin/stashy

Ability to remove branch after PR merged

ViachaslauKabak opened this issue · 2 comments

I cannot find an option to remove branch for merge() procedure
please add it

Bitbucket Server doesn't provide an option for this in its merge endpoint:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/merge

If you look at Bitbucket Server's own access logs to see what rest endpoints are called internally when you merge a PR with "Delete source branch after merging" ticked, you'll see that a second endpoint receives a POST:

rest/pull-request-cleanup/latest/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}
JSON payload:

{deleteSourceRef: true, retargetDependents: true}

This pull-request-cleanup resource is undocumented and is therefore considered an internal implementation detail. In other words, it can't be relied upon to be supported in future and may be subject to undocumented changes at any time. That being the case it seems unwise for this library to provide support for an undocumented, internal API.

As it happens I work for Atlassian support, and this seems like a reasonable request so I've raised BSERV-10976 to request adding a supported way to do this via the API. If that gets implemented then the equivalent option can be added to this library.

Until then, I'd suggest marking this one as Blocked (or Closed) until the above issue gets some movement.

Closing until BitBucket Server adds a way to do this