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

62 lines
1.9 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,
2019-05-30 16:15:17 +05:30
assignee: project.team.users.sample
2014-09-02 18:07:02 +05:30
}
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
2019-02-15 15:39:39 +05:30
Sidekiq::Worker.skipping_transaction_check do
MergeRequests::CreateService.new(project, developer, params).execute
2019-03-02 22:35:43 +05:30
rescue Repository::AmbiguousRefError
# Ignore pipelines creation errors for now, we can doing that after
# https://gitlab.com/gitlab-org/gitlab-ce/issues/55966. will be resolved.
2019-02-15 15:39:39 +05:30
end
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'
}
2019-02-15 15:39:39 +05:30
Sidekiq::Worker.skipping_transaction_check do
MergeRequests::CreateService.new(project, User.admins.first, params).execute
end
2015-04-26 12:48:37 +05:30
print '.'
params = {
source_branch: 'feature_conflict',
target_branch: 'feature',
title: 'Cannot be automatically merged'
}
2019-02-15 15:39:39 +05:30
Sidekiq::Worker.skipping_transaction_check do
MergeRequests::CreateService.new(project, User.admins.first, params).execute
end
2015-04-26 12:48:37 +05:30
print '.'
2014-09-02 18:07:02 +05:30
end