From 415483fddb027a05f6a5bd0953b4bf05045bff1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 19 Oct 2017 08:17:01 +0000 Subject: Merge branch 'encoding-helper-performance' into 'master' Avoind unnecesary `force_encoding` operations Closes #39227 See merge request gitlab-org/gitlab-ce!12167 (cherry picked from commit 371eb62bc90a70f4a578303215e1d4dfc430ddbb) 520866a0 Avoind unnecesary `force_encoding` operations --- lib/gitlab/encoding_helper.rb | 7 +++++-- spec/lib/gitlab/encoding_helper_spec.rb | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb index 7b3483a7f96..99dfee3dd9b 100644 --- a/lib/gitlab/encoding_helper.rb +++ b/lib/gitlab/encoding_helper.rb @@ -14,9 +14,9 @@ module Gitlab ENCODING_CONFIDENCE_THRESHOLD = 50 def encode!(message) - return nil unless message.respond_to? :force_encoding + return nil unless message.respond_to?(:force_encoding) + return message if message.encoding == Encoding::UTF_8 && message.valid_encoding? - # if message is utf-8 encoding, just return it message.force_encoding("UTF-8") return message if message.valid_encoding? @@ -50,6 +50,9 @@ module Gitlab end def encode_utf8(message) + return nil unless message.is_a?(String) + return message if message.encoding == Encoding::UTF_8 && message.valid_encoding? + detect = CharlockHolmes::EncodingDetector.detect(message) if detect && detect[:encoding] begin diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index 8b14b227e65..9151c66afb3 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -6,6 +6,9 @@ describe Gitlab::EncodingHelper do describe '#encode!' do [ + ["nil", nil, nil], + ["empty string", "".encode("ASCII-8BIT"), "".encode("UTF-8")], + ["invalid utf-8 encoded string", "my bad string\xE5".force_encoding("UTF-8"), "my bad string"], [ 'leaves ascii only string as is', 'ascii only string', @@ -81,6 +84,9 @@ describe Gitlab::EncodingHelper do describe '#encode_utf8' do [ + ["nil", nil, nil], + ["empty string", "".encode("ASCII-8BIT"), "".encode("UTF-8")], + ["invalid utf-8 encoded string", "my bad string\xE5".force_encoding("UTF-8"), "my bad stringå"], [ "encodes valid utf8 encoded string to utf8", "λ, λ, λ".encode("UTF-8"), @@ -95,12 +101,18 @@ describe Gitlab::EncodingHelper do "encodes valid ISO-8859-1 encoded string to utf8", "Rüby ist eine Programmiersprache. Wir verlängern den text damit ICU die Sprache erkennen kann.".encode("ISO-8859-1", "UTF-8"), "Rüby ist eine Programmiersprache. Wir verlängern den text damit ICU die Sprache erkennen kann.".encode("UTF-8") + ], + [ + # Test case from https://gitlab.com/gitlab-org/gitlab-ce/issues/39227 + "Equifax branch name", + "refs/heads/Equifax".encode("UTF-8"), + "refs/heads/Equifax".encode("UTF-8") ] ].each do |description, test_string, xpect| it description do - r = ext_class.encode_utf8(test_string.force_encoding('UTF-8')) + r = ext_class.encode_utf8(test_string) expect(r).to eq(xpect) - expect(r.encoding.name).to eq('UTF-8') + expect(r.encoding.name).to eq('UTF-8') if xpect end end -- cgit v1.2.1 From b3cc7385caf12d5d84b44b52529c13e60b5b030e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 19 Oct 2017 11:28:29 +0000 Subject: Merge branch 'sh-fix-broken-docker-delete' into 'master' Fix inability to delete container registry tags Closes #39260 See merge request gitlab-org/gitlab-ce!14947 (cherry picked from commit 83f5955ee342af01cea7a9a2e18089a3de615a06) b7e35033 Fix inability to delete container registry tags de57492d Fix broken function invocation --- .../javascripts/registry/components/collapsible_container.vue | 2 +- app/assets/javascripts/registry/components/table_registry.vue | 2 +- app/serializers/container_tag_entity.rb | 2 +- config/routes/project.rb | 9 +++++++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/registry/components/collapsible_container.vue b/app/assets/javascripts/registry/components/collapsible_container.vue index 41ea9742406..ac1c3ec253c 100644 --- a/app/assets/javascripts/registry/components/collapsible_container.vue +++ b/app/assets/javascripts/registry/components/collapsible_container.vue @@ -57,7 +57,7 @@ }, showError(message) { - Flash((errorMessages[message])); + Flash(errorMessages[message]); }, }, }; diff --git a/app/assets/javascripts/registry/components/table_registry.vue b/app/assets/javascripts/registry/components/table_registry.vue index 4ce1571b0aa..e917279947e 100644 --- a/app/assets/javascripts/registry/components/table_registry.vue +++ b/app/assets/javascripts/registry/components/table_registry.vue @@ -57,7 +57,7 @@ }, showError(message) { - Flash((errorMessages[message])); + Flash(errorMessages[message]); }, }, }; diff --git a/app/serializers/container_tag_entity.rb b/app/serializers/container_tag_entity.rb index 26a68c43807..8f1488e6cbb 100644 --- a/app/serializers/container_tag_entity.rb +++ b/app/serializers/container_tag_entity.rb @@ -4,7 +4,7 @@ class ContainerTagEntity < Grape::Entity expose :name, :location, :revision, :short_revision, :total_size, :created_at expose :destroy_path, if: -> (*) { can_destroy? } do |tag| - project_registry_repository_tag_path(project, tag.repository, tag.name, format: :json) + project_registry_repository_tag_path(project, tag.repository, tag.name) end private diff --git a/config/routes/project.rb b/config/routes/project.rb index 7f0e056c884..d05fe11f233 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -281,8 +281,13 @@ constraints(ProjectUrlConstrainer.new) do namespace :registry do resources :repository, only: [] do - resources :tags, only: [:index, :destroy], - constraints: { id: Gitlab::Regex.container_registry_tag_regex } + # We default to JSON format in the controller to avoid ambiguity. + # `latest.json` could either be a request for a tag named `latest` + # in JSON format, or a request for tag named `latest.json`. + scope format: false do + resources :tags, only: [:index, :destroy], + constraints: { id: Gitlab::Regex.container_registry_tag_regex } + end end end -- cgit v1.2.1 From a91eb65570127039af177a785bf023eb3ad6d0be Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 19 Oct 2017 13:43:22 +0000 Subject: Merge branch 'pawel/upgrade_prometheus_gem_to_fix_problem_with_file_locking' into 'master' Update Prometheus gem to fix problems with other Processes overwriting current metrics file Closes #36714 See merge request gitlab-org/gitlab-ce!14827 (cherry picked from commit f73efb793233f69a0402ba529410bf52c6105c2c) f9a4f184 Update Prometheus gem to fix problems with other files overwriting current file --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 5645d1ea4ff..98a614c0a35 100644 --- a/Gemfile +++ b/Gemfile @@ -281,7 +281,7 @@ group :metrics do gem 'influxdb', '~> 0.2', require: false # Prometheus - gem 'prometheus-client-mmap', '~>0.7.0.beta14' + gem 'prometheus-client-mmap', '~>0.7.0.beta17' gem 'raindrops', '~> 0.18' end diff --git a/Gemfile.lock b/Gemfile.lock index 6040596dda5..8dc206c46a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -620,7 +620,7 @@ GEM parser unparser procto (0.0.3) - prometheus-client-mmap (0.7.0.beta14) + prometheus-client-mmap (0.7.0.beta17) mmap2 (~> 2.2, >= 2.2.7) pry (0.10.4) coderay (~> 1.1.0) @@ -1103,7 +1103,7 @@ DEPENDENCIES pg (~> 0.18.2) poltergeist (~> 1.9.0) premailer-rails (~> 1.9.7) - prometheus-client-mmap (~> 0.7.0.beta14) + prometheus-client-mmap (~> 0.7.0.beta17) pry-byebug (~> 3.4.1) pry-rails (~> 0.3.4) rack-attack (~> 4.4.1) -- cgit v1.2.1 From 8b744b21f3725eb6772f8750c8b76d4593215f04 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 20 Oct 2017 10:40:27 +0000 Subject: Merge branch 'fix-non-diff-resolved-discussion' into 'master' Force non diff resolved discussion to display when collapse toggled Closes #39187 See merge request gitlab-org/gitlab-ce!14946 (cherry picked from commit 9c3f094a2f7609386ed182e4d5f6f9e7f6938388) 9487cadf Force non diff resolved discussion to display when collapse toggled 1c4f42a4 Add spec f6304f16 Add changelog --- app/views/discussions/_discussion.html.haml | 2 +- .../fix-non-diff-resolved-discussion.yml | 5 ++++ .../features/discussion_comments_shared_example.rb | 29 +++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/fix-non-diff-resolved-discussion.yml diff --git a/app/views/discussions/_discussion.html.haml b/app/views/discussions/_discussion.html.haml index 578e751ab47..0f03163a2e8 100644 --- a/app/views/discussions/_discussion.html.haml +++ b/app/views/discussions/_discussion.html.haml @@ -44,4 +44,4 @@ = render "discussions/diff_with_notes", discussion: discussion - else .panel.panel-default - = render "discussions/notes", discussion: discussion + = render partial: "discussions/notes", locals: { discussion: discussion, disable_collapse_class: true } diff --git a/changelogs/unreleased/fix-non-diff-resolved-discussion.yml b/changelogs/unreleased/fix-non-diff-resolved-discussion.yml new file mode 100644 index 00000000000..9bff53ea7c9 --- /dev/null +++ b/changelogs/unreleased/fix-non-diff-resolved-discussion.yml @@ -0,0 +1,5 @@ +--- +title: Force non diff resolved discussion to display when collapse toggled +merge_request: +author: +type: fixed diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb index 9f05cabf7ae..7132b9cd221 100644 --- a/spec/support/features/discussion_comments_shared_example.rb +++ b/spec/support/features/discussion_comments_shared_example.rb @@ -121,14 +121,31 @@ shared_examples 'discussion comments' do |resource_name| end end - it 'clicking "Start discussion" will post a discussion' do - find(submit_selector).click + describe 'creating a discussion' do + before do + find(submit_selector).click + find(comments_selector, match: :first) + end + + it 'clicking "Start discussion" will post a discussion' do + new_comment = all(comments_selector).last + + expect(new_comment).to have_content 'a' + expect(new_comment).to have_selector '.discussion' + end + + if resource_name == 'merge request' + it 'shows resolved discussion when toggled' do + click_button "Resolve discussion" + + expect(page).to have_selector('.note-row-1', visible: true) - find(comments_selector, match: :first) - new_comment = all(comments_selector).last + refresh + click_button "Toggle discussion" - expect(new_comment).to have_content 'a' - expect(new_comment).to have_selector '.discussion' + expect(page).to have_selector('.note-row-1', visible: true) + end + end end if resource_name == 'issue' -- cgit v1.2.1