This instance will be upgraded to Heptapod 0.27.1 on 2021-12-08 at 22:00 UTC+1 (a few minutes of down time)

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

Add Project#gitea_import?


Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent c799de69da92
......@@ -533,6 +533,10 @@ def gitlab_project_import?
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 @@ def client
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 @@ def execute
# 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 @@ def import_pull_requests
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 @@ def find_condition
end
def number
if project.import_type == 'gitea'
if project.gitea_import?
raw_data.id
else
raw_data.number
......
......@@ -192,7 +192,7 @@
]
}
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 @@ def create_build(new_pipeline = pipeline, name = 'test')
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