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 ...@@ -533,6 +533,10 @@ class Project < ActiveRecord::Base
import_type == 'gitlab_project' import_type == 'gitlab_project'
end end
def gitea_import?
import_type == 'gitea'
end
def check_limit def check_limit
unless creator.can_create_project? or namespace.kind == 'group' unless creator.can_create_project? or namespace.kind == 'group'
projects_limit = creator.projects_limit projects_limit = creator.projects_limit
......
...@@ -22,7 +22,7 @@ module Gitlab ...@@ -22,7 +22,7 @@ module Gitlab
opts = {} opts = {}
# Gitea plan to be GitHub compliant # Gitea plan to be GitHub compliant
if project.import_type == 'gitea' if project.gitea_import?
uri = URI.parse(project.import_url) uri = URI.parse(project.import_url)
host = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}".sub(%r{/?[\w-]+/[\w-]+\.git\z}, '') host = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}".sub(%r{/?[\w-]+/[\w-]+\.git\z}, '')
opts = { opts = {
...@@ -53,7 +53,7 @@ module Gitlab ...@@ -53,7 +53,7 @@ module Gitlab
# Gitea doesn't have a Release API yet # Gitea doesn't have a Release API yet
# See https://github.com/go-gitea/gitea/issues/330 # See https://github.com/go-gitea/gitea/issues/330
unless project.import_type == 'gitea' unless project.gitea_import?
import_releases import_releases
end end
...@@ -141,7 +141,7 @@ module Gitlab ...@@ -141,7 +141,7 @@ module Gitlab
merge_request = gh_pull_request.create! merge_request = gh_pull_request.create!
# Gitea doesn't return PR in the Issue API endpoint, so labels must be assigned at this stage # 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) apply_labels(merge_request, raw)
end end
rescue => e rescue => e
......
...@@ -23,7 +23,7 @@ module Gitlab ...@@ -23,7 +23,7 @@ module Gitlab
end end
def number def number
if project.import_type == 'gitea' if project.gitea_import?
raw_data.id raw_data.id
else else
raw_data.number raw_data.number
......
...@@ -192,7 +192,7 @@ describe Gitlab::GithubImport::Importer, lib: true do ...@@ -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" } error[:errors] << { type: :release, url: "#{api_root}/repos/octocat/Hello-World/releases/2", errors: "Validation failed: Description can't be blank" }
end end
......
...@@ -1458,6 +1458,18 @@ describe Project, models: true do ...@@ -1458,6 +1458,18 @@ describe Project, models: true do
end end
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 describe '#lfs_enabled?' do
let(:project) { create(:project) } 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