From 143ad044addeaf3d3a942cc658e091750ce1c1a7 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Wed, 10 Jan 2018 19:24:24 +0000 Subject: Merge branch '41491-fix-nil-blob-name-error' into 'master' Fix 500 error when visiting a commit where the blobs do not exist (nil blobs) Closes #41491 See merge request gitlab-org/gitlab-ce!16237 --- app/assets/stylesheets/pages/diff.scss | 8 +++++++- app/views/projects/diffs/_file.html.haml | 2 +- app/views/projects/diffs/_stats.html.haml | 7 ++++++- changelogs/unreleased/41491-fix-nil-blob-name-error.yml | 5 +++++ .../projects/commits/user_browses_commits_spec.rb | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/41491-fix-nil-blob-name-error.yml diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss index 1d081b58f62..7f037582ca0 100644 --- a/app/assets/stylesheets/pages/diff.scss +++ b/app/assets/stylesheets/pages/diff.scss @@ -651,12 +651,18 @@ min-width: 0; } - .diff-changed-file-name { + .diff-changed-file-name, + .diff-changed-blank-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .diff-changed-blank-file-name { + color: $gl-text-color-tertiary; + font-style: italic; + } + .diff-changed-file-path { color: $gl-text-color-tertiary; } diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml index adc4dcbed33..0b01e38d23d 100644 --- a/app/views/projects/diffs/_file.html.haml +++ b/app/views/projects/diffs/_file.html.haml @@ -11,7 +11,7 @@ - unless diff_file.submodule? - blob = diff_file.blob .file-actions.hidden-xs - - if blob.readable_text? + - if blob&.readable_text? = link_to '#', class: 'js-toggle-diff-comments btn active has-tooltip', title: "Toggle comments for this file", disabled: @diff_notes_disabled do = icon('comment') \ diff --git a/app/views/projects/diffs/_stats.html.haml b/app/views/projects/diffs/_stats.html.haml index 325159dd9a7..b082ad0ef0e 100644 --- a/app/views/projects/diffs/_stats.html.haml +++ b/app/views/projects/diffs/_stats.html.haml @@ -24,7 +24,12 @@ %a.diff-changed-file{ href: "##{hexdigest(diff_file.file_path)}", title: diff_file.new_path } = sprite_icon(diff_file_changed_icon(diff_file), size: 16, css_class: "#{diff_file_changed_icon_color(diff_file)} diff-file-changed-icon append-right-8") %span.diff-changed-file-content.append-right-8 - %strong.diff-changed-file-name= diff_file.blob.name + - if diff_file.blob&.name + %strong.diff-changed-file-name + = diff_file.blob.name + - else + %strong.diff-changed-blank-file-name + = s_('Diffs|No file name available') %span.diff-changed-file-path.prepend-top-5= diff_file_path_text(diff_file) %span.diff-changed-stats %span.cgreen< diff --git a/changelogs/unreleased/41491-fix-nil-blob-name-error.yml b/changelogs/unreleased/41491-fix-nil-blob-name-error.yml new file mode 100644 index 00000000000..cf7e63ea46a --- /dev/null +++ b/changelogs/unreleased/41491-fix-nil-blob-name-error.yml @@ -0,0 +1,5 @@ +--- +title: Fix 500 error when visiting a commit where the blobs do not exist +merge_request: +author: +type: fixed diff --git a/spec/features/projects/commits/user_browses_commits_spec.rb b/spec/features/projects/commits/user_browses_commits_spec.rb index 41f3c15a94c..b650c1f4197 100644 --- a/spec/features/projects/commits/user_browses_commits_spec.rb +++ b/spec/features/projects/commits/user_browses_commits_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User broweses commits' do +describe 'User browses commits' do let(:user) { create(:user) } let(:project) { create(:project, :repository, namespace: user.namespace) } @@ -31,6 +31,19 @@ describe 'User broweses commits' do check_author_link(RepoHelpers.sample_commit.author_email, user) end end + + context 'when the blob does not exist' do + let(:commit) { create(:commit, project: project) } + + it 'shows a blank label' do + allow_any_instance_of(Gitlab::Diff::File).to receive(:blob).and_return(nil) + allow_any_instance_of(Gitlab::Diff::File).to receive(:raw_binary?).and_return(true) + + visit(project_commit_path(project, commit)) + + expect(find('.diff-file-changes', visible: false)).to have_content('No file name available') + end + end end private -- cgit v1.2.1 From edfddd5a7d0160b7473aa895e91c5a4ee42e865b Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Thu, 11 Jan 2018 17:48:54 +0000 Subject: Merge branch '41607-require-rsync-docs' into 'master' Resolve "Document rsync as requirement for 10.4" Closes #41607 See merge request gitlab-org/gitlab-ce!16252 --- doc/install/installation.md | 2 +- doc/raketasks/backup_restore.md | 21 +++++++++++++++++---- doc/update/10.3-to-10.4.md | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 2b7352d3561..b2acd5e78b5 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -64,7 +64,7 @@ up-to-date and install it. Install the required packages (needed to compile Ruby and native extensions to Ruby gems): - sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libre2-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake + sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libre2-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate rsync python-docutils pkg-config cmake Ubuntu 14.04 (Trusty Tahr) doesn't have the `libre2-dev` package available, but you can [install re2 manually](https://github.com/google/re2/wiki/Install). diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index 54c3e20d61d..50bb665216e 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -5,8 +5,8 @@ An application data backup creates an archive file that contains the database, all repositories and all attachments. -You can only restore a backup to **exactly the same version and type (CE/EE)** -of GitLab on which it was created. The best way to migrate your repositories +You can only restore a backup to **exactly the same version and type (CE/EE)** +of GitLab on which it was created. The best way to migrate your repositories from one server to another is through backup restore. ## Backup @@ -14,6 +14,19 @@ from one server to another is through backup restore. GitLab provides a simple command line interface to backup your whole installation, and is flexible enough to fit your needs. +### Requirements + +If you're using GitLab with the Omnibus package, you're all set. If you +installed GitLab from source, make sure the following packages are installed: + +* rsync + +If you're using Ubuntu, you could run: + +``` +sudo apt-get install -y rsync +``` + ### Backup timestamp >**Note:** @@ -431,7 +444,7 @@ The [restore prerequisites section](#restore-prerequisites) includes crucial information. Make sure to read and test the whole restore process at least once before attempting to perform it in a production environment. -You can only restore a backup to **exactly the same version and type (CE/EE)** of +You can only restore a backup to **exactly the same version and type (CE/EE)** of GitLab that you created it on, for example CE 9.1.0. ### Restore prerequisites @@ -511,7 +524,7 @@ sudo service gitlab restart This procedure assumes that: -- You have installed the **exact same version and type (CE/EE)** of GitLab +- You have installed the **exact same version and type (CE/EE)** of GitLab Omnibus with which the backup was created. - You have run `sudo gitlab-ctl reconfigure` at least once. - GitLab is running. If not, start it using `sudo gitlab-ctl start`. diff --git a/doc/update/10.3-to-10.4.md b/doc/update/10.3-to-10.4.md index 850cb3103f4..67b7e634c94 100644 --- a/doc/update/10.3-to-10.4.md +++ b/doc/update/10.3-to-10.4.md @@ -21,6 +21,8 @@ sudo service gitlab stop ### 2. Backup +NOTE: If you installed GitLab from source, make sure `rsync` is installed. + ```bash cd /home/git/gitlab -- cgit v1.2.1 From d368a2d676f95ceaabb4854198be9d23b6a4f2e1 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 10 Jan 2018 08:20:47 +0000 Subject: Merge branch 'sh-fix-bare-import-hooks' into 'master' Fix hooks not being set up properly for bare import Rake task Closes #41739 See merge request gitlab-org/gitlab-ce!16280 --- app/models/repository.rb | 4 ++++ changelogs/unreleased/sh-fix-bare-import-hooks.yml | 5 +++++ lib/gitlab/bare_repository_import/importer.rb | 1 + .../gitlab/bare_repository_import/importer_spec.rb | 8 ++++++-- spec/models/repository_spec.rb | 22 ++++++++++++++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/sh-fix-bare-import-hooks.yml diff --git a/app/models/repository.rb b/app/models/repository.rb index 9c879e2006b..b36e756c07c 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -103,6 +103,10 @@ class Repository "#<#{self.class.name}:#{@disk_path}>" end + def create_hooks + Gitlab::Git::Repository.create_hooks(path_to_repo, Gitlab.config.gitlab_shell.hooks_path) + end + def commit(ref = 'HEAD') return nil unless exists? return ref if ref.is_a?(::Commit) diff --git a/changelogs/unreleased/sh-fix-bare-import-hooks.yml b/changelogs/unreleased/sh-fix-bare-import-hooks.yml new file mode 100644 index 00000000000..deb6c62f738 --- /dev/null +++ b/changelogs/unreleased/sh-fix-bare-import-hooks.yml @@ -0,0 +1,5 @@ +--- +title: Fix hooks not being set up properly for bare import Rake task +merge_request: +author: +type: fixed diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb index 709a901aa77..884a3de8f62 100644 --- a/lib/gitlab/bare_repository_import/importer.rb +++ b/lib/gitlab/bare_repository_import/importer.rb @@ -63,6 +63,7 @@ module Gitlab log " * Created #{project.name} (#{project_full_path})".color(:green) project.write_repository_config + project.repository.create_hooks ProjectCacheWorker.perform_async(project.id) else diff --git a/spec/lib/gitlab/bare_repository_import/importer_spec.rb b/spec/lib/gitlab/bare_repository_import/importer_spec.rb index b5d86df09d2..f302e412a6e 100644 --- a/spec/lib/gitlab/bare_repository_import/importer_spec.rb +++ b/spec/lib/gitlab/bare_repository_import/importer_spec.rb @@ -74,14 +74,18 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do importer.create_project_if_needed end - it 'creates the Git repo in disk' do + it 'creates the Git repo on disk with the proper symlink for hooks' do create_bare_repository("#{project_path}.git") importer.create_project_if_needed project = Project.find_by_full_path(project_path) + repo_path = File.join(project.repository_storage_path, project.disk_path + '.git') + hook_path = File.join(repo_path, 'hooks') - expect(File).to exist(File.join(project.repository_storage_path, project.disk_path + '.git')) + expect(File).to exist(repo_path) + expect(File.symlink?(hook_path)).to be true + expect(File.readlink(hook_path)).to eq(Gitlab.config.gitlab_shell.hooks_path) end context 'hashed storage enabled' do diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index c0db2c1b386..edd981752d9 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -412,6 +412,28 @@ describe Repository do end end + describe '#create_hooks' do + let(:hook_path) { File.join(repository.path_to_repo, 'hooks') } + + it 'symlinks the global hooks directory' do + repository.create_hooks + + expect(File.symlink?(hook_path)).to be true + expect(File.readlink(hook_path)).to eq(Gitlab.config.gitlab_shell.hooks_path) + end + + it 'replaces existing symlink with the right directory' do + FileUtils.mkdir_p(hook_path) + + expect(File.symlink?(hook_path)).to be false + + repository.create_hooks + + expect(File.symlink?(hook_path)).to be true + expect(File.readlink(hook_path)).to eq(Gitlab.config.gitlab_shell.hooks_path) + end + end + describe "#create_dir" do it "commits a change that creates a new directory" do expect do -- cgit v1.2.1 From 2fa478710d44fb06ff76454bcc8690a3aea6865f Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Thu, 11 Jan 2018 08:25:20 +0000 Subject: Merge branch '41789-fix-up-web-ide-user-preference-copy-and-buttons' into 'master' Fix up Web IDE user preference copy and buttons Closes #41789 See merge request gitlab-org/gitlab-ce!16298 --- app/assets/images/multi-editor-on.png | Bin 5464 -> 3971 bytes app/helpers/blob_helper.rb | 2 +- app/views/layouts/header/_default.html.haml | 2 -- app/views/profiles/preferences/show.html.haml | 4 ++-- ...ix-up-web-ide-user-preference-copy-and-buttons.yml | 5 +++++ spec/features/projects/tree/create_directory_spec.rb | 2 +- spec/features/projects/tree/create_file_spec.rb | 2 +- spec/features/projects/tree/upload_file_spec.rb | 2 +- 8 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/41789-fix-up-web-ide-user-preference-copy-and-buttons.yml diff --git a/app/assets/images/multi-editor-on.png b/app/assets/images/multi-editor-on.png index 2bcd29abf13..d51b68da985 100644 Binary files a/app/assets/images/multi-editor-on.png and b/app/assets/images/multi-editor-on.png differ diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index f9dcb32f7c4..5e3b2e5581c 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -46,7 +46,7 @@ module BlobHelper end def ide_edit_text - "#{_('Multi Edit')} #{_('Beta')}".html_safe + "#{_('Web IDE')}" end def ide_blob_link(project = @project, ref = @ref, path = @path, options = {}) diff --git a/app/views/layouts/header/_default.html.haml b/app/views/layouts/header/_default.html.haml index 39eb71c2bac..99e7f3b568d 100644 --- a/app/views/layouts/header/_default.html.haml +++ b/app/views/layouts/header/_default.html.haml @@ -56,8 +56,6 @@ = link_to "Profile", current_user, class: 'profile-link', data: { user: current_user.username } %li = link_to "Settings", profile_path - %li - = link_to "Turn on multi edit", profile_preferences_path - if current_user %li = link_to "Help", help_path diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 65328791ce5..aeae7455a1c 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -5,8 +5,8 @@ = form_for @user, url: profile_preferences_path, remote: true, method: :put, html: { class: 'row prepend-top-default js-preferences-form' } do |f| .col-lg-4 %h4.prepend-top-0 - GitLab multi file editor - %p Unlock an additional editing experience which makes it possible to edit and commit multiple files + Web IDE (Beta) + %p Enable the new web IDE on this device to make it possible to open and edit multiple files with a single commit .col-lg-8.multi-file-editor-options = label_tag do .preview.append-bottom-10= image_tag "multi-editor-off.png" diff --git a/changelogs/unreleased/41789-fix-up-web-ide-user-preference-copy-and-buttons.yml b/changelogs/unreleased/41789-fix-up-web-ide-user-preference-copy-and-buttons.yml new file mode 100644 index 00000000000..fe87cd5cadb --- /dev/null +++ b/changelogs/unreleased/41789-fix-up-web-ide-user-preference-copy-and-buttons.yml @@ -0,0 +1,5 @@ +--- +title: Fix web ide user preferences copy and buttons +merge_request: 41789 +author: +type: other diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb index 3f6d16c8acf..0c67196f53e 100644 --- a/spec/features/projects/tree/create_directory_spec.rb +++ b/spec/features/projects/tree/create_directory_spec.rb @@ -14,7 +14,7 @@ feature 'Multi-file editor new directory', :js do wait_for_requests - click_link('Multi Edit') + click_link('Web IDE') wait_for_requests end diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb index ba71eef07f4..85f7318c05d 100644 --- a/spec/features/projects/tree/create_file_spec.rb +++ b/spec/features/projects/tree/create_file_spec.rb @@ -14,7 +14,7 @@ feature 'Multi-file editor new file', :js do wait_for_requests - click_link('Multi Edit') + click_link('Web IDE') wait_for_requests end diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb index 9fbb1dbd0e8..f81e8677e92 100644 --- a/spec/features/projects/tree/upload_file_spec.rb +++ b/spec/features/projects/tree/upload_file_spec.rb @@ -16,7 +16,7 @@ feature 'Multi-file editor upload file', :js do wait_for_requests - click_link('Multi Edit') + click_link('Web IDE') wait_for_requests end -- cgit v1.2.1 From 81e1cb0d994f9efcac1abed51dc5475bd97c1a1f Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Wed, 10 Jan 2018 08:00:48 +0000 Subject: Merge branch 'dz-improve-code-quality-docs' into 'master' Use 0.69 version of codeclimate image for CI code quality docs See merge request gitlab-org/gitlab-ce!16319 --- doc/ci/examples/code_climate.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ci/examples/code_climate.md b/doc/ci/examples/code_climate.md index 6a5821762cc..f919ed3c797 100644 --- a/doc/ci/examples/code_climate.md +++ b/doc/ci/examples/code_climate.md @@ -16,7 +16,8 @@ codequality: - docker:dind script: - docker pull codeclimate/codeclimate - - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json || true + - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate:0.69.0 init + - docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate:0.69.0 analyze -f json > codeclimate.json || true artifacts: paths: [codeclimate.json] ``` -- cgit v1.2.1 From 39924b113734f178986e7c63c94d741a712a2174 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 10 Jan 2018 08:47:18 +0000 Subject: Merge branch 'fix/sidebar-collapse-button-spacing' into 'master' Restore sidebar collapse button padding #41803 See merge request gitlab-org/gitlab-ce!16323 --- app/assets/stylesheets/pages/issuable.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index e1637618ab2..ae9a8b0182c 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -303,7 +303,6 @@ .gutter-toggle { margin-top: 7px; border-left: 1px solid $border-gray-normal; - padding-left: 0; text-align: center; } -- cgit v1.2.1 From 1606a6b834fbfa18e55a97a099fa0199961c7ffd Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 10 Jan 2018 15:51:52 +0000 Subject: Merge branch 'merge-request-lfs-badge' into 'master' Added LFS badge to merge request files tracked by LFS Closes #41829 See merge request gitlab-org/gitlab-ce!16345 --- app/views/projects/diffs/_file_header.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/projects/diffs/_file_header.html.haml b/app/views/projects/diffs/_file_header.html.haml index 73c316472e3..dbeddf6689a 100644 --- a/app/views/projects/diffs/_file_header.html.haml +++ b/app/views/projects/diffs/_file_header.html.haml @@ -35,3 +35,6 @@ - if diff_file.mode_changed? %small #{diff_file.a_mode} → #{diff_file.b_mode} + + - if diff_file.stored_externally? && diff_file.external_storage == :lfs + %span.label.label-lfs.append-right-5 LFS -- cgit v1.2.1 From 1ce24f93fc52437ca072052ed89b4a923f16e172 Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Wed, 10 Jan 2018 13:39:45 +0000 Subject: Merge branch 'remove-beta-notice-for-clusters' into 'master' Remove Beta notice for Clusters See merge request gitlab-org/gitlab-ce!16350 --- doc/user/project/clusters/index.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/user/project/clusters/index.md b/doc/user/project/clusters/index.md index 218b9dee41d..130f7897b1a 100644 --- a/doc/user/project/clusters/index.md +++ b/doc/user/project/clusters/index.md @@ -2,9 +2,6 @@ > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/35954) in 10.1. -CAUTION: **Warning:** -The Cluster integration is currently in **Beta**. - With a cluster associated to your project, you can use Review Apps, deploy your applications, run your pipelines, and much more, in an easy way. -- cgit v1.2.1 From da5efa5b83d2cb35a347df54e9433a1558b410ca Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 12 Jan 2018 08:14:31 +0000 Subject: Merge branch '41882-respect-only-path-in-relative-link-filter' into 'master' Resolve "Attachments in e-mail notifications are using the wrong URL" Closes #41882 See merge request gitlab-org/gitlab-ce!16364 --- ...2-respect-only-path-in-relative-link-filter.yml | 5 +++ lib/banzai/filter/relative_link_filter.rb | 15 +++++-- .../lib/banzai/filter/relative_link_filter_spec.rb | 48 ++++++++++++++++------ 3 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 changelogs/unreleased/41882-respect-only-path-in-relative-link-filter.yml diff --git a/changelogs/unreleased/41882-respect-only-path-in-relative-link-filter.yml b/changelogs/unreleased/41882-respect-only-path-in-relative-link-filter.yml new file mode 100644 index 00000000000..d4b7ec6a3b5 --- /dev/null +++ b/changelogs/unreleased/41882-respect-only-path-in-relative-link-filter.yml @@ -0,0 +1,5 @@ +--- +title: Ensure that emails contain absolute, rather than relative, links to user uploads +merge_request: 16364 +author: +type: fixed diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 5c197afd782..f6169b2c85d 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -50,15 +50,22 @@ module Banzai end def process_link_to_upload_attr(html_attr) - uri_parts = [html_attr.value] + path_parts = [html_attr.value] if group - uri_parts.unshift(relative_url_root, 'groups', group.full_path, '-') + path_parts.unshift(relative_url_root, 'groups', group.full_path, '-') elsif project - uri_parts.unshift(relative_url_root, project.full_path) + path_parts.unshift(relative_url_root, project.full_path) end - html_attr.value = File.join(*uri_parts) + path = File.join(*path_parts) + + html_attr.value = + if context[:only_path] + path + else + URI.join(Gitlab.config.gitlab.base_url, path).to_s + end end def process_link_to_repository_attr(html_attr) diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index f38f0776303..7e17457ce70 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -8,7 +8,8 @@ describe Banzai::Filter::RelativeLinkFilter do group: group, project_wiki: project_wiki, ref: ref, - requested_path: requested_path + requested_path: requested_path, + only_path: only_path }) described_class.call(doc, contexts) @@ -37,6 +38,7 @@ describe Banzai::Filter::RelativeLinkFilter do let(:commit) { project.commit(ref) } let(:project_wiki) { nil } let(:requested_path) { '/' } + let(:only_path) { true } shared_examples :preserve_unchanged do it 'does not modify any relative URL in anchor' do @@ -240,26 +242,35 @@ describe Banzai::Filter::RelativeLinkFilter do let(:commit) { nil } let(:ref) { nil } let(:requested_path) { nil } + let(:upload_path) { '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg' } + let(:relative_path) { "/#{project.full_path}#{upload_path}" } context 'to a project upload' do + context 'with an absolute URL' do + let(:absolute_path) { Gitlab.config.gitlab.url + relative_path } + let(:only_path) { false } + + it 'rewrites the link correctly' do + doc = filter(link(upload_path)) + + expect(doc.at_css('a')['href']).to eq(absolute_path) + end + end + it 'rebuilds relative URL for a link' do - doc = filter(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('a')['href']) - .to eq "/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + doc = filter(link(upload_path)) + expect(doc.at_css('a')['href']).to eq(relative_path) - doc = filter(nested(link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))) - expect(doc.at_css('a')['href']) - .to eq "/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + doc = filter(nested(link(upload_path))) + expect(doc.at_css('a')['href']).to eq(relative_path) end it 'rebuilds relative URL for an image' do - doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')) - expect(doc.at_css('img')['src']) - .to eq "/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + doc = filter(image(upload_path)) + expect(doc.at_css('img')['src']).to eq(relative_path) - doc = filter(nested(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))) - expect(doc.at_css('img')['src']) - .to eq "/#{project.full_path}/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" + doc = filter(nested(image(upload_path))) + expect(doc.at_css('img')['src']).to eq(relative_path) end it 'does not modify absolute URL' do @@ -288,6 +299,17 @@ describe Banzai::Filter::RelativeLinkFilter do let(:project) { nil } let(:relative_path) { "/groups/#{group.full_path}/-/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" } + context 'with an absolute URL' do + let(:absolute_path) { Gitlab.config.gitlab.url + relative_path } + let(:only_path) { false } + + it 'rewrites the link correctly' do + doc = filter(upload_link) + + expect(doc.at_css('a')['href']).to eq(absolute_path) + end + end + it 'rewrites the link correctly' do doc = filter(upload_link) -- cgit v1.2.1 From 72e905d425b1dada108d4d018a4bc1f79ec8b28a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 11 Jan 2018 12:03:33 +0000 Subject: Merge branch 'Ben305/gitlab-ce-36669-default-mr-title-with-external-issues' into 'master' Resolve "Incorrect default merge request title when Jira activated" Closes #36669 See merge request gitlab-org/gitlab-ce!16356 --- app/services/merge_requests/build_service.rb | 8 ++----- ...36669-default-mr-title-with-external-issues.yml | 5 +++++ spec/services/merge_requests/build_service_spec.rb | 26 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/36669-default-mr-title-with-external-issues.yml diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index 9622a5c5462..22b9b91a957 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -154,13 +154,9 @@ module MergeRequests end def assign_title_from_issue - return unless issue + return unless issue && issue.is_a?(Issue) - merge_request.title = - case issue - when Issue then "Resolve \"#{issue.title}\"" - when ExternalIssue then "Resolve #{issue.title}" - end + merge_request.title = "Resolve \"#{issue.title}\"" end def issue_iid diff --git a/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml b/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml new file mode 100644 index 00000000000..6af9ac4b099 --- /dev/null +++ b/changelogs/unreleased/36669-default-mr-title-with-external-issues.yml @@ -0,0 +1,5 @@ +--- +title: Default merge request title is set correctly again when external issue tracker is activated +merge_request: 16356 +author: Ben305 +type: fixed diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index a9605c6e4c6..cb4c3e72aa0 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -171,6 +171,24 @@ describe MergeRequests::BuildService do end end end + + context 'branch starts with external issue IID followed by a hyphen' do + let(:source_branch) { '12345-fix-issue' } + + before do + allow(project).to receive(:external_issue_tracker).and_return(true) + end + + it 'uses the title of the commit as the title of the merge request' do + expect(merge_request.title).to eq(commit_1.safe_message.split("\n").first) + end + + it 'uses the description of the commit as the description of the merge request and appends the closes text' do + commit_description = commit_1.safe_message.split(/\n+/, 2).last + + expect(merge_request.description).to eq("#{commit_description}\n\nCloses #12345") + end + end end context 'more than one commit in the diff' do @@ -241,8 +259,12 @@ describe MergeRequests::BuildService do allow(project).to receive(:external_issue_tracker).and_return(true) end - it 'sets the title to: Resolves External Issue $issue-iid' do - expect(merge_request.title).to eq('Resolve External Issue 12345') + it 'sets the title to the humanized branch title' do + expect(merge_request.title).to eq('12345 fix issue') + end + + it 'appends the closes text' do + expect(merge_request.description).to eq('Closes #12345') end end end -- cgit v1.2.1 From a718f3e70211ddfe17193d4430b85629ba69fcc6 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 12 Jan 2018 14:03:04 +0000 Subject: Merge branch 'disable-pages-on-jobs' into 'master' Use simple Next/Prev paging for CI Jobs page Closes #41058 See merge request gitlab-org/gitlab-ce!16392 --- app/controllers/projects/jobs_controller.rb | 2 +- app/views/projects/jobs/_table.html.haml | 2 +- changelogs/unreleased/disable-pages-on-jobs.yml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/disable-pages-on-jobs.yml diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 4865ec3dfe5..8b54ba3ad7c 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -29,7 +29,7 @@ class Projects::JobsController < Projects::ApplicationController :project, :tags ]) - @builds = @builds.page(params[:page]).per(30) + @builds = @builds.page(params[:page]).per(30).without_count end def cancel_all diff --git a/app/views/projects/jobs/_table.html.haml b/app/views/projects/jobs/_table.html.haml index 82806f022ee..d124d3ebfc1 100644 --- a/app/views/projects/jobs/_table.html.haml +++ b/app/views/projects/jobs/_table.html.haml @@ -22,4 +22,4 @@ = render partial: "projects/ci/builds/build", collection: builds, as: :build, locals: { commit_sha: true, ref: true, pipeline_link: true, stage: true, allow_retry: true, admin: admin } - = paginate builds, theme: 'gitlab' + = paginate_collection(builds) diff --git a/changelogs/unreleased/disable-pages-on-jobs.yml b/changelogs/unreleased/disable-pages-on-jobs.yml new file mode 100644 index 00000000000..629768efce1 --- /dev/null +++ b/changelogs/unreleased/disable-pages-on-jobs.yml @@ -0,0 +1,6 @@ +--- +title: Use simple Next/Prev paging for jobs to avoid large count queries on arbitrarily + large sets of historical jobs +merge_request: +author: +type: performance -- cgit v1.2.1 From 175052faa2daec94f83cb90bb79e7731a6c437dd Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Fri, 12 Jan 2018 14:42:12 +0000 Subject: Merge branch 'projects-dropdown-perf' into 'master' Fixed performance of projects dropdown Closes #41939 See merge request gitlab-org/gitlab-ce!16425 --- app/assets/javascripts/projects_dropdown/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/projects_dropdown/index.js b/app/assets/javascripts/projects_dropdown/index.js index 2660da3c558..e78ebce2923 100644 --- a/app/assets/javascripts/projects_dropdown/index.js +++ b/app/assets/javascripts/projects_dropdown/index.js @@ -19,11 +19,8 @@ document.addEventListener('DOMContentLoaded', () => { return; } - $(navEl).on('show.bs.dropdown', (e) => { - const dropdownEl = $(e.currentTarget).find('.projects-dropdown-menu'); - dropdownEl.one('transitionend', () => { - eventHub.$emit('dropdownOpen'); - }); + $(navEl).on('shown.bs.dropdown', () => { + eventHub.$emit('dropdownOpen'); }); // eslint-disable-next-line no-new -- cgit v1.2.1 From c2d5d3f8fb57f8de352c30038b09f77071febe3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 15 Jan 2018 13:10:51 +0000 Subject: Merge branch '41970-job-play-button' into 'master' Resolve "Empty state for manual job - play button does not work" Closes #41970 See merge request gitlab-org/gitlab-ce!16426 --- app/views/projects/jobs/_empty_state.html.haml | 5 +++-- app/views/projects/jobs/show.html.haml | 7 +++---- spec/features/projects/jobs_spec.rb | 14 +++++++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/views/projects/jobs/_empty_state.html.haml b/app/views/projects/jobs/_empty_state.html.haml index c66313bdbf3..311934d9c33 100644 --- a/app/views/projects/jobs/_empty_state.html.haml +++ b/app/views/projects/jobs/_empty_state.html.haml @@ -1,7 +1,7 @@ - illustration = local_assigns.fetch(:illustration) - illustration_size = local_assigns.fetch(:illustration_size) - title = local_assigns.fetch(:title) -- content = local_assigns.fetch(:content) +- content = local_assigns.fetch(:content, nil) - action = local_assigns.fetch(:action, nil) .row.empty-state @@ -11,7 +11,8 @@ .col-xs-12 .text-content %h4.text-center= title - %p= content + - if content + %p= content - if action .text-center = action diff --git a/app/views/projects/jobs/show.html.haml b/app/views/projects/jobs/show.html.haml index 8b05440fc78..1e6d6f67e66 100644 --- a/app/views/projects/jobs/show.html.haml +++ b/app/views/projects/jobs/show.html.haml @@ -93,14 +93,13 @@ illustration: 'illustrations/manual_action.svg', illustration_size: 'svg-394', title: _('This job requires a manual action'), - content: _('This job depends on a user to trigger its process. Often they are used to deploy code to production environments.'), - action: ( link_to _('Trigger this manual action'), play_project_job_path(@project, @build), class: 'btn btn-primary', title: _('Trigger this manual action') ) + content: _('This job depends on a user to trigger its process. Often they are used to deploy code to production environments'), + action: ( link_to _('Trigger this manual action'), play_project_job_path(@project, @build), method: :post, class: 'btn btn-primary', title: _('Trigger this manual action') ) - else = render 'empty_state', illustration: 'illustrations/job_not_triggered.svg', illustration_size: 'svg-306', - title: _('This job has not been triggered yet'), - content: _('This job depends on upstream jobs that need to succeed in order for this job to be triggered.') + title: _('This job has not been triggered yet') = render "sidebar" diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 9a6b27c00f8..a5cd858b11a 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -380,9 +380,18 @@ feature 'Jobs' do it 'shows manual action empty state' do expect(page).to have_content('This job requires a manual action') - expect(page).to have_content('This job depends on a user to trigger its process. Often they are used to deploy code to production environments.') + expect(page).to have_content('This job depends on a user to trigger its process. Often they are used to deploy code to production environments') expect(page).to have_link('Trigger this manual action') end + + it 'plays manual action', :js do + click_link 'Trigger this manual action' + + wait_for_requests + expect(page).to have_content('This job has not been triggered') + expect(page).to have_content('This job is stuck, because the project doesn\'t have any runners online assigned to it.') + expect(page).to have_content('pending') + end end context 'Non triggered job' do @@ -392,9 +401,8 @@ feature 'Jobs' do visit project_job_path(project, job) end - it 'shows manual action empty state' do + it 'shows empty state' do expect(page).to have_content('This job has not been triggered yet') - expect(page).to have_content('This job depends on upstream jobs that need to succeed in order for this job to be triggered.') end end end -- cgit v1.2.1 From 8ac23312b5d57b5530f0f8747b9bdd5e84ca8d5b Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 15 Jan 2018 09:10:52 +0000 Subject: Merge branch 'fj-41598-fixing-request-mime-type' into 'master' Fixing request json mime type Closes #41598 See merge request gitlab-org/gitlab-ce!16427 --- changelogs/unreleased/fj-41598-fixing-request-mime-type.yml | 5 +++++ lib/gitlab/auth/user_auth_finders.rb | 4 +--- spec/lib/gitlab/auth/user_auth_finders_spec.rb | 10 ++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/fj-41598-fixing-request-mime-type.yml diff --git a/changelogs/unreleased/fj-41598-fixing-request-mime-type.yml b/changelogs/unreleased/fj-41598-fixing-request-mime-type.yml new file mode 100644 index 00000000000..85e4d78b2df --- /dev/null +++ b/changelogs/unreleased/fj-41598-fixing-request-mime-type.yml @@ -0,0 +1,5 @@ +--- +title: Fixing rack request mime type when using rack attack +merge_request: 16427 +author: +type: fixed diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb index b4114a3ac96..cf02030c577 100644 --- a/lib/gitlab/auth/user_auth_finders.rb +++ b/lib/gitlab/auth/user_auth_finders.rb @@ -96,9 +96,7 @@ module Gitlab end def ensure_action_dispatch_request(request) - return request if request.is_a?(ActionDispatch::Request) - - ActionDispatch::Request.new(request.env) + ActionDispatch::Request.new(request.env.dup) end def current_request diff --git a/spec/lib/gitlab/auth/user_auth_finders_spec.rb b/spec/lib/gitlab/auth/user_auth_finders_spec.rb index 4637816570c..2733eef6611 100644 --- a/spec/lib/gitlab/auth/user_auth_finders_spec.rb +++ b/spec/lib/gitlab/auth/user_auth_finders_spec.rb @@ -76,6 +76,16 @@ describe Gitlab::Auth::UserAuthFinders do expect(find_user_from_rss_token).to be_nil end end + + context 'when the request format is empty' do + it 'the method call does not modify the original value' do + env['action_dispatch.request.formats'] = nil + + find_user_from_rss_token + + expect(env['action_dispatch.request.formats']).to be_nil + end + end end describe '#find_user_from_access_token' do -- cgit v1.2.1 From f57dac49b5123199eda449e292eb9370dce003da Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 12 Jan 2018 13:10:49 +0000 Subject: Merge branch '41937-vue-prop-type' into 'master' Resolve "Fix type is started key" Closes #41937 See merge request gitlab-org/gitlab-ce!16407 --- app/assets/javascripts/jobs/components/header.vue | 6 +++- spec/javascripts/jobs/header_spec.js | 34 +++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/jobs/components/header.vue b/app/assets/javascripts/jobs/components/header.vue index c660828b30e..a17514231b5 100644 --- a/app/assets/javascripts/jobs/components/header.vue +++ b/app/assets/javascripts/jobs/components/header.vue @@ -30,8 +30,12 @@ shouldRenderContent() { return !this.isLoading && Object.keys(this.job).length; }, + /** + * When job has not started the key will be `false` + * When job started the key will be a string with a date. + */ jobStarted() { - return this.job.started; + return !this.job.started === false; }, }, methods: { diff --git a/spec/javascripts/jobs/header_spec.js b/spec/javascripts/jobs/header_spec.js index 83395ea451e..a9df0418d5d 100644 --- a/spec/javascripts/jobs/header_spec.js +++ b/spec/javascripts/jobs/header_spec.js @@ -31,6 +31,7 @@ describe('Job details header', () => { email: 'foo@bar.com', avatar_url: 'link', }, + started: '2018-01-08T09:48:27.319Z', new_issue_path: 'path', }, isLoading: false, @@ -43,15 +44,32 @@ describe('Job details header', () => { vm.$destroy(); }); - it('should render provided job information', () => { - expect( - vm.$el.querySelector('.header-main-content').textContent.replace(/\s+/g, ' ').trim(), - ).toEqual('failed Job #123 triggered 3 weeks ago by Foo'); + describe('triggered job', () => { + beforeEach(() => { + vm = mountComponent(HeaderComponent, props); + }); + + it('should render provided job information', () => { + expect( + vm.$el.querySelector('.header-main-content').textContent.replace(/\s+/g, ' ').trim(), + ).toEqual('failed Job #123 triggered 3 weeks ago by Foo'); + }); + + it('should render new issue link', () => { + expect( + vm.$el.querySelector('.js-new-issue').getAttribute('href'), + ).toEqual(props.job.new_issue_path); + }); }); - it('should render new issue link', () => { - expect( - vm.$el.querySelector('.js-new-issue').getAttribute('href'), - ).toEqual(props.job.new_issue_path); + describe('created job', () => { + it('should render created key', () => { + props.job.started = false; + vm = mountComponent(HeaderComponent, props); + + expect( + vm.$el.querySelector('.header-main-content').textContent.replace(/\s+/g, ' ').trim(), + ).toEqual('failed Job #123 created 3 weeks ago by Foo'); + }); }); }); -- cgit v1.2.1 From 09b07d8420e1102ac3fcfef1395f70439dcc6c76 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Mon, 15 Jan 2018 13:11:22 +0000 Subject: Merge branch '42025-fix-issue-api' into 'master' [API] Fix creating issue when assignee_id is empty See merge request gitlab-org/gitlab-ce!16458 --- changelogs/unreleased/42025-fix-issue-api.yml | 5 +++++ lib/api/helpers/common_helpers.rb | 6 ++++-- spec/requests/api/issues_spec.rb | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/42025-fix-issue-api.yml diff --git a/changelogs/unreleased/42025-fix-issue-api.yml b/changelogs/unreleased/42025-fix-issue-api.yml new file mode 100644 index 00000000000..abb83bb2fad --- /dev/null +++ b/changelogs/unreleased/42025-fix-issue-api.yml @@ -0,0 +1,5 @@ +--- +title: "[API] Fix creating issue when assignee_id is empty" +merge_request: +author: +type: fixed diff --git a/lib/api/helpers/common_helpers.rb b/lib/api/helpers/common_helpers.rb index 322624c6092..9993caa5249 100644 --- a/lib/api/helpers/common_helpers.rb +++ b/lib/api/helpers/common_helpers.rb @@ -3,8 +3,10 @@ module API module CommonHelpers def convert_parameters_from_legacy_format(params) params.tap do |params| - if params[:assignee_id].present? - params[:assignee_ids] = [params.delete(:assignee_id)] + assignee_id = params.delete(:assignee_id) + + if assignee_id.present? + params[:assignee_ids] = [assignee_id] end end end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 320217f2032..43218755f4f 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -847,6 +847,15 @@ describe API::Issues, :mailer do expect(json_response['assignee']['name']).to eq(user2.name) expect(json_response['assignees'].first['name']).to eq(user2.name) end + + it 'creates a new project issue when assignee_id is empty' do + post api("/projects/#{project.id}/issues", user), + title: 'new issue', assignee_id: '' + + expect(response).to have_gitlab_http_status(201) + expect(json_response['title']).to eq('new issue') + expect(json_response['assignee']).to be_nil + end end context 'single assignee restrictions' do -- cgit v1.2.1