@@ -305,6 +305,21 @@ func (s *pullService) ClearMilestone(ctx context.Context, repo string, prID int)
305305 return nil , scm .ErrNotSupported
306306}
307307
308+ func (s * pullService ) DeletePullRequest (ctx context.Context , repo string , prID int ) (* scm.Response , error ) {
309+ namespace , name := scm .Split (repo )
310+ // in Bitbucket server (stash) to delete a pull request `version` of the pull request
311+ // must be provided in body of the request so it's worth fetching pull request via rest api
312+ // to get latest version of the pull request.
313+ path := fmt .Sprintf ("rest/api/1.0/projects/%s/repos/%s/pull-requests/%d" , namespace , name , prID )
314+ out := new (pullRequest )
315+ _ , err := s .client .do (ctx , http .MethodGet , path , nil , out )
316+ if err != nil {
317+ return nil , fmt .Errorf ("failed to get pull request. err: %v" , err )
318+ }
319+ in := map [string ]int {"version" : out .Version }
320+ return s .client .do (ctx , http .MethodDelete , path , & in , nil )
321+ }
322+
308323type createPRInput struct {
309324 Title string `json:"title,omitempty"`
310325 Description string `json:"description,omitempty"`
0 commit comments