diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-07-09 14:59:07 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-07-11 12:22:57 +0300 |
commit | 6743147b7d9f310fbf5afa520e19ae495fd4df33 (patch) | |
tree | 2ac26c5fd33ea635462d73b8925915dff8486694 /lib | |
parent | e02efff63d2b065f95e4eeac28ba994d245e4505 (diff) | |
download | gitlab-ce-6743147b7d9f310fbf5afa520e19ae495fd4df33.tar.gz |
Improve manifest feature after backend review
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/manifest_import/manifest.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/manifest_import/project_creator.rb | 3 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/gitlab/manifest_import/manifest.rb b/lib/gitlab/manifest_import/manifest.rb index 7b1e6a22c3a..4d6034fb956 100644 --- a/lib/gitlab/manifest_import/manifest.rb +++ b/lib/gitlab/manifest_import/manifest.rb @@ -1,4 +1,4 @@ -# Class to parse manifest file to import multiple projects at once +# Class to parse manifest file and build a list of repositories for import # # <manifest> # <remote review="https://android-review.googlesource.com/" /> @@ -11,17 +11,16 @@ # For example, you can't have projects with 'foo' and 'foo/bar' paths. # 2. Remote must be present with review attribute so GitLab knows # where to fetch source code -# 3. For each nested keyword in path a corresponding group will be created. -# For example if a path is 'foo/bar' then GitLab will create a group 'foo' -# and a project 'bar' in it. module Gitlab module ManifestImport class Manifest attr_reader :parsed_xml, :errors def initialize(file) - @parsed_xml = File.open(file) { |f| Nokogiri::XML(f) } + @parsed_xml = Nokogiri::XML(file) { |config| config.strict } @errors = [] + rescue Nokogiri::XML::SyntaxError + @errors = ['The uploaded file is not a valid XML file.'] end def projects @@ -36,6 +35,8 @@ module Gitlab end def valid? + return false if @errors.any? + unless validate_remote @errors << 'Make sure a <remote> tag is present and is valid.' end diff --git a/lib/gitlab/manifest_import/project_creator.rb b/lib/gitlab/manifest_import/project_creator.rb index 9ccd32c3a3b..b5967c93735 100644 --- a/lib/gitlab/manifest_import/project_creator.rb +++ b/lib/gitlab/manifest_import/project_creator.rb @@ -12,8 +12,7 @@ module Gitlab def execute group_full_path, _, project_path = repository[:path].rpartition('/') group_full_path = File.join(destination.full_path, group_full_path) if destination - group = Group.find_by_full_path(group_full_path) || - create_group_with_parents(group_full_path) + group = create_group_with_parents(group_full_path) params = { import_url: repository[:url], |