Commit d3af645e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refactor pipeline fixtures for dev env a little

parent ac73de50
...@@ -34,33 +34,38 @@ class Gitlab::Seeder::Builds ...@@ -34,33 +34,38 @@ class Gitlab::Seeder::Builds
end end
end end
private
def pipelines def pipelines
master_pipelines + merge_request_pipelines create_master_pipelines + create_merge_request_pipelines
end end
def master_pipelines def create_master_pipelines
create_pipelines_for(@project, 'master') @project.repository.commits('master', limit: 5).map do |commit|
create_pipeline!(@project, 'master', commit)
end
rescue rescue
[] []
end end
def merge_request_pipelines def create_merge_request_pipelines
@project.merge_requests.last(5).map do |merge_request| pipelines = @project.merge_requests.first(5).map do |merge_request|
create_pipelines(merge_request.source_project, merge_request.source_branch, merge_request.commits.last(5)) project = merge_request.source_project
end.flatten branch = merge_request.source_branch
merge_request.commits.last(5).map do |commit|
create_pipeline!(project, branch, commit)
end
end
pipelines.flatten
rescue rescue
[] []
end end
def create_pipelines_for(project, ref)
commits = project.repository.commits(ref, limit: 5)
create_pipelines(project, ref, commits)
end
def create_pipelines(project, ref, commits) def create_pipeline!(project, ref, commit)
commits.map do |commit| project.pipelines.create(sha: commit.id, ref: ref)
project.pipelines.create(sha: commit.id, ref: ref)
end
end end
def build_create!(pipeline, opts = {}) def build_create!(pipeline, opts = {})
......
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