From 7bb5190c68ecd8164887a65152692a539ecc5220 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 29 Sep 2017 15:30:56 +0000 Subject: Merge branch '38582-popover-badge' into 'master' Improves UX of autodevops popover to match gpg one Closes #38582 See merge request gitlab-org/gitlab-ce!14582 --- app/assets/javascripts/pipelines/components/pipeline_url.vue | 4 ++-- changelogs/unreleased/38582-popover-badge.yml | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/38582-popover-badge.yml diff --git a/app/assets/javascripts/pipelines/components/pipeline_url.vue b/app/assets/javascripts/pipelines/components/pipeline_url.vue index f0b44dfa6d8..76b97af39f1 100644 --- a/app/assets/javascripts/pipelines/components/pipeline_url.vue +++ b/app/assets/javascripts/pipelines/components/pipeline_url.vue @@ -28,8 +28,7 @@ popoverOptions() { return { html: true, - delay: { hide: 600 }, - trigger: 'hover', + trigger: 'focus', placement: 'top', title: '
This pipeline makes use of a predefined CI/CD configuration enabled by Auto DevOps.
', content: `Learn more about Auto DevOps`, @@ -75,6 +74,7 @@ diff --git a/changelogs/unreleased/38582-popover-badge.yml b/changelogs/unreleased/38582-popover-badge.yml new file mode 100644 index 00000000000..ccec679a13f --- /dev/null +++ b/changelogs/unreleased/38582-popover-badge.yml @@ -0,0 +1,5 @@ +--- +title: Improves UX of autodevops popover to match gpg one +merge_request: +author: +type: fixed -- cgit v1.2.3 From 7c34c3c0945a75f0252ce4b2bd5a4996f55d16a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 28 Sep 2017 17:15:32 +0000 Subject: Merge branch 'bvl-fix-close-issuable-link' into 'master' Use relative paths for opening and closing issuables Closes #35822 See merge request gitlab-org/gitlab-ce!14555 --- app/helpers/issuables_helper.rb | 21 +++++++++++++++------ .../shared/issuable/_close_reopen_button.html.haml | 4 ++-- .../issuable/_close_reopen_report_toggle.html.haml | 6 +++--- .../unreleased/bvl-fix-close-issuable-link.yml | 5 +++++ 4 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 changelogs/unreleased/bvl-fix-close-issuable-link.yml diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index df390dd5aab..7713fb0b9f8 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -248,16 +248,25 @@ module IssuablesHelper Gitlab::IssuablesCountForState.new(finder)[state] end - def close_issuable_url(issuable) - issuable_url(issuable, close_reopen_params(issuable, :close)) + def close_issuable_path(issuable) + issuable_path(issuable, close_reopen_params(issuable, :close)) end - def reopen_issuable_url(issuable) - issuable_url(issuable, close_reopen_params(issuable, :reopen)) + def reopen_issuable_path(issuable) + issuable_path(issuable, close_reopen_params(issuable, :reopen)) end - def close_reopen_issuable_url(issuable, should_inverse = false) - issuable.closed? ^ should_inverse ? reopen_issuable_url(issuable) : close_issuable_url(issuable) + def close_reopen_issuable_path(issuable, should_inverse = false) + issuable.closed? ^ should_inverse ? reopen_issuable_path(issuable) : close_issuable_path(issuable) + end + + def issuable_path(issuable, *options) + case issuable + when Issue + issue_path(issuable, *options) + when MergeRequest + merge_request_path(issuable, *options) + end end def issuable_url(issuable, *options) diff --git a/app/views/shared/issuable/_close_reopen_button.html.haml b/app/views/shared/issuable/_close_reopen_button.html.haml index f16bc8dd430..9ef015047c9 100644 --- a/app/views/shared/issuable/_close_reopen_button.html.haml +++ b/app/views/shared/issuable/_close_reopen_button.html.haml @@ -3,9 +3,9 @@ - button_method = issuable_close_reopen_button_method(issuable) - if can_update && is_current_user - = link_to "Close #{display_issuable_type}", close_issuable_url(issuable), method: button_method, + = link_to "Close #{display_issuable_type}", close_issuable_path(issuable), method: button_method, class: "hidden-xs hidden-sm btn btn-grouped btn-close js-btn-issue-action #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}" - = link_to "Reopen #{display_issuable_type}", reopen_issuable_url(issuable), method: button_method, + = link_to "Reopen #{display_issuable_type}", reopen_issuable_path(issuable), method: button_method, class: "hidden-xs hidden-sm btn btn-grouped btn-reopen js-btn-issue-action #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}" - elsif can_update && !is_current_user = render 'shared/issuable/close_reopen_report_toggle', issuable: issuable diff --git a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml index a38cd319e3c..39a5171c1d6 100644 --- a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml +++ b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml @@ -7,7 +7,7 @@ - button_method = issuable_close_reopen_button_method(issuable) .pull-left.btn-group.prepend-left-10.issuable-close-dropdown.droplab-dropdown.js-issuable-close-dropdown - = link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_url(issuable), + = link_to "#{display_button_action} #{display_issuable_type}", close_reopen_issuable_path(issuable), method: button_method, class: "#{button_class} btn-#{button_action}", title: "#{display_button_action} #{display_issuable_type}" = button_tag type: 'button', class: "#{toggle_class} btn-#{button_action}-color", @@ -16,7 +16,7 @@ %ul#issuable-close-menu.js-issuable-close-menu.dropdown-menu{ class: button_responsive_class, data: { dropdown: true } } %li.close-item{ class: "#{issuable_button_visibility(issuable, true) || 'droplab-item-selected'}", - data: { text: "Close #{display_issuable_type}", url: close_issuable_url(issuable), + data: { text: "Close #{display_issuable_type}", url: close_issuable_path(issuable), button_class: "#{button_class} btn-close", toggle_class: "#{toggle_class} btn-close-color", method: button_method } } %button.btn.btn-transparent = icon('check', class: 'icon') @@ -26,7 +26,7 @@ = display_issuable_type %li.reopen-item{ class: "#{issuable_button_visibility(issuable, false) || 'droplab-item-selected'}", - data: { text: "Reopen #{display_issuable_type}", url: reopen_issuable_url(issuable), + data: { text: "Reopen #{display_issuable_type}", url: reopen_issuable_path(issuable), button_class: "#{button_class} btn-reopen", toggle_class: "#{toggle_class} btn-reopen-color", method: button_method } } %button.btn.btn-transparent = icon('check', class: 'icon') diff --git a/changelogs/unreleased/bvl-fix-close-issuable-link.yml b/changelogs/unreleased/bvl-fix-close-issuable-link.yml new file mode 100644 index 00000000000..140a9d35cc1 --- /dev/null +++ b/changelogs/unreleased/bvl-fix-close-issuable-link.yml @@ -0,0 +1,5 @@ +--- +title: Fix CSRF validation issue when closing/opening merge requests from the UI +merge_request: 14555 +author: +type: fixed -- cgit v1.2.3 From 52b3667e5e6755fe128d06dd0c754a4bd6222229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 29 Sep 2017 13:08:48 +0000 Subject: Merge branch 'make-has-visible-commit-more-efficient' into 'master' Make Repository#has_visible_content more efficient See merge request gitlab-org/gitlab-ce!14554 --- app/models/repository.rb | 9 ++----- lib/gitlab/git/repository.rb | 26 ++++++++++++++++++- lib/gitlab/gitaly_client/ref_service.rb | 8 ++++++ spec/lib/gitlab/git/repository_spec.rb | 34 +++++++++++++++++++++++++ spec/models/repository_spec.rb | 30 ++++++++++++++-------- spec/workers/git_garbage_collect_worker_spec.rb | 6 ++--- 6 files changed, 91 insertions(+), 22 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 0315fed24c5..4cb9f1baffd 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -90,12 +90,6 @@ class Repository ) end - # we need to have this method here because it is not cached in ::Git and - # the method is called multiple times for every request - def has_visible_content? - branch_count > 0 - end - def inspect "#<#{self.class.name}:#{@disk_path}>" end @@ -522,9 +516,10 @@ class Repository delegate :tag_names, to: :raw_repository cache_method :tag_names, fallback: [] - delegate :branch_count, :tag_count, to: :raw_repository + delegate :branch_count, :tag_count, :has_visible_content?, to: :raw_repository cache_method :branch_count, fallback: 0 cache_method :tag_count, fallback: 0 + cache_method :has_visible_content?, fallback: false def avatar if tree = file_on_head(:avatar) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 6c639f286ee..984e34a9ef1 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -190,6 +190,28 @@ module Gitlab end end + def has_local_branches? + gitaly_migrate(:has_local_branches) do |is_enabled| + if is_enabled + gitaly_ref_client.has_local_branches? + else + has_local_branches_rugged? + end + end + end + + def has_local_branches_rugged? + rugged.branches.each(:local).any? do |ref| + begin + ref.name && ref.target # ensures the branch is valid + + true + rescue Rugged::ReferenceError + false + end + end + end + # Returns the number of valid tags def tag_count gitaly_migrate(:tag_names) do |is_enabled| @@ -909,7 +931,9 @@ module Gitlab # This method return true if repository contains some content visible in project page. # def has_visible_content? - branch_count > 0 + return @has_visible_content if defined?(@has_visible_content) + + @has_visible_content = has_local_branches? end def gitaly_repository diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb index 8ef873d5848..52c1f1ab3d0 100644 --- a/lib/gitlab/gitaly_client/ref_service.rb +++ b/lib/gitlab/gitaly_client/ref_service.rb @@ -57,6 +57,14 @@ module Gitlab branch_names.count end + # TODO implement a more efficient RPC for this https://gitlab.com/gitlab-org/gitaly/issues/616 + def has_local_branches? + request = Gitaly::FindAllBranchNamesRequest.new(repository: @gitaly_repo) + response = GitalyClient.call(@storage, :ref_service, :find_all_branch_names, request).first + + response&.names.present? + end + def local_branches(sort_by: nil) request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo) request.sort_by = sort_by_param(sort_by) if sort_by diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 6c014fac2b0..236265a9090 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -389,6 +389,40 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#has_local_branches?' do + shared_examples 'check for local branches' do + it { expect(repository.has_local_branches?).to eq(true) } + + context 'mutable' do + let(:repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') } + + after do + ensure_seeds + end + + it 'returns false when there are no branches' do + # Sanity check + expect(repository.has_local_branches?).to eq(true) + + FileUtils.rm_rf(File.join(repository.path, 'packed-refs')) + heads_dir = File.join(repository.path, 'refs/heads') + FileUtils.rm_rf(heads_dir) + FileUtils.mkdir_p(heads_dir) + + expect(repository.has_local_branches?).to eq(false) + end + end + end + + context 'with gitaly' do + it_behaves_like 'check for local branches' + end + + context 'without gitaly', skip_gitaly_mock: true do + it_behaves_like 'check for local branches' + end + end + describe "#delete_branch" do shared_examples "deleting a branch" do let(:repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 7065d467ec0..d76ab421553 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1134,21 +1134,31 @@ describe Repository, models: true do end describe '#has_visible_content?' do - subject { repository.has_visible_content? } + before do + # If raw_repository.has_visible_content? gets called more than once then + # caching is broken. We don't want that. + expect(repository.raw_repository).to receive(:has_visible_content?) + .once + .and_return(result) + end - describe 'when there are no branches' do - before do - allow(repository.raw_repository).to receive(:branch_count).and_return(0) - end + context 'when true' do + let(:result) { true } - it { is_expected.to eq(false) } + it 'returns true and caches it' do + expect(repository.has_visible_content?).to eq(true) + # Second call hits the cache + expect(repository.has_visible_content?).to eq(true) + end end - describe 'when there are branches' do - it 'returns true' do - expect(repository.raw_repository).to receive(:branch_count).and_return(3) + context 'when false' do + let(:result) { false } - expect(subject).to eq(true) + it 'returns false and caches it' do + expect(repository.has_visible_content?).to eq(false) + # Second call hits the cache + expect(repository.has_visible_content?).to eq(false) end end end diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index f7b67b8efc6..ab656d619f4 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -32,7 +32,7 @@ describe GitGarbageCollectWorker do expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).to receive(:branch_names).and_call_original expect_any_instance_of(Repository).to receive(:has_visible_content?).and_call_original - expect_any_instance_of(Gitlab::Git::Repository).to receive(:branch_count).and_call_original + expect_any_instance_of(Gitlab::Git::Repository).to receive(:has_visible_content?).and_call_original subject.perform(project.id, :gc, lease_key, lease_uuid) end @@ -47,7 +47,6 @@ describe GitGarbageCollectWorker do expect(subject).not_to receive(:command) expect_any_instance_of(Repository).not_to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).not_to receive(:branch_names).and_call_original - expect_any_instance_of(Repository).not_to receive(:branch_count).and_call_original expect_any_instance_of(Repository).not_to receive(:has_visible_content?).and_call_original subject.perform(project.id, :gc, lease_key, lease_uuid) @@ -78,7 +77,7 @@ describe GitGarbageCollectWorker do expect_any_instance_of(Repository).to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).to receive(:branch_names).and_call_original expect_any_instance_of(Repository).to receive(:has_visible_content?).and_call_original - expect_any_instance_of(Gitlab::Git::Repository).to receive(:branch_count).and_call_original + expect_any_instance_of(Gitlab::Git::Repository).to receive(:has_visible_content?).and_call_original subject.perform(project.id) end @@ -93,7 +92,6 @@ describe GitGarbageCollectWorker do expect(subject).not_to receive(:command) expect_any_instance_of(Repository).not_to receive(:after_create_branch).and_call_original expect_any_instance_of(Repository).not_to receive(:branch_names).and_call_original - expect_any_instance_of(Repository).not_to receive(:branch_count).and_call_original expect_any_instance_of(Repository).not_to receive(:has_visible_content?).and_call_original subject.perform(project.id) -- cgit v1.2.3 From 6d3bafcc18a7cdca6529b31ac19408979cac9364 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 29 Sep 2017 08:49:13 +0000 Subject: Merge branch 'docs-fix-auto-devops-banner-feature-flag' into 'master' Fix Auto DevOps banner feature flag Closes #38576 See merge request gitlab-org/gitlab-ce!14576 --- doc/topics/autodevops/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md index 0b7c11ea700..5561784ed0b 100644 --- a/doc/topics/autodevops/index.md +++ b/doc/topics/autodevops/index.md @@ -511,7 +511,7 @@ sudo gitlab-rails console Then run: ```ruby -Feature.get(:auto_devops_banner_disabled).disable +Feature.get(:auto_devops_banner_disabled).enable ``` Or through the HTTP API with an admin access token: -- cgit v1.2.3 From 886511fd18cb3e7bf7f3853432cfe6a3a9f2a705 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 29 Sep 2017 07:52:13 +0000 Subject: Merge branch '38528-build-url' into 'master' Fixes data parameter not being sent in ajax request for jobs log Closes #38528 See merge request gitlab-org/gitlab-ce!14564 --- app/assets/javascripts/build.js | 2 +- changelogs/unreleased/38528-build-url.yml | 5 +++++ spec/javascripts/build_spec.js | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/38528-build-url.yml diff --git a/app/assets/javascripts/build.js b/app/assets/javascripts/build.js index ae1a23132a7..e85a7bc1772 100644 --- a/app/assets/javascripts/build.js +++ b/app/assets/javascripts/build.js @@ -166,7 +166,7 @@ window.Build = (function () { Build.prototype.getBuildTrace = function () { return $.ajax({ url: `${this.pageUrl}/trace.json`, - data: this.state, + data: { state: this.state }, }) .done((log) => { gl.utils.setCiStatusFavicon(`${this.pageUrl}/status.json`); diff --git a/changelogs/unreleased/38528-build-url.yml b/changelogs/unreleased/38528-build-url.yml new file mode 100644 index 00000000000..357b9aacea8 --- /dev/null +++ b/changelogs/unreleased/38528-build-url.yml @@ -0,0 +1,5 @@ +--- +title: Fixes data parameter not being sent in ajax request for jobs log +merge_request: +author: +type: fixed diff --git a/spec/javascripts/build_spec.js b/spec/javascripts/build_spec.js index 35149611095..d5b0f23e7b7 100644 --- a/spec/javascripts/build_spec.js +++ b/spec/javascripts/build_spec.js @@ -289,4 +289,18 @@ describe('Build', () => { }); }); }); + + describe('getBuildTrace', () => { + it('should request build trace with state parameter', (done) => { + spyOn(jQuery, 'ajax').and.callThrough(); + new Build(); + + setTimeout(() => { + expect(jQuery.ajax).toHaveBeenCalledWith( + { url: `${BUILD_URL}/trace.json`, data: { state: '' } }, + ); + done(); + }, 0); + }); + }); }); -- cgit v1.2.3 From 450c98a6c0ff20e33383e2c5b04dfd6243599db6 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 2 Oct 2017 07:11:50 +0000 Subject: Merge branch 'sh-fix-issue-38646' into 'master' Fix pushes to an empty repository not invalidating has_visible_content? cache Closes #38646 See merge request gitlab-org/gitlab-ce!14613 --- app/models/repository.rb | 9 ++++++--- changelogs/unreleased/sh-fix-issue-38646.yml | 5 +++++ spec/models/repository_spec.rb | 13 ++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/sh-fix-issue-38646.yml diff --git a/app/models/repository.rb b/app/models/repository.rb index 4cb9f1baffd..a032df89e2d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -33,7 +33,10 @@ class Repository CACHED_METHODS = %i(size commit_count rendered_readme contribution_guide changelog license_blob license_key gitignore koding_yml gitlab_ci_yml branch_names tag_names branch_count - tag_count avatar exists? empty? root_ref).freeze + tag_count avatar exists? empty? root_ref has_visible_content?).freeze + + # Methods that use cache_method but only memoize the value + MEMOIZED_CACHED_METHODS = %i(license empty_repo?).freeze # Certain method caches should be refreshed when certain types of files are # changed. This Hash maps file types (as returned by Gitlab::FileDetector) to @@ -268,7 +271,7 @@ class Repository end def expire_branches_cache - expire_method_caches(%i(branch_names branch_count)) + expire_method_caches(%i(branch_names branch_count has_visible_content?)) @local_branches = nil @branch_exists_memo = nil end @@ -339,7 +342,7 @@ class Repository def expire_emptiness_caches return unless empty? - expire_method_caches(%i(empty?)) + expire_method_caches(%i(empty? has_visible_content?)) end def lookup_cache diff --git a/changelogs/unreleased/sh-fix-issue-38646.yml b/changelogs/unreleased/sh-fix-issue-38646.yml new file mode 100644 index 00000000000..5c205775662 --- /dev/null +++ b/changelogs/unreleased/sh-fix-issue-38646.yml @@ -0,0 +1,5 @@ +--- +title: Fix pushes to an empty repository not invalidating has_visible_content? cache +merge_request: +author: +type: fixed diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index d76ab421553..b46a19bfbb7 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1275,6 +1275,7 @@ describe Repository, models: true do allow(repository).to receive(:empty?).and_return(true) expect(cache).to receive(:expire).with(:empty?) + expect(cache).to receive(:expire).with(:has_visible_content?) repository.expire_emptiness_caches end @@ -1283,6 +1284,7 @@ describe Repository, models: true do allow(repository).to receive(:empty?).and_return(false) expect(cache).not_to receive(:expire).with(:empty?) + expect(cache).not_to receive(:expire).with(:has_visible_content?) repository.expire_emptiness_caches end @@ -1613,7 +1615,7 @@ describe Repository, models: true do describe '#expire_branches_cache' do it 'expires the cache' do expect(repository).to receive(:expire_method_caches) - .with(%i(branch_names branch_count)) + .with(%i(branch_names branch_count has_visible_content?)) .and_call_original repository.expire_branches_cache @@ -1874,6 +1876,15 @@ describe Repository, models: true do repository.expire_all_method_caches end + + it 'all cache_method definitions are in the lists of method caches' do + methods = repository.methods.map do |method| + match = /^_uncached_(.*)/.match(method) + match[1].to_sym if match + end.compact + + expect(methods).to match_array(Repository::CACHED_METHODS + Repository::MEMOIZED_CACHED_METHODS) + end end describe '#file_on_head' do -- cgit v1.2.3 From 585acd18022972bbee3fa2a27340fd16d06b6b29 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Mon, 2 Oct 2017 09:52:35 +0000 Subject: Merge branch 'sh-restore-all-refs-backup' into 'master' Ensure all refs are restored on a backup/restore Closes #38352 See merge request gitlab-org/gitlab-ce!14595 --- changelogs/unreleased/sh-restore-all-refs-backup.yml | 5 +++++ lib/backup/repository.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/sh-restore-all-refs-backup.yml diff --git a/changelogs/unreleased/sh-restore-all-refs-backup.yml b/changelogs/unreleased/sh-restore-all-refs-backup.yml new file mode 100644 index 00000000000..eaac0c71dd0 --- /dev/null +++ b/changelogs/unreleased/sh-restore-all-refs-backup.yml @@ -0,0 +1,5 @@ +--- +title: Ensure all refs are restored on a restore from backup +merge_request: +author: +type: fixed diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 4e92be85110..3ad09a1b421 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -78,7 +78,7 @@ module Backup project.ensure_storage_path_exists cmd = if File.exist?(path_to_project_bundle) - %W(#{Gitlab.config.git.bin_path} clone --bare #{path_to_project_bundle} #{path_to_project_repo}) + %W(#{Gitlab.config.git.bin_path} clone --bare --mirror #{path_to_project_bundle} #{path_to_project_repo}) else %W(#{Gitlab.config.git.bin_path} init --bare #{path_to_project_repo}) end -- cgit v1.2.3 From 87fa1b44bf2ae2191c11b4986fe0bf4eb80df0d8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Sat, 30 Sep 2017 07:37:24 +0000 Subject: Merge branch 'sh-fix-gitlab-qa-admin' into 'master' Fix Admin -> License selector for GitLab QA specs Closes gitlab-qa#68 See merge request gitlab-org/gitlab-ce!14599 --- qa/qa/page/admin/menu.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb index b01a4e10f93..f4619042e34 100644 --- a/qa/qa/page/admin/menu.rb +++ b/qa/qa/page/admin/menu.rb @@ -3,15 +3,10 @@ module QA module Admin class Menu < Page::Base def go_to_license - within_middle_menu { click_link 'License' } - end - - private - - def within_middle_menu - page.within('.nav-control') do - yield - end + link = find_link 'License' + # Click space to scroll this link into the view + link.send_keys(:space) + link.click end end end -- cgit v1.2.3 From c6ae33a6f1af27866a5c16061d88d83987746205 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 2 Oct 2017 14:11:25 +0200 Subject: Remove `empty_repo?` from `MEMOIZED_CACHED_METHODS` It's only cached in 10.1 currently. --- app/models/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index a032df89e2d..ca6adef9979 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -36,7 +36,7 @@ class Repository tag_count avatar exists? empty? root_ref has_visible_content?).freeze # Methods that use cache_method but only memoize the value - MEMOIZED_CACHED_METHODS = %i(license empty_repo?).freeze + MEMOIZED_CACHED_METHODS = %i(license).freeze # Certain method caches should be refreshed when certain types of files are # changed. This Hash maps file types (as returned by Gitlab::FileDetector) to -- cgit v1.2.3 From 37d7e762a4cea27c34c14a235b824582f6b98f7b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 2 Oct 2017 17:34:08 +0000 Subject: Merge branch 'sh-fix-import-repos' into 'master' Fix gitlab-rake gitlab:import:repos task Closes #37682 See merge request gitlab-org/gitlab-ce!14597 --- app/models/project.rb | 6 ++++-- changelogs/unreleased/sh-fix-import-repos.yml | 5 +++++ lib/gitlab/bare_repository_importer.rb | 3 ++- spec/models/project_spec.rb | 11 +++++++++++ spec/services/projects/create_service_spec.rb | 9 +++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/sh-fix-import-repos.yml diff --git a/app/models/project.rb b/app/models/project.rb index f7221e4f3b2..9bec7963130 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -72,6 +72,7 @@ class Project < ActiveRecord::Base attr_accessor :old_path_with_namespace attr_accessor :template_name attr_writer :pipeline_status + attr_accessor :skip_disk_validation alias_attribute :title, :name @@ -227,7 +228,7 @@ class Project < ActiveRecord::Base validates :import_url, importable_url: true, if: [:external_import?, :import_url_changed?] validates :star_count, numericality: { greater_than_or_equal_to: 0 } validate :check_limit, on: :create - validate :can_create_repository?, on: [:create, :update], if: ->(project) { !project.persisted? || project.renamed? } + validate :check_repository_path_availability, on: [:create, :update], if: ->(project) { !project.persisted? || project.renamed? } validate :avatar_type, if: ->(project) { project.avatar.present? && project.avatar_changed? } validates :avatar, file_size: { maximum: 200.kilobytes.to_i } @@ -1015,7 +1016,8 @@ class Project < ActiveRecord::Base end # Check if repository already exists on disk - def can_create_repository? + def check_repository_path_availability + return true if skip_disk_validation return false unless repository_storage_path expires_full_path_cache # we need to clear cache to validate renames correctly diff --git a/changelogs/unreleased/sh-fix-import-repos.yml b/changelogs/unreleased/sh-fix-import-repos.yml new file mode 100644 index 00000000000..5764b3bdc01 --- /dev/null +++ b/changelogs/unreleased/sh-fix-import-repos.yml @@ -0,0 +1,5 @@ +--- +title: Fix gitlab-rake gitlab:import:repos task failing +merge_request: +author: +type: fixed diff --git a/lib/gitlab/bare_repository_importer.rb b/lib/gitlab/bare_repository_importer.rb index 9323bfc7fb2..1d98d187805 100644 --- a/lib/gitlab/bare_repository_importer.rb +++ b/lib/gitlab/bare_repository_importer.rb @@ -56,7 +56,8 @@ module Gitlab name: project_path, path: project_path, repository_storage: storage_name, - namespace_id: group&.id + namespace_id: group&.id, + skip_disk_validation: true } project = Projects::CreateService.new(user, project_params).execute diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 78226c6c3fa..ba9254e825e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2717,6 +2717,17 @@ describe Project do end end + describe '#check_repository_path_availability' do + let(:project) { build(:project) } + + it 'skips gitlab-shell exists?' do + project.skip_disk_validation = true + + expect(project.gitlab_shell).not_to receive(:exists?) + expect(project.check_repository_path_availability).to be_truthy + end + end + describe '#latest_successful_pipeline_for_default_branch' do let(:project) { build(:project) } diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 5da634e2fb1..7af7e170046 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -208,6 +208,15 @@ describe Projects::CreateService, '#execute' do end end + context 'when skip_disk_validation is used' do + it 'sets the project attribute' do + opts[:skip_disk_validation] = true + project = create_project(user, opts) + + expect(project.skip_disk_validation).to be_truthy + end + end + def create_project(user, opts) Projects::CreateService.new(user, opts).execute end -- cgit v1.2.3 From 3b9734344f008f42914a946861d84740cb1ed492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Tue, 3 Oct 2017 08:57:12 +0000 Subject: Merge branch 'fix-kubectl-180' into 'master' Fix broken certificate-authority-data with kubectl >= 1.8.0 Closes #38685 See merge request gitlab-org/gitlab-ce!14635 --- changelogs/unreleased/fix-kubectl-180.yml | 5 +++++ lib/gitlab/kubernetes.rb | 2 +- spec/fixtures/config/kubeconfig.yml | 2 +- spec/models/project_services/kubernetes_service_spec.rb | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/fix-kubectl-180.yml diff --git a/changelogs/unreleased/fix-kubectl-180.yml b/changelogs/unreleased/fix-kubectl-180.yml new file mode 100644 index 00000000000..beb71cecd57 --- /dev/null +++ b/changelogs/unreleased/fix-kubectl-180.yml @@ -0,0 +1,5 @@ +--- +title: 'Kubernetes integration: ensure v1.8.0 compatibility' +merge_request: 14635 +author: +type: fixed diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb index cdbdfa10d0e..da43bd0af4b 100644 --- a/lib/gitlab/kubernetes.rb +++ b/lib/gitlab/kubernetes.rb @@ -113,7 +113,7 @@ module Gitlab def kubeconfig_embed_ca_pem(config, ca_pem) cluster = config.dig(:clusters, 0, :cluster) - cluster[:'certificate-authority-data'] = Base64.encode64(ca_pem) + cluster[:'certificate-authority-data'] = Base64.strict_encode64(ca_pem) end end end diff --git a/spec/fixtures/config/kubeconfig.yml b/spec/fixtures/config/kubeconfig.yml index c4e8e573c32..5152dae0104 100644 --- a/spec/fixtures/config/kubeconfig.yml +++ b/spec/fixtures/config/kubeconfig.yml @@ -4,7 +4,7 @@ clusters: - name: gitlab-deploy cluster: server: https://kube.domain.com - certificate-authority-data: "UEVN\n" + certificate-authority-data: "UEVN" contexts: - name: gitlab-deploy context: diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 537cdadd528..2298dcab55f 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -208,7 +208,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do config.dig('users', 0, 'user')['token'] = 'token' config.dig('contexts', 0, 'context')['namespace'] = namespace config.dig('clusters', 0, 'cluster')['certificate-authority-data'] = - Base64.encode64('CA PEM DATA') + Base64.strict_encode64('CA PEM DATA') YAML.dump(config) end -- cgit v1.2.3