diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-03-27 18:20:03 +0200 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-03-27 18:20:08 +0200 |
commit | 39c911eaaa68c79381fb420859b45658e9c71f2f (patch) | |
tree | c23eeba9281d99cf4788461675f13095ddd7a82f | |
parent | f56ef2065710346f9998c87a136abc2fe3cbc454 (diff) | |
download | gitlab-ce-dm-refs-contains-sha-encoding.tar.gz |
Fix listing commit branch/tags that contain special charactersdm-refs-contains-sha-encoding
-rw-r--r-- | changelogs/unreleased/dm-refs-contains-sha-encoding.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/git/repository.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/git/repository_spec.rb | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/changelogs/unreleased/dm-refs-contains-sha-encoding.yml b/changelogs/unreleased/dm-refs-contains-sha-encoding.yml new file mode 100644 index 00000000000..cdd9ead5a65 --- /dev/null +++ b/changelogs/unreleased/dm-refs-contains-sha-encoding.yml @@ -0,0 +1,5 @@ +--- +title: Fix listing commit branch/tags that contain special characters +merge_request: +author: +type: fixed diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 20b0647fce9..2d16a81c888 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -8,6 +8,7 @@ module Gitlab class Repository include Gitlab::Git::RepositoryMirroring include Gitlab::Git::Popen + include Gitlab::EncodingHelper ALLOWED_OBJECT_DIRECTORIES_VARIABLES = %w[ GIT_OBJECT_DIRECTORY @@ -1479,7 +1480,7 @@ module Gitlab names.lines.each do |line| next unless line.start_with?(refs_prefix) - refs << line.rstrip[left_slice_count..-1] + refs << encode_utf8(line.rstrip[left_slice_count..-1]) end refs diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 54ada3e423f..0e315b3f49e 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -604,17 +604,20 @@ describe Gitlab::Git::Repository, seed_helper: true do shared_examples 'returning the right branches' do let(:head_id) { repository.rugged.head.target.oid } let(:new_branch) { head_id } + let(:utf8_branch) { 'branch-é' } before do repository.create_branch(new_branch, 'master') + repository.create_branch(utf8_branch, 'master') end after do repository.delete_branch(new_branch) + repository.delete_branch(utf8_branch) end it 'displays that branch' do - expect(repository.branch_names_contains_sha(head_id)).to include('master', new_branch) + expect(repository.branch_names_contains_sha(head_id)).to include('master', new_branch, utf8_branch) end end |