Commit 1e2f9a8f authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fork_gitlab_ci' into 'master'

Preserve custom .gitlab-ci.yml config path when forking

Closes #30242 and #22875

See merge request gitlab-org/gitlab!17817
parents 36703445 b39656f6
...@@ -43,6 +43,7 @@ module Projects ...@@ -43,6 +43,7 @@ module Projects
shared_runners_enabled: @project.shared_runners_enabled, shared_runners_enabled: @project.shared_runners_enabled,
namespace_id: target_namespace.id, namespace_id: target_namespace.id,
fork_network: fork_network, fork_network: fork_network,
ci_config_path: @project.ci_config_path,
# We need to set ci_default_git_depth to 0 for the forked project when # We need to set ci_default_git_depth to 0 for the forked project when
# @project.ci_default_git_depth is nil in order to keep the same behaviour # @project.ci_default_git_depth is nil in order to keep the same behaviour
# and not get ProjectCiCdSetting::DEFAULT_GIT_DEPTH set on create # and not get ProjectCiCdSetting::DEFAULT_GIT_DEPTH set on create
......
---
title: Preserve custom .gitlab-ci.yml config path when forking.
merge_request: 17817
author: Mathieu Parent
type: added
...@@ -50,6 +50,7 @@ describe Projects::ForkService do ...@@ -50,6 +50,7 @@ describe Projects::ForkService do
it { expect(to_project.star_count).to be_zero } it { expect(to_project.star_count).to be_zero }
it { expect(to_project.description).to eq(@from_project.description) } it { expect(to_project.description).to eq(@from_project.description) }
it { expect(to_project.avatar.file).to be_exists } it { expect(to_project.avatar.file).to be_exists }
it { expect(to_project.ci_config_path).to eq(@from_project.ci_config_path) }
# This test is here because we had a bug where the from-project lost its # This test is here because we had a bug where the from-project lost its
# avatar after being forked. # avatar after being forked.
...@@ -215,7 +216,8 @@ describe Projects::ForkService do ...@@ -215,7 +216,8 @@ describe Projects::ForkService do
@project = create(:project, :repository, @project = create(:project, :repository,
creator_id: @group_owner.id, creator_id: @group_owner.id,
star_count: 777, star_count: 777,
description: 'Wow, such a cool project!') description: 'Wow, such a cool project!',
ci_config_path: 'debian/salsa-ci.yml')
@group = create(:group) @group = create(:group)
@group.add_user(@group_owner, GroupMember::OWNER) @group.add_user(@group_owner, GroupMember::OWNER)
@group.add_user(@developer, GroupMember::DEVELOPER) @group.add_user(@developer, GroupMember::DEVELOPER)
...@@ -228,14 +230,15 @@ describe Projects::ForkService do ...@@ -228,14 +230,15 @@ describe Projects::ForkService do
it 'group owner successfully forks project into the group' do it 'group owner successfully forks project into the group' do
to_project = fork_project(@project, @group_owner, @opts) to_project = fork_project(@project, @group_owner, @opts)
expect(to_project).to be_persisted expect(to_project).to be_persisted
expect(to_project.errors).to be_empty expect(to_project.errors).to be_empty
expect(to_project.owner).to eq(@group) expect(to_project.owner).to eq(@group)
expect(to_project.namespace).to eq(@group) expect(to_project.namespace).to eq(@group)
expect(to_project.name).to eq(@project.name) expect(to_project.name).to eq(@project.name)
expect(to_project.path).to eq(@project.path) expect(to_project.path).to eq(@project.path)
expect(to_project.description).to eq(@project.description) expect(to_project.description).to eq(@project.description)
expect(to_project.star_count).to be_zero expect(to_project.ci_config_path).to eq(@project.ci_config_path)
expect(to_project.star_count).to be_zero
end end
end end
......
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