Skip to content
Snippets Groups Projects
Commit 2986de7c authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Add readable error message when remote data could not be fully imported

parent 3c09000e
No related branches found
No related tags found
No related merge requests found
Loading
@@ -36,7 +36,12 @@ module Gitlab
Loading
@@ -36,7 +36,12 @@ module Gitlab
end end
   
def handle_errors def handle_errors
project.update_column(:import_error, errors.to_json) unless errors.empty? return unless errors.any?
project.update_column(:import_error, {
message: 'The remote data could not be fully imported.',
errors: errors
}.to_json)
end end
   
def import_labels def import_labels
Loading
Loading
Loading
@@ -110,19 +110,22 @@ describe Gitlab::GithubImport::Importer, lib: true do
Loading
@@ -110,19 +110,22 @@ describe Gitlab::GithubImport::Importer, lib: true do
end end
   
it 'stores error messages' do it 'stores error messages' do
errors = [ error = {
{ type: :label, url: "https://api.github.com/repos/octocat/Hello-World/labels/bug", errors: "Validation failed: Title has already been taken" }, message: 'The remote data could not be fully imported.',
{ type: :milestone, url: "https://api.github.com/repos/octocat/Hello-World/milestones/1", errors: "Validation failed: Title has already been taken" }, errors: [
{ type: :issue, url: "https://api.github.com/repos/octocat/Hello-World/issues/1347", errors: "Invalid Repository. Use user/repo format." }, { type: :label, url: "https://api.github.com/repos/octocat/Hello-World/labels/bug", errors: "Validation failed: Title has already been taken" },
{ type: :issue, url: "https://api.github.com/repos/octocat/Hello-World/issues/1348", errors: "Validation failed: Title can't be blank, Title is too short (minimum is 0 characters)" }, { type: :milestone, url: "https://api.github.com/repos/octocat/Hello-World/milestones/1", errors: "Validation failed: Title has already been taken" },
{ type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Invalid Repository. Use user/repo format." }, { type: :issue, url: "https://api.github.com/repos/octocat/Hello-World/issues/1347", errors: "Invalid Repository. Use user/repo format." },
{ type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Validation failed: Validate branches Cannot Create: This merge request already exists: [\"New feature\"]" }, { type: :issue, url: "https://api.github.com/repos/octocat/Hello-World/issues/1348", errors: "Validation failed: Title can't be blank, Title is too short (minimum is 0 characters)" },
{ type: :wiki, errors: "Gitlab::Shell::Error" } { type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Invalid Repository. Use user/repo format." },
] { type: :pull_request, url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347", errors: "Validation failed: Validate branches Cannot Create: This merge request already exists: [\"New feature\"]" },
{ type: :wiki, errors: "Gitlab::Shell::Error" }
]
}
   
described_class.new(project).execute described_class.new(project).execute
   
expect(project.import_error).to eq errors.to_json expect(project.import_error).to eq error.to_json
end end
end end
end end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment