2014-09-02 18:07:02 +05:30
|
|
|
Gitlab::Seeder.quiet do
|
2016-06-02 11:05:42 +05:30
|
|
|
# Limit the number of merge requests per project to avoid long seeds
|
|
|
|
MAX_NUM_MERGE_REQUESTS = 10
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
Project.all.reject(&:empty_repo?).each do |project|
|
2016-06-02 11:05:42 +05:30
|
|
|
branches = project.repository.branch_names.sample(MAX_NUM_MERGE_REQUESTS * 2)
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
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-09-11 14:41:01 +05:30
|
|
|
title: FFaker::Lorem.sentence(6),
|
|
|
|
description: FFaker::Lorem.sentences(3).join(" "),
|
2014-09-02 18:07:02 +05:30
|
|
|
milestone: project.milestones.sample,
|
|
|
|
assignee: project.team.users.sample
|
|
|
|
}
|
|
|
|
|
|
|
|
MergeRequests::CreateService.new(project, project.team.users.sample, params).execute
|
|
|
|
print '.'
|
|
|
|
end
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
project = Project.find_with_namespace('gitlab-org/gitlab-test')
|
|
|
|
|
|
|
|
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 '.'
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|