Commit ab06313c authored by Rémy Coutable's avatar Rémy Coutable

Add Project#gitea_import?

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent e046e4c1
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment