2012-11-13 15:11:56 -05:00
|
|
|
Gitlab::Seeder.quiet do
|
2016-05-04 03:59:20 -04:00
|
|
|
# Limit the number of merge requests per project to avoid long seeds
|
|
|
|
MAX_NUM_MERGE_REQUESTS = 10
|
|
|
|
|
2014-05-05 08:07:19 -04:00
|
|
|
Project.all.reject(&:empty_repo?).each do |project|
|
2016-05-04 03:59:20 -04:00
|
|
|
branches = project.repository.branch_names.sample(MAX_NUM_MERGE_REQUESTS * 2)
|
2014-05-05 08:07:19 -04:00
|
|
|
|
|
|
|
branches.each do |branch_name|
|
|
|
|
break if branches.size < 2
|
|
|
|
source_branch = branches.pop
|
|
|
|
target_branch = branches.pop
|
|
|
|
|
|
|
|
params = {
|
|
|
|
source_branch: source_branch,
|
|
|
|
target_branch: target_branch,
|
2015-05-20 19:22:00 -04:00
|
|
|
title: FFaker::Lorem.sentence(6),
|
|
|
|
description: FFaker::Lorem.sentences(3).join(" "),
|
2014-08-11 10:55:31 -04:00
|
|
|
milestone: project.milestones.sample,
|
|
|
|
assignee: project.team.users.sample
|
2014-05-05 08:07:19 -04:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:55:31 -04:00
|
|
|
MergeRequests::CreateService.new(project, project.team.users.sample, params).execute
|
|
|
|
print '.'
|
2013-10-04 15:11:50 -04:00
|
|
|
end
|
2012-11-13 15:11:56 -05:00
|
|
|
end
|
2014-09-29 07:55:31 -04:00
|
|
|
|
2014-09-30 11:34:46 -04:00
|
|
|
project = Project.find_with_namespace('gitlab-org/gitlab-test')
|
2014-09-29 07:55:31 -04:00
|
|
|
|
|
|
|
params = {
|
|
|
|
source_branch: 'feature',
|
|
|
|
target_branch: 'master',
|
|
|
|
title: 'Can be automatically merged'
|
|
|
|
}
|
|
|
|
MergeRequests::CreateService.new(project, User.admins.first, params).execute
|
|
|
|
print '.'
|
|
|
|
|
|
|
|
params = {
|
|
|
|
source_branch: 'feature_conflict',
|
|
|
|
target_branch: 'feature',
|
|
|
|
title: 'Cannot be automatically merged'
|
|
|
|
}
|
|
|
|
MergeRequests::CreateService.new(project, User.admins.first, params).execute
|
|
|
|
print '.'
|
2012-10-30 04:03:21 -04:00
|
|
|
end
|