Commit ab54a183 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix/github-importer' into 'master'

Fix GitHub importer to import PR where source repo/fork was renamed/deleted

Closes #24594

See merge request !7865
parents 9e8df307 20720d6a
---
title: Fix branch validation for GitHub PR where repo/fork was renamed/deleted
merge_request:
author:
...@@ -8,7 +8,7 @@ module Gitlab ...@@ -8,7 +8,7 @@ module Gitlab
end end
def valid? def valid?
repo.present? sha.present? && ref.present?
end end
private private
......
...@@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do ...@@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do
end end
describe '#valid?' do describe '#valid?' do
it 'returns true when raw repo is present' do it 'returns true when raw sha and ref are present' do
branch = described_class.new(project, double(raw)) branch = described_class.new(project, double(raw))
expect(branch.valid?).to eq true expect(branch.valid?).to eq true
end end
it 'returns false when raw repo is blank' do it 'returns false when raw sha is blank' do
branch = described_class.new(project, double(raw.merge(repo: nil))) branch = described_class.new(project, double(raw.merge(sha: nil)))
expect(branch.valid?).to eq false
end
it 'returns false when raw ref is blank' do
branch = described_class.new(project, double(raw.merge(ref: nil)))
expect(branch.valid?).to eq false expect(branch.valid?).to eq false
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