Update project full path in .git/config when renaming namespace
This commit is contained in:
parent
bd90330740
commit
ca089f5968
3 changed files with 23 additions and 0 deletions
|
@ -34,6 +34,8 @@ module Storage
|
|||
# So we basically we mute exceptions in next actions
|
||||
begin
|
||||
send_update_instructions
|
||||
write_projects_full_path_config
|
||||
|
||||
true
|
||||
rescue
|
||||
# Returning false does not rollback after_* transaction but gives
|
||||
|
|
|
@ -268,4 +268,11 @@ class Namespace < ActiveRecord::Base
|
|||
def namespace_previously_created_with_same_path?
|
||||
RedirectRoute.permanent.exists?(path: path)
|
||||
end
|
||||
|
||||
def write_projects_full_path_config
|
||||
all_projects.each do |project|
|
||||
project.expires_full_path_cache # we need to clear cache to validate renames correctly
|
||||
project.write_repository_config(:fullpath, project.full_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -240,6 +240,20 @@ describe Namespace do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates project full path in .git/config for each project inside namespace' do
|
||||
parent = create(:group, name: 'mygroup', path: 'mygroup')
|
||||
subgroup = create(:group, name: 'mysubgroup', path: 'mysubgroup', parent: parent)
|
||||
project_in_parent_group = create(:project, :repository, namespace: parent, name: 'foo1')
|
||||
hashed_project_in_subgroup = create(:project, :repository, :hashed, namespace: subgroup, name: 'foo2')
|
||||
legacy_project_in_subgroup = create(:project, :repository, namespace: subgroup, name: 'foo3')
|
||||
|
||||
parent.update(path: 'mygroup_new')
|
||||
|
||||
expect(project_in_parent_group.repo.config['gitlab.fullpath']).to eq "mygroup_new/#{project_in_parent_group.path}"
|
||||
expect(hashed_project_in_subgroup.repo.config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{hashed_project_in_subgroup.path}"
|
||||
expect(legacy_project_in_subgroup.repo.config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{legacy_project_in_subgroup.path}"
|
||||
end
|
||||
end
|
||||
|
||||
describe '#rm_dir', 'callback' do
|
||||
|
|
Loading…
Reference in a new issue