Commit 490d0f94 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ce-to-ee-2018-08-30' into 'master'

CE upstream - 2018-08-30 12:21 UTC

See merge request gitlab-org/gitlab-ee!7080
parents a32a0ed1 2dac3843
......@@ -3,7 +3,7 @@
module OptionallySearch
extend ActiveSupport::Concern
module ClassMethods
class_methods do
def search(*)
raise(
NotImplementedError,
......
......@@ -45,8 +45,8 @@ module Projects
@new_path = File.join(@new_namespace.try(:full_path) || '', project.path)
@old_namespace = project.namespace
if Project.where(path: project.path, namespace_id: @new_namespace.try(:id)).exists?
raise TransferError.new("Project with same path in target namespace already exists")
if Project.where(namespace_id: @new_namespace.try(:id)).where('path = ? or name = ?', project.path, project.name).exists?
raise TransferError.new("Project with same name or path in target namespace already exists")
end
if project.has_container_registry_tags?
......@@ -120,6 +120,7 @@ module Projects
def rollback_side_effects
rollback_folder_move
project.reload
update_namespace_and_visibility(@old_namespace)
write_repository_config(@old_path)
end
......
......@@ -30,11 +30,13 @@
%pre.dark#merge-info-3
- if @merge_request.for_fork?
:preserve
git checkout #{h @merge_request.target_branch}
git fetch origin
git checkout origin/#{h @merge_request.target_branch}
git merge --no-ff #{h @merge_request.source_project_path}-#{h @merge_request.source_branch}
- else
:preserve
git checkout #{h @merge_request.target_branch}
git fetch origin
git checkout origin/#{h @merge_request.target_branch}
git merge --no-ff #{h @merge_request.source_branch}
%p
%strong Step 4.
......
---
title: Fix project transfer name validation issues causing a redirect loop
merge_request: 21408
author:
type: fixed
---
title: Adds Rubocop rule to enforce class_methods over module ClassMethods
merge_request: 21379
author: Jacopo Beschi @jacopo-beschi
type: added
---
title: Fix Error 500s due to encoding issues when Wiki hooks fire
merge_request: 21414
author:
type: fixed
......@@ -75,7 +75,7 @@ module Gitlab
end
def binary_stringio(str)
StringIO.new(str || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
StringIO.new(str.freeze || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
end
private
......
# coding: utf-8
require "spec_helper"
describe Gitlab::EncodingHelper do
......@@ -187,4 +188,15 @@ describe Gitlab::EncodingHelper do
end
end
end
describe '#binary_stringio' do
it 'does not mutate the original string encoding' do
test = 'my-test'
io_stream = ext_class.binary_stringio(test)
expect(io_stream.external_encoding.name).to eq('ASCII-8BIT')
expect(test.encoding.name).to eq('UTF-8')
end
end
end
......@@ -169,6 +169,35 @@ describe Projects::TransferService do
it { expect(project.errors[:new_namespace]).to include('Cannot move project') }
end
context 'target namespace containing the same project name' do
before do
group.add_owner(user)
project.update(name: 'new_name')
create(:project, name: 'new_name', group: group, path: 'other')
@result = transfer_project(project, user, group)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
it { expect(project.errors[:new_namespace]).to include('Project with same name or path in target namespace already exists') }
end
context 'target namespace containing the same project path' do
before do
group.add_owner(user)
create(:project, name: 'other-name', path: project.path, group: group)
@result = transfer_project(project, user, group)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
it { expect(project.errors[:new_namespace]).to include('Project with same name or path in target namespace already exists') }
end
def transfer_project(project, user, new_namespace)
service = Projects::TransferService.new(project, user)
......
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