Commit 148b23e3 authored by Stan Hu's avatar Stan Hu

Make Bitbucket Cloud superseded pull requests as closed

The Bitbucket pull request API
(https://developer.atlassian.com/bitbucket/api/2/reference/) reports
four different states for pull requests:

1. MERGED
2. SUPERSEDED
3. OPEN
4. DECLINED

Previously, we were not handling the SUPERSEDED case. This commit now
changes SUPERSEDED pull requests as closed.

Possible fix for https://gitlab.com/gitlab-org/gitlab/issues/34656
parent 5d2d1d79
---
title: Make Bitbucket Cloud superseded pull requests as closed
merge_request: 19193
author:
type: fixed
...@@ -16,9 +16,10 @@ module Bitbucket ...@@ -16,9 +16,10 @@ module Bitbucket
end end
def state def state
if raw['state'] == 'MERGED' case raw['state']
when 'MERGED'
'merged' 'merged'
elsif raw['state'] == 'DECLINED' when 'DECLINED', 'SUPERSEDED'
'closed' 'closed'
else else
'opened' 'opened'
......
...@@ -20,6 +20,7 @@ describe Bitbucket::Representation::PullRequest do ...@@ -20,6 +20,7 @@ describe Bitbucket::Representation::PullRequest do
describe '#state' do describe '#state' do
it { expect(described_class.new({ 'state' => 'MERGED' }).state).to eq('merged') } it { expect(described_class.new({ 'state' => 'MERGED' }).state).to eq('merged') }
it { expect(described_class.new({ 'state' => 'DECLINED' }).state).to eq('closed') } it { expect(described_class.new({ 'state' => 'DECLINED' }).state).to eq('closed') }
it { expect(described_class.new({ 'state' => 'SUPERSEDED' }).state).to eq('closed') }
it { expect(described_class.new({}).state).to eq('opened') } it { expect(described_class.new({}).state).to eq('opened') }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment