Add Project#gitea_import?

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2016-12-16 17:44:22 +01:00
parent e046e4c14d
commit ab06313c36
5 changed files with 21 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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) }