Commit d3af645e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refactor pipeline fixtures for dev env a little

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