diff options
author | Rémy Coutable <remy@rymai.me> | 2016-12-16 17:44:22 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-12-19 17:35:51 +0100 |
commit | ab06313c36fc5856b2472d3dfcb966a8c6341d0b (patch) | |
tree | ea6d499de443ada8364337c194e1d08b4e28682f | |
parent | e046e4c14d06a19cc30a679f4943c77b56ee6d0c (diff) | |
download | gitlab-ce-22348-gitea-importer.tar.gz |
Add Project#gitea_import?22348-gitea-importer
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/github_import/importer.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/github_import/milestone_formatter.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/importer_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 12 |
5 files changed, 21 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 5d5d6737dad..0ba8fca24d5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -533,6 +533,10 @@ class Project < ActiveRecord::Base import_type == 'gitlab_project' end + def gitea_import? + import_type == 'gitea' + end + def check_limit unless creator.can_create_project? or namespace.kind == 'group' projects_limit = creator.projects_limit diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb index c53cd1a928d..ec1318ab33c 100644 --- a/lib/gitlab/github_import/importer.rb +++ b/lib/gitlab/github_import/importer.rb @@ -22,7 +22,7 @@ module Gitlab opts = {} # Gitea plan to be GitHub compliant - if project.import_type == 'gitea' + if project.gitea_import? uri = URI.parse(project.import_url) host = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}".sub(%r{/?[\w-]+/[\w-]+\.git\z}, '') opts = { @@ -53,7 +53,7 @@ module Gitlab # Gitea doesn't have a Release API yet # See https://github.com/go-gitea/gitea/issues/330 - unless project.import_type == 'gitea' + unless project.gitea_import? import_releases end @@ -141,7 +141,7 @@ module Gitlab merge_request = gh_pull_request.create! # Gitea doesn't return PR in the Issue API endpoint, so labels must be assigned at this stage - if project.import_type == 'gitea' + if project.gitea_import? apply_labels(merge_request, raw) end rescue => e diff --git a/lib/gitlab/github_import/milestone_formatter.rb b/lib/gitlab/github_import/milestone_formatter.rb index fe172b854d5..dd782eff059 100644 --- a/lib/gitlab/github_import/milestone_formatter.rb +++ b/lib/gitlab/github_import/milestone_formatter.rb @@ -23,7 +23,7 @@ module Gitlab end def number - if project.import_type == 'gitea' + if project.gitea_import? raw_data.id else raw_data.number diff --git a/spec/lib/gitlab/github_import/importer_spec.rb b/spec/lib/gitlab/github_import/importer_spec.rb index 0a03b7353f6..72421832ffc 100644 --- a/spec/lib/gitlab/github_import/importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer_spec.rb @@ -192,7 +192,7 @@ describe Gitlab::GithubImport::Importer, lib: true do ] } - unless project.import_type == 'gitea' + unless project.gitea_import? error[:errors] << { type: :release, url: "#{api_root}/repos/octocat/Hello-World/releases/2", errors: "Validation failed: Description can't be blank" } end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index ed6b2c6a22b..8779b399344 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1458,6 +1458,18 @@ describe Project, models: true do end end + describe '#gitlab_project_import?' do + subject(:project) { build(:project, import_type: 'gitlab_project') } + + it { expect(project.gitlab_project_import?).to be true } + end + + describe '#gitea_import?' do + subject(:project) { build(:project, import_type: 'gitea') } + + it { expect(project.gitea_import?).to be true } + end + describe '#lfs_enabled?' do let(:project) { create(:project) } |