Skip to content

Commit

Permalink
Extend Subversion repository with UTF-8 paths (opf#4326)
Browse files Browse the repository at this point in the history
Provide some test data for UTF-8 encoded paths with Subversion.
This confirms the tests of PR opf#4324.

Side note:
OS X will decompose some unicode characters into two characters.
For example, the LATIN SMALL LETTER O WITH DIAERESIS (U+00F6 `ö`) will be
decomposed into o and COMBINING DIAERESIS (U+0308).

This obviously breaks SVN path mapping and while you will be able to
commit files with decomposed paths, it will wreak havoc when using these
characters on repositories manipulated by OSX and other systems.
It apepars that Windows, Linux silently ignore these changes.

We can't really account for this server side, but unicode-path patches exists for Subversion on OSX.
For git, a config setting exists that does just that (`core.precomposeunicode`).
  • Loading branch information
oliverguenther committed Apr 18, 2016
1 parent 9fc459d commit 8fd75e0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 27 deletions.
42 changes: 34 additions & 8 deletions spec/controllers/repositories_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
Expand Down Expand Up @@ -252,24 +253,49 @@
end
end

shared_examples 'renders the repository title' do |active_breadcrumb|
it do
expect(response).to be_success
expect(response.body).to have_selector('.repository-breadcrumbs', text: active_breadcrumb)
end
end

describe 'show' do
render_views

let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) }

before do
get :show, project_id: project.identifier, path: path
end

shared_examples 'renders the repository' do |active_breadcrumb|
it do
expect(response).to be_success
expect(response.body).to have_selector('.repository-breadcrumbs', text: active_breadcrumb)
end
context 'with brackets' do
let(:path) { 'subversion_test/[folder_with_brackets]' }
it_behaves_like 'renders the repository title', '[folder_with_brackets]'
end

context 'with special characters' do
context 'with unicode' do
let(:path) { 'Föbar/äm/Sägepütz!%5D§' }
it_behaves_like 'renders the repository title', 'Sägepütz!%5D§'
end
end

describe 'changes' do
render_views
let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) }

before do
get :changes, project_id: project.identifier, path: path
expect(response).to be_success
end

context 'with brackets' do
let(:path) { 'subversion_test/[folder_with_brackets]' }
it_behaves_like 'renders the repository', '[folder_with_brackets]'
it_behaves_like 'renders the repository title', '[folder_with_brackets]'
end

context 'with unicode' do
let(:path) { 'Föbar/äm' }
it_behaves_like 'renders the repository title', 'äm'
end
end

Expand Down
Binary file not shown.
Binary file modified spec/fixtures/repositories/subversion_repository.tar.gz
Binary file not shown.
24 changes: 13 additions & 11 deletions spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,30 +187,32 @@
it 'builds the info object' do
info = adapter.info
expect(info.root_url).to eq(url)
expect(info.lastrev.identifier).to eq('12')
expect(info.lastrev.identifier).to eq('13')
expect(info.lastrev.author).to eq('oliver')
expect(info.lastrev.time).to eq('2015-07-08T13:32:29.228572Z')
expect(info.lastrev.time).to eq('2016-04-14T19:23:01.74469Z')
end
end

describe '.entries' do
it 'reads all entries from the current revision' do
entries = adapter.entries
expect(entries.length).to eq(1)
expect(entries.length).to eq(2)

expect(entries[0].name).to eq('subversion_test')
expect(entries[0].path).to eq('subversion_test')
expect(entries[0].name).to eq('Föbar')
expect(entries[0].path).to eq('Föbar')
expect(entries[1].name).to eq('subversion_test')
expect(entries[1].path).to eq('subversion_test')
end

it 'contains a reference to the last revision' do
entries = adapter.entries
expect(entries.length).to eq(1)
expect(entries.length).to eq(2)
lastrev = entries[0].lastrev

expect(lastrev.identifier).to eq('12')
expect(lastrev.identifier).to eq('13')
expect(lastrev.author).to eq('oliver')
expect(lastrev.message).to eq('')
expect(lastrev.time).to eq('2015-07-08T13:32:29.228572Z')
expect(lastrev.time).to eq('2016-04-14T19:23:01.74469Z')
end

it 'reads all entries from the given revision' do
Expand Down Expand Up @@ -282,13 +284,13 @@
describe '.revisions' do
it 'returns all revisions by default' do
revisions = adapter.revisions
expect(revisions.length).to eq(12)
expect(revisions.length).to eq(13)

expect(revisions[0].author).to eq('oliver')
expect(revisions[0].message).to eq("Propedit\n")
expect(revisions[0].message).to eq("UTF-8 Test")

revisions.each_with_index do |rev, i|
expect(rev.identifier).to eq((12 - i).to_s)
expect(rev.identifier).to eq((13 - i).to_s)
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/models/repository/subversion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@
instance.fetch_changesets
instance.reload

expect(instance.changesets.count).to eq(12)
expect(instance.file_changes.count).to eq(21)
expect(instance.changesets.count).to eq(13)
expect(instance.file_changes.count).to eq(25)
expect(instance.changesets.find_by(revision: '1').comments).to eq('Initial import.')
end

Expand All @@ -175,7 +175,7 @@
expect(instance.changesets.count).to eq(5)

instance.fetch_changesets
expect(instance.changesets.count).to eq(12)
expect(instance.changesets.count).to eq(13)
end

it 'should latest changesets' do
Expand Down Expand Up @@ -289,7 +289,7 @@
changeset = instance.find_changeset_by_name('1')
expect(changeset.previous).to be_nil

changeset = instance.find_changeset_by_name('12')
changeset = instance.find_changeset_by_name('13')
expect(changeset.next).to be_nil
end

Expand Down
8 changes: 4 additions & 4 deletions spec_legacy/unit/repository_subversion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
@repository.fetch_changesets
@repository.reload

assert_equal 12, @repository.changesets.count
assert_equal 21, @repository.file_changes.count
assert_equal 13, @repository.changesets.count
assert_equal 25, @repository.file_changes.count
assert_equal 'Initial import.', @repository.changesets.find_by(revision: '1').comments
end

Expand All @@ -58,7 +58,7 @@
assert_equal 5, @repository.changesets.count

@repository.fetch_changesets
assert_equal 12, @repository.changesets.count
assert_equal 13, @repository.changesets.count
end

it 'should latest changesets' do
Expand Down Expand Up @@ -199,7 +199,7 @@
it 'should next nil' do
@repository.fetch_changesets
@repository.reload
changeset = @repository.find_changeset_by_name('12')
changeset = @repository.find_changeset_by_name('13')
assert_nil changeset.next
end

Expand Down

0 comments on commit 8fd75e0

Please sign in to comment.