diff --git a/CHANGELOG.md b/CHANGELOG.md index d0d08097a7..cf7d07b984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ documentation](doc/development/changelog.md) for instructions on adding your own entry. +## 13.12.4 (2021-06-14) + +### Fixed (3 changes) + +- [Add alias method usage_ping_enabled?](gitlab-org/gitlab@eb8755115a2a7045b6291171aaa0c7ae76f43fec) ([merge request](gitlab-org/gitlab!63974)) +- [Fix MR diff compare with previous version](gitlab-org/gitlab@96d4df8bb4eb5f148e4dabcc4c3eea88ad27cbc3) ([merge request](gitlab-org/gitlab!63974)) +- [Fix double render in project's git URL redirect](gitlab-org/gitlab@be4059b7a5cddd2e70fa760d8935b1d170068759) ([merge request](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62053)) + ## 13.12.3 (2021-06-07) ### Added (1 change) diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 975d54d8fc..535687224a 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -13.12.3 \ No newline at end of file +13.12.4 \ No newline at end of file diff --git a/VERSION b/VERSION index 975d54d8fc..535687224a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -13.12.3 \ No newline at end of file +13.12.4 \ No newline at end of file diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index 3eaabfbf33..f125952cb9 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -163,7 +163,10 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic end def render_merge_ref_head_diff? - Gitlab::Utils.to_boolean(params[:diff_head]) && @merge_request.diffable_merge_ref? && @start_sha.nil? + params[:diff_id].blank? && + Gitlab::Utils.to_boolean(params[:diff_head]) && + @merge_request.diffable_merge_ref? && + @start_sha.nil? end def note_positions diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e66893ac26..fb977a5ee4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -510,7 +510,7 @@ class ProjectsController < Projects::ApplicationController # `project` calls `find_routable!`, so this will trigger the usual not-found # behaviour when the user isn't authorized to see the project - return unless project + return if project.nil? || performed? redirect_to(request.original_url.sub(%r{\.git/?\Z}, '')) end diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index 5ff1c653f9..bf9df3b9ef 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -374,6 +374,7 @@ module ApplicationSettingImplementation def usage_ping_enabled usage_ping_can_be_configured? && super end + alias_method :usage_ping_enabled?, :usage_ping_enabled def allowed_key_types SUPPORTED_KEY_TYPES.select do |type| diff --git a/debian/changelog b/debian/changelog index 99a366b917..d67315a838 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +gitlab (13.12.4+ds1-1) experimental; urgency=medium + + * Update minimum version of golang-any (>= 2:1.15~) + * Export GEM_HOME in gitlab-rails-console script + * Install grpc and google-protobuf before GEM_HOME is set + * New upstream version 13.12.4+ds1 + + -- Pirate Praveen Mon, 21 Jun 2021 23:58:09 +0530 + gitlab (13.12.3+ds1-7~fto11+1) bullseye-fasttrack; urgency=medium * Rebuild for bullseye-fasttrack. diff --git a/debian/control b/debian/control index f6f182f7bb..dd7a487d61 100644 --- a/debian/control +++ b/debian/control @@ -10,7 +10,7 @@ Uploaders: Cédric Boutillier , Build-Depends: debhelper (>= 10~), gem2deb, dh-golang, - golang-any, + golang-any (>= 2:1.15~), bc, golang-github-alecthomas-chroma-dev, golang-github-aws-aws-sdk-go-dev, diff --git a/debian/gitlab-rails-console.sh b/debian/gitlab-rails-console.sh index 73148c626a..e6242bfb5c 100755 --- a/debian/gitlab-rails-console.sh +++ b/debian/gitlab-rails-console.sh @@ -5,7 +5,7 @@ set -e # Read debian specific configuration . /etc/gitlab-common/gitlab-common.conf . /etc/gitlab/gitlab-debian.conf -export DB RAILS_ENV +export DB RAILS_ENV GEM_HOME cd /usr/share/gitlab diff --git a/debian/gitlab.postinst b/debian/gitlab.postinst index 6badff21bb..4d7beb77a4 100755 --- a/debian/gitlab.postinst +++ b/debian/gitlab.postinst @@ -37,6 +37,13 @@ test -f ${gitlab_common_defaults} && . ${gitlab_common_defaults} # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. +# These gems should be installed as root for gitlab to find it +# Setting GEM_HOME seems not working for all cases, help welcome to fix it +# Workaround for #966653 +/usr/bin/gem install -v 1.30.2 grpc +# Workaround for #989774 +/usr/bin/gem install -v 3.17.1 google-protobuf + ####################################################################### # Read debian specific configuration ####################################################################### @@ -50,9 +57,6 @@ cp ${gitlab_debian_conf_example} ${gitlab_debian_conf_private} test -f ${gitlab_debian_conf} && . ${gitlab_debian_conf} export DB RAILS_ENV -# Required for embedded gems -export GEM_HOME=/var/lib/gitlab/.gem - # Read default values (we cannot do this before gitlab-debian.conf is exported # as we want to override variables set by gitlab-debian.conf in earlier gitlab # versions with gitlab-debian.defaults) @@ -61,10 +65,8 @@ export GEM_HOME=/var/lib/gitlab/.gem # Read gitlab_user from gitlab-common.conf test -f ${gitlab_common_conf} && . ${gitlab_common_conf} -# Workaround for #966653 -/usr/bin/gem install -v 1.30.2 grpc -# Workaround for #989774 -/usr/bin/gem install -v 3.17.1 google-protobuf +# Required for embedded gems +export GEM_HOME=/var/lib/gitlab/.gem ####################################################################### # update Gemfile.lock and yarn.lock, always diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb index 989f941cae..4fcb63ac61 100644 --- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb @@ -69,6 +69,20 @@ RSpec.describe Projects::MergeRequests::DiffsController do end end + shared_examples 'show the right diff files with previous diff_id' do + context 'with previous diff_id' do + let!(:merge_request_diff_1) { merge_request.merge_request_diffs.create!(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } + let!(:merge_request_diff_2) { merge_request.merge_request_diffs.create!(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e', diff_type: :merge_head) } + + subject { go(diff_id: merge_request_diff_1.id, diff_head: true) } + + it 'shows the right diff files' do + subject + expect(json_response["diff_files"].size).to eq(merge_request_diff_1.files_count) + end + end + end + let(:project) { create(:project, :repository) } let(:user) { create(:user) } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) } @@ -142,6 +156,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do it_behaves_like '404 for unexistent diffable' + it_behaves_like 'show the right diff files with previous diff_id' + context 'when not authorized' do let(:another_user) { create(:user) } @@ -480,6 +496,8 @@ RSpec.describe Projects::MergeRequests::DiffsController do it_behaves_like '404 for unexistent diffable' + it_behaves_like 'show the right diff files with previous diff_id' + context 'when not authorized' do let(:other_user) { create(:user) } @@ -499,7 +517,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do it_behaves_like 'serializes diffs with expected arguments' do let(:collection) { Gitlab::Diff::FileCollection::MergeRequestDiffBatch } - let(:expected_options) { collection_arguments(current_page: 1, total_pages: 1) } + let(:expected_options) { collection_arguments(current_page: 1, total_pages: 1).merge(merge_ref_head_diff: false) } end it_behaves_like 'successful request' @@ -522,7 +540,7 @@ RSpec.describe Projects::MergeRequests::DiffsController do it_behaves_like 'serializes diffs with expected arguments' do let(:collection) { Gitlab::Diff::FileCollection::Compare } - let(:expected_options) { collection_arguments } + let(:expected_options) { collection_arguments.merge(merge_ref_head_diff: false) } end it_behaves_like 'successful request' diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index ffe2d393b1..fdc687496b 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -375,6 +375,23 @@ RSpec.describe ProjectsController do end end + context 'when project is moved and git format is requested' do + let(:old_path) { project.path + 'old' } + + before do + project.redirect_routes.create!(path: "#{project.namespace.full_path}/#{old_path}") + + project.add_developer(user) + sign_in(user) + end + + it 'redirects to new project path' do + get :show, params: { namespace_id: project.namespace, id: old_path }, format: :git + + expect(response).to redirect_to(project_path(project, format: :git)) + end + end + context 'when the project is forked and has a repository', :request_store do let(:public_project) { create(:project, :public, :repository) } let(:other_user) { create(:user) } diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 4b4e7820f7..c13d83d168 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -363,6 +363,85 @@ RSpec.describe ApplicationSetting do .is_less_than(65536) end + describe 'usage_ping_enabled setting' do + shared_examples 'usage ping enabled' do + it do + expect(setting.usage_ping_enabled).to eq(true) + expect(setting.usage_ping_enabled?).to eq(true) + end + end + + shared_examples 'usage ping disabled' do + it do + expect(setting.usage_ping_enabled).to eq(false) + expect(setting.usage_ping_enabled?).to eq(false) + end + end + + context 'when setting is in database' do + context 'with usage_ping_enabled disabled' do + before do + setting.update!(usage_ping_enabled: false) + end + + it_behaves_like 'usage ping disabled' + end + + context 'with usage_ping_enabled enabled' do + before do + setting.update!(usage_ping_enabled: true) + end + + it_behaves_like 'usage ping enabled' + end + end + + context 'when setting is in GitLab config' do + context 'with usage_ping_enabled disabled' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false) + end + + it_behaves_like 'usage ping disabled' + end + + context 'with usage_ping_enabled enabled' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true) + end + + it_behaves_like 'usage ping enabled' + end + end + + context 'when setting in database false and setting in GitLab config true' do + before do + setting.update!(usage_ping_enabled: false) + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true) + end + + it_behaves_like 'usage ping disabled' + end + + context 'when setting database true and setting in GitLab config false' do + before do + setting.update!(usage_ping_enabled: true) + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false) + end + + it_behaves_like 'usage ping disabled' + end + + context 'when setting database true and setting in GitLab config true' do + before do + setting.update!(usage_ping_enabled: true) + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true) + end + + it_behaves_like 'usage ping enabled' + end + end + context 'key restrictions' do it 'supports all key types' do expect(described_class::SUPPORTED_KEY_TYPES).to contain_exactly(:rsa, :dsa, :ecdsa, :ed25519) diff --git a/spec/services/submit_usage_ping_service_spec.rb b/spec/services/submit_usage_ping_service_spec.rb index a9f1b2c2b2..7133dc35fc 100644 --- a/spec/services/submit_usage_ping_service_spec.rb +++ b/spec/services/submit_usage_ping_service_spec.rb @@ -90,6 +90,14 @@ RSpec.describe SubmitUsagePingService do it_behaves_like 'does not run' end + context 'when usage ping is disabled from GitLab config file' do + before do + stub_config_setting(usage_ping_enabled: false) + end + + it_behaves_like 'does not run' + end + context 'when usage ping is enabled' do before do stub_usage_data_connections