diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-01 18:22:24 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-01 18:22:24 +0000 |
commit | ab54a183a266099664c08489560c0784481595df (patch) | |
tree | 06bd9a98d6c4adc0237fd04534cd3932442d1f45 | |
parent | 9e8df307e1aba45aba3521bb9aa4dff528205b6e (diff) | |
parent | 20720d6aac157207b7ce31edf1ab7a1cd2be6853 (diff) | |
download | gitlab-ce-ab54a183a266099664c08489560c0784481595df.tar.gz |
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
-rw-r--r-- | changelogs/unreleased/fix-github-branch-formatter.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/github_import/branch_formatter.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/branch_formatter_spec.rb | 12 |
3 files changed, 14 insertions, 4 deletions
diff --git a/changelogs/unreleased/fix-github-branch-formatter.yml b/changelogs/unreleased/fix-github-branch-formatter.yml new file mode 100644 index 00000000000..c8698f507de --- /dev/null +++ b/changelogs/unreleased/fix-github-branch-formatter.yml @@ -0,0 +1,4 @@ +--- +title: Fix branch validation for GitHub PR where repo/fork was renamed/deleted +merge_request: +author: diff --git a/lib/gitlab/github_import/branch_formatter.rb b/lib/gitlab/github_import/branch_formatter.rb index 4750675ae9d..0a8d05b5fe1 100644 --- a/lib/gitlab/github_import/branch_formatter.rb +++ b/lib/gitlab/github_import/branch_formatter.rb @@ -8,7 +8,7 @@ module Gitlab end def valid? - repo.present? + sha.present? && ref.present? end private diff --git a/spec/lib/gitlab/github_import/branch_formatter_spec.rb b/spec/lib/gitlab/github_import/branch_formatter_spec.rb index e5300dbba1e..462caa5b5fe 100644 --- a/spec/lib/gitlab/github_import/branch_formatter_spec.rb +++ b/spec/lib/gitlab/github_import/branch_formatter_spec.rb @@ -49,14 +49,20 @@ describe Gitlab::GithubImport::BranchFormatter, lib: true do end 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)) expect(branch.valid?).to eq true end - it 'returns false when raw repo is blank' do - branch = described_class.new(project, double(raw.merge(repo: nil))) + it 'returns false when raw sha is blank' do + 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 end |