debian-mirror-gitlab/db/fixtures/development/10_merge_requests.rb

53 lines
1.5 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require './spec/support/sidekiq'
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
2018-05-09 12:01:36 +05:30
Project.non_archived.with_merge_requests_enabled.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
}
2018-05-09 12:01:36 +05:30
# Only create MRs with users that are allowed to create MRs
developer = project.team.developers.sample
break unless developer
MergeRequests::CreateService.new(project, developer, params).execute
2014-09-02 18:07:02 +05:30
print '.'
end
end
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
project = Project.find_by_full_path('gitlab-org/gitlab-test')
2015-04-26 12:48:37 +05:30
2018-03-17 18:26:18 +05:30
next if project.empty_repo? # We don't have repository on CI
2015-04-26 12:48:37 +05:30
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