From 56d3922c4add413d777ef65af7b7923b2aaa0d4c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 12 Sep 2017 12:27:09 +0000 Subject: Merge branch 'detect-orphaned-repositories' into 'master' Detect orphaned repositories See merge request !14204 --- .../unreleased/detect-orphaned-repositories.yml | 5 ++ lib/system_check/orphans/namespace_check.rb | 54 +++++++++++++++++ lib/system_check/orphans/repository_check.rb | 68 ++++++++++++++++++++++ lib/tasks/gitlab/check.rake | 29 +++++++++ .../system_check/orphans/namespace_check_spec.rb | 61 +++++++++++++++++++ .../system_check/orphans/repository_check_spec.rb | 68 ++++++++++++++++++++++ 6 files changed, 285 insertions(+) create mode 100644 changelogs/unreleased/detect-orphaned-repositories.yml create mode 100644 lib/system_check/orphans/namespace_check.rb create mode 100644 lib/system_check/orphans/repository_check.rb create mode 100644 spec/lib/system_check/orphans/namespace_check_spec.rb create mode 100644 spec/lib/system_check/orphans/repository_check_spec.rb diff --git a/changelogs/unreleased/detect-orphaned-repositories.yml b/changelogs/unreleased/detect-orphaned-repositories.yml new file mode 100644 index 00000000000..101c1897826 --- /dev/null +++ b/changelogs/unreleased/detect-orphaned-repositories.yml @@ -0,0 +1,5 @@ +--- +title: Scripts to detect orphaned repositories +merge_request: 14204 +author: +type: added diff --git a/lib/system_check/orphans/namespace_check.rb b/lib/system_check/orphans/namespace_check.rb new file mode 100644 index 00000000000..b8446300f72 --- /dev/null +++ b/lib/system_check/orphans/namespace_check.rb @@ -0,0 +1,54 @@ +module SystemCheck + module Orphans + class NamespaceCheck < SystemCheck::BaseCheck + set_name 'Orphaned namespaces:' + + def multi_check + Gitlab.config.repositories.storages.each do |storage_name, repository_storage| + $stdout.puts + $stdout.puts "* Storage: #{storage_name} (#{repository_storage['path']})".color(:yellow) + toplevel_namespace_dirs = disk_namespaces(repository_storage['path']) + + orphans = (toplevel_namespace_dirs - existing_namespaces) + print_orphans(orphans, storage_name) + end + + clear_namespaces! # releases memory when check finishes + end + + private + + def print_orphans(orphans, storage_name) + if orphans.empty? + $stdout.puts "* No orphaned namespaces for #{storage_name} storage".color(:green) + return + end + + orphans.each do |orphan| + $stdout.puts " - #{orphan}".color(:red) + end + end + + def disk_namespaces(storage_path) + fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result| + namespace = File.basename(namespace_path) + next if namespace.eql?('@hashed') + + result << namespace + end + end + + def fetch_disk_namespaces(storage_path) + Dir.glob(File.join(storage_path, '*')) + end + + def existing_namespaces + @namespaces ||= Namespace.where(parent: nil).all.pluck(:path) + end + + def clear_namespaces! + @namespaces = nil + end + end + end +end diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb new file mode 100644 index 00000000000..9b6b2429783 --- /dev/null +++ b/lib/system_check/orphans/repository_check.rb @@ -0,0 +1,68 @@ +module SystemCheck + module Orphans + class RepositoryCheck < SystemCheck::BaseCheck + set_name 'Orphaned repositories:' + attr_accessor :orphans + + def multi_check + Gitlab.config.repositories.storages.each do |storage_name, repository_storage| + $stdout.puts + $stdout.puts "* Storage: #{storage_name} (#{repository_storage['path']})".color(:yellow) + + repositories = disk_repositories(repository_storage['path']) + orphans = (repositories - fetch_repositories(storage_name)) + + print_orphans(orphans, storage_name) + end + end + + private + + def print_orphans(orphans, storage_name) + if orphans.empty? + $stdout.puts "* No orphaned repositories for #{storage_name} storage".color(:green) + return + end + + orphans.each do |orphan| + $stdout.puts " - #{orphan}".color(:red) + end + end + + def disk_repositories(storage_path) + fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result| + namespace = File.basename(namespace_path) + next if namespace.eql?('@hashed') + + fetch_disk_repositories(namespace_path).each do |repo| + result << "#{namespace}/#{File.basename(repo)}" + end + end + end + + def fetch_repositories(storage_name) + sql = " + SELECT + CONCAT(n.path, '/', p.path, '.git') repo, + CONCAT(n.path, '/', p.path, '.wiki.git') wiki + FROM projects p + JOIN namespaces n + ON (p.namespace_id = n.id AND + n.parent_id IS NULL) + WHERE (p.repository_storage LIKE ?) + " + + query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, storage_name]) # rubocop:disable GitlabSecurity/PublicSend + ActiveRecord::Base.connection.select_all(query).rows.try(:flatten!) || [] + end + + def fetch_disk_namespaces(storage_path) + Dir.glob(File.join(storage_path, '*')) + end + + def fetch_disk_repositories(namespace_path) + Dir.glob(File.join(namespace_path, '*')) + end + end + end +end diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 654f638c454..dfade1f3885 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -398,6 +398,35 @@ namespace :gitlab do end end + namespace :orphans do + desc 'Gitlab | Check for orphaned namespaces and repositories' + task check: :environment do + warn_user_is_not_gitlab + checks = [ + SystemCheck::Orphans::NamespaceCheck, + SystemCheck::Orphans::RepositoryCheck + ] + + SystemCheck.run('Orphans', checks) + end + + desc 'GitLab | Check for orphaned namespaces in the repositories path' + task check_namespaces: :environment do + warn_user_is_not_gitlab + checks = [SystemCheck::Orphans::NamespaceCheck] + + SystemCheck.run('Orphans', checks) + end + + desc 'GitLab | Check for orphaned repositories in the repositories path' + task check_repositories: :environment do + warn_user_is_not_gitlab + checks = [SystemCheck::Orphans::RepositoryCheck] + + SystemCheck.run('Orphans', checks) + end + end + namespace :user do desc "GitLab | Check the integrity of a specific user's repositories" task :check_repos, [:username] => :environment do |t, args| diff --git a/spec/lib/system_check/orphans/namespace_check_spec.rb b/spec/lib/system_check/orphans/namespace_check_spec.rb new file mode 100644 index 00000000000..2a61ff3ad65 --- /dev/null +++ b/spec/lib/system_check/orphans/namespace_check_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' +require 'rake_helper' + +describe SystemCheck::Orphans::NamespaceCheck do + let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } } + + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + allow(subject).to receive(:fetch_disk_namespaces).and_return(disk_namespaces) + silence_output + end + + describe '#multi_check' do + context 'all orphans' do + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } + + it 'prints list of all orphaned namespaces except @hashed' do + expect_list_of_orphans(%w(orphan1 orphan2)) + + subject.multi_check + end + end + + context 'few orphans with existing namespace' do + let!(:first_level) { create(:group, path: 'my-namespace') } + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } + + it 'prints list of orphaned namespaces' do + expect_list_of_orphans(%w(orphan1 orphan2)) + + subject.multi_check + end + end + + context 'few orphans with existing namespace and parents with same name as orphans' do + let!(:first_level) { create(:group, path: 'my-namespace') } + let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } + + it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do + expect_list_of_orphans(%w(orphan1 orphan2 second-level)) + + subject.multi_check + end + end + + context 'no orphans' do + let(:disk_namespaces) { %w(@hashed) } + + it 'prints an empty list ignoring @hashed' do + expect_list_of_orphans([]) + + subject.multi_check + end + end + end + + def expect_list_of_orphans(orphans) + expect(subject).to receive(:print_orphans).with(orphans, 'default') + end +end diff --git a/spec/lib/system_check/orphans/repository_check_spec.rb b/spec/lib/system_check/orphans/repository_check_spec.rb new file mode 100644 index 00000000000..b0c2267d177 --- /dev/null +++ b/spec/lib/system_check/orphans/repository_check_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' +require 'rake_helper' + +describe SystemCheck::Orphans::RepositoryCheck do + let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } } + + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + allow(subject).to receive(:fetch_disk_namespaces).and_return(disk_namespaces) + allow(subject).to receive(:fetch_disk_repositories).and_return(disk_repositories) + # silence_output + end + + describe '#multi_check' do + context 'all orphans' do + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) } + let(:disk_repositories) { %w(repo1.git repo2.git) } + + it 'prints list of all orphaned namespaces except @hashed' do + expect_list_of_orphans(%w(orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git)) + + subject.multi_check + end + end + + context 'few orphans with existing namespace' do + let!(:first_level) { create(:group, path: 'my-namespace') } + let!(:project) { create(:project, path: 'repo', namespace: first_level) } + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) } + let(:disk_repositories) { %w(repo.git) } + + it 'prints list of orphaned namespaces' do + expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git)) + + subject.multi_check + end + end + + context 'few orphans with existing namespace and parents with same name as orphans' do + let!(:first_level) { create(:group, path: 'my-namespace') } + let!(:second_level) { create(:group, path: 'second-level', parent: first_level) } + let!(:project) { create(:project, path: 'repo', namespace: first_level) } + let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) } + let(:disk_repositories) { %w(repo.git) } + + it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do + expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git second-level/repo.git)) + + subject.multi_check + end + end + + context 'no orphans' do + let(:disk_namespaces) { %w(@hashed) } + let(:disk_repositories) { %w(repo.git) } + + it 'prints an empty list ignoring @hashed' do + expect_list_of_orphans([]) + + subject.multi_check + end + end + end + + def expect_list_of_orphans(orphans) + expect(subject).to receive(:print_orphans).with(orphans, 'default') + end +end -- cgit v1.2.3 From 117cd6e56db700cd9b324ea577a82c9929282330 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 12 Sep 2017 13:51:11 +0000 Subject: Merge branch 'breadcrumbs-hover-underline' into 'master' Fixed the breadcrumbs project name not having hover style Closes #37661 See merge request !14211 --- app/assets/stylesheets/new_nav.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/new_nav.scss b/app/assets/stylesheets/new_nav.scss index 8e095cbdd7e..58e205537ef 100644 --- a/app/assets/stylesheets/new_nav.scss +++ b/app/assets/stylesheets/new_nav.scss @@ -431,6 +431,7 @@ header.navbar-gitlab-new { .breadcrumb-item-text { @include str-truncated(128px); + text-decoration: inherit; } .breadcrumbs-list-angle { -- cgit v1.2.3 From cc1e0bf314b8a0a9aeb01ff76101ec615e72dede Mon Sep 17 00:00:00 2001 From: Achilleas Pipinellis Date: Tue, 12 Sep 2017 18:22:56 +0000 Subject: Merge branch 'docs/autodevops-fixes' into 'master' Fix Auto DevOps quick start guide Closes #37768 See merge request !14230 --- doc/topics/autodevops/quick_start_guide.md | 80 +++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/doc/topics/autodevops/quick_start_guide.md b/doc/topics/autodevops/quick_start_guide.md index f23c9d794b4..564dd3222ac 100644 --- a/doc/topics/autodevops/quick_start_guide.md +++ b/doc/topics/autodevops/quick_start_guide.md @@ -18,45 +18,66 @@ example for this guide. It contains two files: ## Fork sample project on GitLab.com Let’s start by forking our sample application. Go to [the project -page](https://gitlab.com/gitlab-examples/minimal-ruby-app) and press the `Fork` -button. Soon you should have a project under your namespace with the necessary -files. +page](https://gitlab.com/auto-devops-examples/minimal-ruby-app) and press the +**Fork** button. Soon you should have a project under your namespace with the +necessary files. ## Setup your own cluster on Google Container Engine -If you do not already have a Google Cloud account, create one at https://console.cloud.google.com. +If you do not already have a Google Cloud account, create one at +https://console.cloud.google.com. -Visit the [`Container Engine`](https://console.cloud.google.com/kubernetes/list) tab and create a new cluster. You can change the name and leave the rest of the default settings. Once you have your cluster running, you need to connect to the cluster by following the Google interface. +Visit the [**Container Engine**](https://console.cloud.google.com/kubernetes/list) +tab and create a new cluster. You can change the name and leave the rest of the +default settings. Once you have your cluster running, you need to connect to the +cluster by following the Google interface. ## Connect to Kubernetes cluster You need to have the Google Cloud SDK installed. e.g. -On OSX, install [homebrew](https://brew.sh): +On macOS, install [homebrew](https://brew.sh): 1. Install Brew Caskroom: `brew install caskroom/cask/brew-cask` 2. Install Google Cloud SDK: `brew cask install google-cloud-sdk` -3. Add `kubectl`: `gcloud components install kubectl` +3. Add `kubectl` with: `gcloud components install kubectl` 4. Log in: `gcloud auth login` -Now go back to the Google interface, find your cluster, and follow the instructions under `Connect to the cluster` and open the Kubernetes Dashboard. It will look something like `gcloud container clusters get-credentials ruby-autodeploy \ --zone europe-west2-c --project api-project-XXXXXXX` and then `kubectl proxy`. +Now go back to the Google interface, find your cluster, follow the instructions +under "Connect to the cluster" and open the Kubernetes Dashboard. It will look +something like: + +```sh +gcloud container clusters get-credentials ruby-autodeploy \ --zone europe-west2-c --project api-project-XXXXXXX +``` + +Finally, run `kubectl proxy`. ![connect to cluster](img/guide_connect_cluster.png) ## Copy credentials to GitLab.com project -Once you have the Kubernetes Dashboard interface running, you should visit `Secrets` under the `Config` section. There you should find the settings we need for GitLab integration: ca.crt and token. +Once you have the Kubernetes Dashboard interface running, you should visit +**Secrets** under the "Config" section. There, you should find the settings we +need for GitLab integration: `ca.crt` and token. ![connect to cluster](img/guide_secret.png) -You need to copy-paste the ca.crt and token into your project on GitLab.com in the Kubernetes integration page under project **Settings > Integrations > Project services > Kubernetes**. Don't actually copy the namespace though. Each project should have a unique namespace, and by leaving it blank, GitLab will create one for you. +You need to copy-paste the `ca.crt` and token into your project on GitLab.com in +the Kubernetes integration page under project +**Settings > Integrations > Project services > Kubernetes**. Don't actually copy +the namespace though. Each project should have a unique namespace, and by leaving +it blank, GitLab will create one for you. ![connect to cluster](img/guide_integration.png) -For API URL, you should use the `Endpoint` IP from your cluster page on Google Cloud Platform. +For the API URL, you should use the "Endpoint" IP from your cluster page on +Google Cloud Platform. ## Expose application to the world -In order to be able to visit your application, you need to install an NGINX ingress controller and point your domain name to its external IP address. +In order to be able to visit your application, you need to install an NGINX +ingress controller and point your domain name to its external IP address. Let's +see how that's done. ### Set up Ingress controller @@ -68,28 +89,49 @@ helm init helm install --name ruby-app stable/nginx-ingress ``` -This should create several services including `ruby-app-nginx-ingress-controller`. You can list your services by running `kubectl get svc` to confirm that. +This should create several services including `ruby-app-nginx-ingress-controller`. +You can list your services by running `kubectl get svc` to confirm that. ### Point DNS at Cluster IP -Find out the external IP address of the `ruby-app-nginx-ingress-controller` by running: +Find out the external IP address of the `ruby-app-nginx-ingress-controller` by +running: ```sh kubectl get svc ruby-app-nginx-ingress-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}' ``` -Use this IP address to configure your DNS. This part heavily depends on your preferences and domain provider. But in case you are not sure, just create an A record with a wildcard host like `*.`. +Use this IP address to configure your DNS. This part heavily depends on your +preferences and domain provider. But in case you are not sure, just create an +A record with a wildcard host like `*.`. -Use `nslookup minimal-ruby-app-staging.` to confirm that domain is assigned to the cluster IP. +Use `nslookup minimal-ruby-app-staging.` to confirm that domain is +assigned to the cluster IP. ## Set up Auto DevOps -In your GitLab.com project, go to **Settings > CI/CD** and find the Auto DevOps section. Select "Enable Auto DevOps", add in your base domain, and save. +In your GitLab.com project, go to **Settings > CI/CD** and find the Auto DevOps +section. Select "Enable Auto DevOps", add in your base domain, and save. ![auto devops settings](img/auto_devops_settings.png) -Then trigger your first pipeline run. This will create a new pipeline with several jobs: `build`, `test`, `codequality`, and `production`. The `build` job will create a docker image with your new change and push it to the GitLab Container Registry. The `test` job will test your change. The `codequality` job will run static analysis on your change. The `production` job will deploy your change to a production application. Once the deploy job succeeds you should be able to see your application by visiting the Kubernetes dashboard. Select the namespace of your project, which will look like `minimal-ruby-app-23`, but with a unique ID for your project, and your app will be listed as "production" under the Deployment tab. +Next, a pipeline needs to be triggered. Since the test project doesn't have a +`.gitlab-ci.yml`, you need to either push a change to the repository or +manually visit `https://gitlab.com//minimal-ruby-app/pipelines/run`, +where `` is your username. + +This will create a new pipeline with several jobs: `build`, `test`, `codequality`, +and `production`. The `build` job will create a Docker image with your new +change and push it to the Container Registry. The `test` job will test your +changes, whereas the `codequality` job will run static analysis on your changes. +Finally, the `production` job will deploy your changes to a production application. + +Once the deploy job succeeds you should be able to see your application by +visiting the Kubernetes dashboard. Select the namespace of your project, which +will look like `minimal-ruby-app-23`, but with a unique ID for your project, +and your app will be listed as "production" under the Deployment tab. -Once its ready - just visit http://minimal-ruby-app.example.com to see “Hello, world!” +Once its ready, just visit `http://minimal-ruby-app.example.com` to see the +famous "Hello, world!"! [ce-37115]: https://gitlab.com/gitlab-org/gitlab-ce/issues/37115 -- cgit v1.2.3 From a18f488645eb493e91cb33bd7fad217956f1a4a4 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Tue, 12 Sep 2017 22:21:22 +0000 Subject: Merge branch '37730-image-onion-skin-does-not-work-anymore' into 'master' Resolve "Image onion skin + swipe does not work anymore" Closes #37730 and #37732 See merge request !14215 --- app/views/projects/diffs/viewers/_image.html.haml | 8 ++++---- .../unreleased/37730-image-onion-skin-does-not-work-anymore.yml | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/37730-image-onion-skin-does-not-work-anymore.yml diff --git a/app/views/projects/diffs/viewers/_image.html.haml b/app/views/projects/diffs/viewers/_image.html.haml index aa004a739d7..01879556894 100644 --- a/app/views/projects/diffs/viewers/_image.html.haml +++ b/app/views/projects/diffs/viewers/_image.html.haml @@ -41,10 +41,10 @@ .swipe.view.hide .swipe-frame .frame.deleted - = image_tag(old_blob_raw_path, alt: diff_file.old_path) + = image_tag(old_blob_raw_path, alt: diff_file.old_path, lazy: false) .swipe-wrap .frame.added - = image_tag(blob_raw_path, alt: diff_file.new_path) + = image_tag(blob_raw_path, alt: diff_file.new_path, lazy: false) %span.swipe-bar %span.top-handle %span.bottom-handle @@ -52,9 +52,9 @@ .onion-skin.view.hide .onion-skin-frame .frame.deleted - = image_tag(old_blob_raw_path, alt: diff_file.old_path) + = image_tag(old_blob_raw_path, alt: diff_file.old_path, lazy: false) .frame.added - = image_tag(blob_raw_path, alt: diff_file.new_path) + = image_tag(blob_raw_path, alt: diff_file.new_path, lazy: false) .controls .transparent .drag-track diff --git a/changelogs/unreleased/37730-image-onion-skin-does-not-work-anymore.yml b/changelogs/unreleased/37730-image-onion-skin-does-not-work-anymore.yml new file mode 100644 index 00000000000..7357c61b5f2 --- /dev/null +++ b/changelogs/unreleased/37730-image-onion-skin-does-not-work-anymore.yml @@ -0,0 +1,5 @@ +--- +title: Resolve Image onion skin + swipe does not work anymore +merge_request: +author: +type: fixed -- cgit v1.2.3 From 74dc4c2c92bcf51d23d33a0b01a5e84f8ba8fc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 13 Sep 2017 09:00:50 +0000 Subject: Merge branch 'zj-feature-flipper-disable-banner' into 'master' Allow all AutoDevOps banners to be disabled Closes #37653 See merge request !14218 --- app/helpers/auto_devops_helper.rb | 3 ++- .../unreleased/zj-feature-flipper-disable-banner.yml | 5 +++++ doc/topics/autodevops/index.md | 17 +++++++++++++++++ spec/helpers/auto_devops_helper_spec.rb | 10 ++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/zj-feature-flipper-disable-banner.yml diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb index 4ff38f86b5f..c132daed323 100644 --- a/app/helpers/auto_devops_helper.rb +++ b/app/helpers/auto_devops_helper.rb @@ -1,6 +1,7 @@ module AutoDevopsHelper def show_auto_devops_callout?(project) - show_callout?('auto_devops_settings_dismissed') && + Feature.get(:auto_devops_banner_disabled).off? && + show_callout?('auto_devops_settings_dismissed') && can?(current_user, :admin_pipeline, project) && project.has_auto_devops_implicitly_disabled? end diff --git a/changelogs/unreleased/zj-feature-flipper-disable-banner.yml b/changelogs/unreleased/zj-feature-flipper-disable-banner.yml new file mode 100644 index 00000000000..fd5dd1bbe37 --- /dev/null +++ b/changelogs/unreleased/zj-feature-flipper-disable-banner.yml @@ -0,0 +1,5 @@ +--- +title: Allow all AutoDevOps banners to be turned off +merge_request: +author: +type: changed diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md index babf44d2665..b31b8eaaca0 100644 --- a/doc/topics/autodevops/index.md +++ b/doc/topics/autodevops/index.md @@ -323,6 +323,23 @@ container registry. **Restarting a pod, scaling a service, or other actions whic require on-going access to the registry will fail**. On-going secure access is planned for a subsequent release. +## Disable the banner instance wide + +If an administrater would like to disable the banners on an instance level, this +feature can be disabled either through the console: + +```basb +$ gitlab-rails console +[1] pry(main)> Feature.get(:auto_devops_banner_disabled).disable +=> true +``` + +Or through the HTTP API with the admin access token: + +``` +curl --data "value=true" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/auto_devops_banner_disabled +``` + ## Troubleshooting - Auto Build and Auto Test may fail in detecting your language/framework. There diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb index b6d892548ef..80d58ff6bf7 100644 --- a/spec/helpers/auto_devops_helper_spec.rb +++ b/spec/helpers/auto_devops_helper_spec.rb @@ -10,6 +10,8 @@ describe AutoDevopsHelper do before do allow(helper).to receive(:can?).with(user, :admin_pipeline, project) { allowed } allow(helper).to receive(:current_user) { user } + + Feature.get(:auto_devops_banner_disabled).disable end subject { helper.show_auto_devops_callout?(project) } @@ -18,6 +20,14 @@ describe AutoDevopsHelper do it { is_expected.to eq(true) } end + context 'when the banner is disabled by feature flag' do + it 'allows the feature flag to disable' do + Feature.get(:auto_devops_banner_disabled).enable + + expect(subject).to be(false) + end + end + context 'when dismissed' do before do helper.request.cookies[:auto_devops_settings_dismissed] = 'true' -- cgit v1.2.3 From 3d86ef603994e7a18e7c1ca11ba134c0e62f155a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 13 Sep 2017 14:24:29 +0000 Subject: Merge branch 'sh-exclude-api-responses' into 'master' Exclude logging of API responses to prevent leakage of confidential data See merge request !14245 --- lib/api/api.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/api/api.rb b/lib/api/api.rb index ee4e1688e12..79e55a2f4f7 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -8,7 +8,6 @@ module API logger: Logger.new(LOG_FILENAME), formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new, include: [ - GrapeLogging::Loggers::Response.new, GrapeLogging::Loggers::FilterParameters.new, GrapeLogging::Loggers::ClientEnv.new ] -- cgit v1.2.3 From 7ae5d97ecdec371f564d20217186aa26fd0ef3cc Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 13 Sep 2017 09:24:12 +0000 Subject: Merge branch '37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot' into 'master' Resolve "Lazy image loading breaks notification mails for an added screenshot" Closes #37629 See merge request !14161 --- ...g-breaks-notification-mails-for-an-added-screenshot.yml | 5 +++++ lib/banzai/filter/image_lazy_load_filter.rb | 3 ++- lib/banzai/pipeline/email_pipeline.rb | 6 ++++++ spec/lib/banzai/pipeline/email_pipeline_spec.rb | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml create mode 100644 spec/lib/banzai/pipeline/email_pipeline_spec.rb diff --git a/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml b/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml new file mode 100644 index 00000000000..5735d59a2bd --- /dev/null +++ b/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml @@ -0,0 +1,5 @@ +--- +title: Image attachments are properly displayed in notification emails again +merge_request: 14161 +author: +type: fixed diff --git a/lib/banzai/filter/image_lazy_load_filter.rb b/lib/banzai/filter/image_lazy_load_filter.rb index bcb4f332267..4cd9b02b76c 100644 --- a/lib/banzai/filter/image_lazy_load_filter.rb +++ b/lib/banzai/filter/image_lazy_load_filter.rb @@ -1,6 +1,7 @@ module Banzai module Filter - # HTML filter that moves the value of the src attribute to the data-src attribute so it can be lazy loaded + # HTML filter that moves the value of image `src` attributes to `data-src` + # so they can be lazy loaded. class ImageLazyLoadFilter < HTML::Pipeline::Filter def call doc.xpath('descendant-or-self::img').each do |img| diff --git a/lib/banzai/pipeline/email_pipeline.rb b/lib/banzai/pipeline/email_pipeline.rb index e47c384afc1..8f5f144d582 100644 --- a/lib/banzai/pipeline/email_pipeline.rb +++ b/lib/banzai/pipeline/email_pipeline.rb @@ -1,6 +1,12 @@ module Banzai module Pipeline class EmailPipeline < FullPipeline + def self.filters + super.tap do |filter_array| + filter_array.delete(Banzai::Filter::ImageLazyLoadFilter) + end + end + def self.transform_context(context) super(context).merge( only_path: false diff --git a/spec/lib/banzai/pipeline/email_pipeline_spec.rb b/spec/lib/banzai/pipeline/email_pipeline_spec.rb new file mode 100644 index 00000000000..6a11ca2f9d5 --- /dev/null +++ b/spec/lib/banzai/pipeline/email_pipeline_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +describe Banzai::Pipeline::EmailPipeline do + describe '.filters' do + it 'returns the expected type' do + expect(described_class.filters).to be_kind_of(Banzai::FilterArray) + end + + it 'excludes ImageLazyLoadFilter' do + expect(described_class.filters).not_to be_empty + expect(described_class.filters).not_to include(Banzai::Filter::ImageLazyLoadFilter) + end + end +end -- cgit v1.2.3 From 7e5af69524c3c59c86b501d238fdf935ccfa4851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 13 Sep 2017 08:48:20 +0000 Subject: Merge branch 'zj-usage-data-auto-devops' into 'master' Add usage ping for Auto DevOps Closes #37648 See merge request !14162 --- app/models/project_auto_devops.rb | 3 +++ changelogs/unreleased/zj-usage-data-auto-devops.yml | 5 +++++ lib/gitlab/usage_data.rb | 4 ++++ spec/lib/gitlab/usage_data_spec.rb | 4 ++++ 4 files changed, 16 insertions(+) create mode 100644 changelogs/unreleased/zj-usage-data-auto-devops.yml diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb index 53731579e87..7af3b6870e2 100644 --- a/app/models/project_auto_devops.rb +++ b/app/models/project_auto_devops.rb @@ -1,6 +1,9 @@ class ProjectAutoDevops < ActiveRecord::Base belongs_to :project + scope :enabled, -> { where(enabled: true) } + scope :disabled, -> { where(enabled: false) } + validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true } def variables diff --git a/changelogs/unreleased/zj-usage-data-auto-devops.yml b/changelogs/unreleased/zj-usage-data-auto-devops.yml new file mode 100644 index 00000000000..9b5ec894042 --- /dev/null +++ b/changelogs/unreleased/zj-usage-data-auto-devops.yml @@ -0,0 +1,5 @@ +--- +title: Add usage data for Auto DevOps +merge_request: +author: +type: other diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 3cf26625108..36708078136 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -22,9 +22,13 @@ module Gitlab ci_builds: ::Ci::Build.count, ci_internal_pipelines: ::Ci::Pipeline.internal.count, ci_external_pipelines: ::Ci::Pipeline.external.count, + ci_pipeline_config_auto_devops: ::Ci::Pipeline.auto_devops_source.count, + ci_pipeline_config_repository: ::Ci::Pipeline.repository_source.count, ci_runners: ::Ci::Runner.count, ci_triggers: ::Ci::Trigger.count, ci_pipeline_schedules: ::Ci::PipelineSchedule.count, + auto_devops_enabled: ::ProjectAutoDevops.enabled.count, + auto_devops_disabled: ::ProjectAutoDevops.disabled.count, deploy_keys: DeployKey.count, deployments: Deployment.count, environments: ::Environment.count, diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 68429d792f2..c7d9f105f04 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -40,9 +40,13 @@ describe Gitlab::UsageData do ci_builds ci_internal_pipelines ci_external_pipelines + ci_pipeline_config_auto_devops + ci_pipeline_config_repository ci_runners ci_triggers ci_pipeline_schedules + auto_devops_enabled + auto_devops_disabled deploy_keys deployments environments -- cgit v1.2.3 From 2f277bb9a0c7f95febaa630f465ea31e3e163bad Mon Sep 17 00:00:00 2001 From: Tim Zallmann Date: Tue, 12 Sep 2017 12:01:21 +0000 Subject: Merge branch 'fly-out-nav-closest-undefined' into 'master' Fix JS error in fly-out nav See merge request !14212 --- app/assets/javascripts/fly_out_nav.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/fly_out_nav.js b/app/assets/javascripts/fly_out_nav.js index 4b19f7b4188..ad8254167a2 100644 --- a/app/assets/javascripts/fly_out_nav.js +++ b/app/assets/javascripts/fly_out_nav.js @@ -148,7 +148,7 @@ export const documentMouseMove = (e) => { export const subItemsMouseLeave = (relatedTarget) => { clearTimeout(timeoutId); - if (!relatedTarget.closest(`.${IS_OVER_CLASS}`)) { + if (relatedTarget && !relatedTarget.closest(`.${IS_OVER_CLASS}`)) { hideMenu(currentOpenMenu); } }; -- cgit v1.2.3 From 307d37de894912537ad905fe9200471fd5e8f8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 13 Sep 2017 11:53:00 +0000 Subject: Merge branch 'zj-auto-devops-banner' into 'master' AutoDevOps banner hidden on explicit CI config Closes #37652 See merge request !14207 --- app/helpers/auto_devops_helper.rb | 4 +++- changelogs/unreleased/zj-auto-devops-banner.yml | 6 ++++++ spec/helpers/auto_devops_helper_spec.rb | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/zj-auto-devops-banner.yml diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb index c132daed323..c455d18cff8 100644 --- a/app/helpers/auto_devops_helper.rb +++ b/app/helpers/auto_devops_helper.rb @@ -3,6 +3,8 @@ module AutoDevopsHelper Feature.get(:auto_devops_banner_disabled).off? && show_callout?('auto_devops_settings_dismissed') && can?(current_user, :admin_pipeline, project) && - project.has_auto_devops_implicitly_disabled? + project.has_auto_devops_implicitly_disabled? && + !project.repository.gitlab_ci_yml && + project.ci_services.active.none? end end diff --git a/changelogs/unreleased/zj-auto-devops-banner.yml b/changelogs/unreleased/zj-auto-devops-banner.yml new file mode 100644 index 00000000000..a2abed0b2ec --- /dev/null +++ b/changelogs/unreleased/zj-auto-devops-banner.yml @@ -0,0 +1,6 @@ +--- +title: Do not show the Auto DevOps banner when the project has a .gitlab-ci.yml on + master +merge_request: +author: +type: fixed diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb index 80d58ff6bf7..5e272af6073 100644 --- a/spec/helpers/auto_devops_helper_spec.rb +++ b/spec/helpers/auto_devops_helper_spec.rb @@ -65,5 +65,21 @@ describe AutoDevopsHelper do it { is_expected.to eq(false) } end + + context 'when master contains a .gitlab-ci.yml file' do + before do + allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']") + end + + it { is_expected.to eq(false) } + end + + context 'when another service is enabled' do + before do + create(:service, project: project, category: :ci, active: true) + end + + it { is_expected.to eq(false) } + end end end -- cgit v1.2.3 From 8bb8edc1f476f9dbae525e1ff3f8000655ce4902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 13 Sep 2017 11:31:37 +0000 Subject: Merge branch 'fix/gpg-tmp-dir-removal-race-condition' into 'master' Fix: GPG tmp dir removal race condition Ignore any errors when removing the tmp directory, as we may run into a race condition: The `gpg-agent` agent process may clean up some files as well while `FileUtils.remove_entry` is iterating the directory and removing all its contained files and directories recursively, which could raise an error. Closes #36998 See merge request !14194 --- .../unreleased/fix-gpg-tmp-dir-removal-race-condition.yml | 5 +++++ lib/gitlab/gpg.rb | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml diff --git a/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml b/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml new file mode 100644 index 00000000000..e75f188913f --- /dev/null +++ b/changelogs/unreleased/fix-gpg-tmp-dir-removal-race-condition.yml @@ -0,0 +1,5 @@ +--- +title: Fixes the 500 errors caused by a race condition in GPG's tmp directory handling +merge_request: 14194 +author: Alexis Reigel +type: fixed diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb index 025f826e65f..0d5039ddf5f 100644 --- a/lib/gitlab/gpg.rb +++ b/lib/gitlab/gpg.rb @@ -69,11 +69,17 @@ module Gitlab def optimistic_using_tmp_keychain previous_dir = current_home_dir - Dir.mktmpdir do |dir| - GPGME::Engine.home_dir = dir - yield - end + tmp_dir = Dir.mktmpdir + GPGME::Engine.home_dir = tmp_dir + yield ensure + # Ignore any errors when removing the tmp directory, as we may run into a + # race condition: + # The `gpg-agent` agent process may clean up some files as well while + # `FileUtils.remove_entry` is iterating the directory and removing all + # its contained files and directories recursively, which could raise an + # error. + FileUtils.remove_entry(tmp_dir, true) GPGME::Engine.home_dir = previous_dir end end -- cgit v1.2.3 From 0b18c47200e673a76fbadca1b1ff983200ab7832 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Thu, 14 Sep 2017 01:20:59 +0000 Subject: Merge branch 'sub-group-dropdown-width' into 'master' Fixed width of sub-group in breadcrumb dropdown Closes #37745 See merge request !14210 --- app/helpers/groups_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 36b79da1bde..e8efe8fab27 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -21,7 +21,7 @@ module GroupsHelper group.ancestors.reverse.each_with_index do |parent, index| if index > 0 - add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true), location: :before) + add_to_breadcrumb_dropdown(group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before) else full_title += breadcrumb_list_item group_title_link(parent, hidable: false) end @@ -85,8 +85,8 @@ module GroupsHelper private - def group_title_link(group, hidable: false, show_avatar: false) - link_to(group_path(group), class: "group-path breadcrumb-item-text js-breadcrumb-item-text #{'hidable' if hidable}") do + def group_title_link(group, hidable: false, show_avatar: false, for_dropdown: false) + link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do output = if (group.try(:avatar_url) || show_avatar) && !Rails.env.test? image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15) -- cgit v1.2.3 From fbe66a2b218eef4d23640bb4eddc4cb7737e3c8f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 13 Sep 2017 23:42:04 +0000 Subject: Merge branch 'fix_default_navigation_theme_selection' into 'master' Fix default navigation theme selection Closes #37777 See merge request !14260 --- app/views/profiles/preferences/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml index 69885008ecd..66d1d1e8d44 100644 --- a/app/views/profiles/preferences/show.html.haml +++ b/app/views/profiles/preferences/show.html.haml @@ -17,7 +17,7 @@ .preview-row .quadrant.three .quadrant.four - = f.radio_button :theme_id, theme.id + = f.radio_button :theme_id, theme.id, checked: Gitlab::Themes.for_user(@user).id == theme.id = theme.name .col-sm-12 -- cgit v1.2.3 From 61499113dffcea930a8d7eac08761a25aae62628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 13 Sep 2017 12:39:43 +0000 Subject: Merge branch 'fix/sm/37559-pipeline-triggered-through-api-not-showing-trigger-variables' into 'master' Fix `ci_builds` to have an associated `trigger_request_id` See merge request !14244 --- app/services/ci/pipeline_trigger_service.rb | 2 +- ...pipeline-triggered-through-api-not-showing-trigger-variables.yml | 6 ++++++ spec/services/ci/pipeline_trigger_service_spec.rb | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/fix-sm-37559-pipeline-triggered-through-api-not-showing-trigger-variables.yml diff --git a/app/services/ci/pipeline_trigger_service.rb b/app/services/ci/pipeline_trigger_service.rb index 1e5ad28ba57..120af8c1e61 100644 --- a/app/services/ci/pipeline_trigger_service.rb +++ b/app/services/ci/pipeline_trigger_service.rb @@ -14,7 +14,7 @@ module Ci pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: params[:ref]) .execute(:trigger, ignore_skip_ci: true) do |pipeline| - trigger.trigger_requests.create!(pipeline: pipeline) + pipeline.trigger_requests.create!(trigger: trigger) create_pipeline_variables!(pipeline) end diff --git a/changelogs/unreleased/fix-sm-37559-pipeline-triggered-through-api-not-showing-trigger-variables.yml b/changelogs/unreleased/fix-sm-37559-pipeline-triggered-through-api-not-showing-trigger-variables.yml new file mode 100644 index 00000000000..8aae0f6f5b6 --- /dev/null +++ b/changelogs/unreleased/fix-sm-37559-pipeline-triggered-through-api-not-showing-trigger-variables.yml @@ -0,0 +1,6 @@ +--- +title: Fix Pipeline Triggers to show triggered label and predefined variables (e.g. + CI_PIPELINE_TRIGGERED) +merge_request: 14244 +author: +type: fixed diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb index 9a6875e448c..f4ff818c479 100644 --- a/spec/services/ci/pipeline_trigger_service_spec.rb +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -34,6 +34,8 @@ describe Ci::PipelineTriggerService do expect(result[:pipeline].ref).to eq('master') expect(result[:pipeline].project).to eq(project) expect(result[:pipeline].user).to eq(trigger.owner) + expect(result[:pipeline].trigger_requests.to_a) + .to eq(result[:pipeline].builds.map(&:trigger_request).uniq) expect(result[:status]).to eq(:success) end -- cgit v1.2.3 From f3d4d02356c3013d64af92a81e1cab6311eac224 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 14 Sep 2017 08:54:34 +0000 Subject: Merge branch '37573-fix-sidebar-active-color' into 'master' Update badge color to match theme; lighten active color in sidebar Closes #37573 See merge request gitlab-org/gitlab-ce!14116 --- app/assets/stylesheets/framework/gitlab-theme.scss | 20 ++++++++++++++++++-- app/assets/stylesheets/new_sidebar.scss | 14 -------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/framework/gitlab-theme.scss b/app/assets/stylesheets/framework/gitlab-theme.scss index 71f764923ff..f844d6f1d5a 100644 --- a/app/assets/stylesheets/framework/gitlab-theme.scss +++ b/app/assets/stylesheets/framework/gitlab-theme.scss @@ -158,11 +158,23 @@ box-shadow: inset 4px 0 0 $color-700; > a { - color: $color-900; + color: $color-800; } svg { - fill: $color-900; + fill: $color-800; + } + } + + .sidebar-top-level-items > li.active .badge { + color: $color-800; + } + + .nav-links li.active a { + border-bottom-color: $color-500; + + .badge { + font-weight: $gl-font-weight-bold; } } } @@ -261,5 +273,9 @@ body { fill: $theme-gray-900; } } + + .sidebar-top-level-items > li.active .badge { + color: $theme-gray-900; + } } } diff --git a/app/assets/stylesheets/new_sidebar.scss b/app/assets/stylesheets/new_sidebar.scss index 4bbd30056a9..35cb71d422b 100644 --- a/app/assets/stylesheets/new_sidebar.scss +++ b/app/assets/stylesheets/new_sidebar.scss @@ -3,8 +3,6 @@ @import "bootstrap/variables"; $active-background: rgba(0, 0, 0, .04); -$active-border: $indigo-500; -$active-color: $indigo-700; $active-hover-background: $active-background; $active-hover-color: $gl-text-color; $inactive-badge-background: rgba(0, 0, 0, .08); @@ -210,7 +208,6 @@ $new-sidebar-collapsed-width: 50px; &:hover, &:focus { background: $active-background; - color: $active-color; } } } @@ -310,7 +307,6 @@ $new-sidebar-collapsed-width: 50px; } .badge { - color: $active-color; font-weight: $gl-font-weight-bold; } @@ -487,13 +483,3 @@ $new-sidebar-collapsed-width: 50px; .with-performance-bar .boards-list { height: calc(100vh - #{$new-navbar-height} - #{$performance-bar-height}); } - - -// Change color of all horizontal tabs to match the new indigo color -.nav-links li.active a { - border-bottom-color: $active-border; - - .badge { - font-weight: $gl-font-weight-bold; - } -} -- cgit v1.2.3 From 3b05ef4104aa4ac5587d86888fffeca6436482e0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 14 Sep 2017 08:28:04 +0000 Subject: Merge branch '37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header' into 'master' Resolve "Renamed files have escaped HTML for the inline diff in the header" Closes #37576 See merge request gitlab-org/gitlab-ce!14121 --- ...-have-escaped-html-for-the-inline-diff-in-the-header.yml | 5 +++++ lib/gitlab/diff/inline_diff_marker.rb | 3 ++- spec/features/projects/diffs/diff_show_spec.rb | 13 +++++++++++++ spec/helpers/diff_helper_spec.rb | 4 ++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml diff --git a/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml b/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml new file mode 100644 index 00000000000..8c328eb0950 --- /dev/null +++ b/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml @@ -0,0 +1,5 @@ +--- +title: Fix the diff file header from being html escaped for renamed files. +merge_request: 14121 +author: +type: fixed diff --git a/lib/gitlab/diff/inline_diff_marker.rb b/lib/gitlab/diff/inline_diff_marker.rb index 919965100ae..010b4be7b40 100644 --- a/lib/gitlab/diff/inline_diff_marker.rb +++ b/lib/gitlab/diff/inline_diff_marker.rb @@ -2,9 +2,10 @@ module Gitlab module Diff class InlineDiffMarker < Gitlab::StringRangeMarker def mark(line_inline_diffs, mode: nil) - super(line_inline_diffs) do |text, left:, right:| + mark = super(line_inline_diffs) do |text, left:, right:| %{#{text}} end + mark.html_safe end private diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index bc102895aaf..a6f52c9ef58 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -108,6 +108,19 @@ feature 'Diff file viewer', :js do end end + context 'renamed file' do + before do + visit_commit('6907208d755b60ebeacb2e9dfea74c92c3449a1f') + end + + it 'shows the filename with diff highlight' do + within('.file-header-content') do + expect(page).to have_css('.idiff.left.right.deletion') + expect(page).to have_content('files/js/commit.coffee') + end + end + end + context 'binary file that appears to be text in the first 1024 bytes' do before do # The file we're visiting is smaller than 10 KB and we want it collapsed diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 0deea0ff6a3..f9c31ac61d8 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -136,9 +136,9 @@ describe DiffHelper do marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) expect(marked_old_line).to eq(%q{abc 'def'}) - expect(marked_old_line).not_to be_html_safe + expect(marked_old_line).to be_html_safe expect(marked_new_line).to eq(%q{abc "def"}) - expect(marked_new_line).not_to be_html_safe + expect(marked_new_line).to be_html_safe end end -- cgit v1.2.3 From e83260bda36808ba0313cd13c5ec2a9364a2b6c1 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 14 Sep 2017 09:02:30 +0000 Subject: Merge branch '35978-milestone-title' into 'master' Truncate milestone text on collapse; add tooltip for title Closes #35978 See merge request gitlab-org/gitlab-ce!14123 --- app/assets/javascripts/milestone_select.js | 3 ++- app/assets/stylesheets/pages/issuable.scss | 6 ++++++ app/views/shared/issuable/_sidebar.html.haml | 4 ++-- changelogs/unreleased/35978-milestone-title.yml | 5 +++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/35978-milestone-title.yml diff --git a/app/assets/javascripts/milestone_select.js b/app/assets/javascripts/milestone_select.js index 04579058688..4675b1fcb8f 100644 --- a/app/assets/javascripts/milestone_select.js +++ b/app/assets/javascripts/milestone_select.js @@ -45,7 +45,7 @@ import _ from 'underscore'; if (issueUpdateURL) { milestoneLinkTemplate = _.template('<%- title %>'); milestoneLinkNoneTemplate = 'None'; - collapsedSidebarLabelTemplate = _.template(' <%- title %> '); + collapsedSidebarLabelTemplate = _.template(' <%- title %> '); } return $dropdown.glDropdown({ showMenuAbove: showMenuAbove, @@ -208,6 +208,7 @@ import _ from 'underscore'; if (data.milestone != null) { data.milestone.full_path = _this.currentProject.full_path; data.milestone.remaining = gl.utils.timeFor(data.milestone.due_date); + data.milestone.name = data.milestone.title; $value.html(milestoneLinkTemplate(data.milestone)); return $sidebarCollapsedValue.find('span').html(collapsedSidebarLabelTemplate(data.milestone)); } else { diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index d8a15faf7e9..d01ee4b033c 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -449,6 +449,12 @@ } } } + + .milestone-title span { + @include str-truncated(100%); + display: block; + margin: 0 4px; + } } a { diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index 0afa48b392c..9cae3f51825 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -24,9 +24,9 @@ .block.milestone .sidebar-collapsed-icon = icon('clock-o', 'aria-hidden': 'true') - %span + %span.milestone-title - if issuable.milestone - %span.has-tooltip{ title: milestone_remaining_days(issuable.milestone), data: { container: 'body', html: 1, placement: 'left' } } + %span.has-tooltip{ title: "#{issuable.milestone.title}
#{milestone_remaining_days(issuable.milestone)}", data: { container: 'body', html: 1, placement: 'left' } } = issuable.milestone.title - else None diff --git a/changelogs/unreleased/35978-milestone-title.yml b/changelogs/unreleased/35978-milestone-title.yml new file mode 100644 index 00000000000..1a4b71328c1 --- /dev/null +++ b/changelogs/unreleased/35978-milestone-title.yml @@ -0,0 +1,5 @@ +--- +title: Truncate milestone title if sidebar is collapsed +merge_request: +author: +type: fixed -- cgit v1.2.3 From e4ef2406c6f12d2ea098e76297224324d1d3b354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 14 Sep 2017 13:50:58 +0000 Subject: Merge branch 'repo-cache-fix' into 'master' Restore has_visible_content? to improve performance (cache) See merge request gitlab-org/gitlab-ce!14264 --- app/models/repository.rb | 6 ++++++ spec/workers/git_garbage_collect_worker_spec.rb | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 035f85a0b46..6ed33e0c268 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -90,6 +90,12 @@ 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 diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index 6f9ddb6c63c..f7b67b8efc6 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -31,8 +31,8 @@ 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 @@ -77,8 +77,8 @@ 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 -- cgit v1.2.3 From d94e566237e02239c2c89ef44bf2596e43860165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 14 Sep 2017 13:57:40 +0000 Subject: Merge branch '37759-also-treat-newlines-as-separator' into 'master' Treat newlines as separators for pipeline emails service Closes #37759 See merge request gitlab-org/gitlab-ce!14250 --- .../project_services/pipelines_email_service.rb | 2 +- .../37759-also-treat-newlines-as-separator.yml | 5 +++ .../pipelines_email_service_spec.rb | 37 ++++++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 changelogs/unreleased/37759-also-treat-newlines-as-separator.yml diff --git a/app/models/project_services/pipelines_email_service.rb b/app/models/project_services/pipelines_email_service.rb index 9d37184be2c..6a3118a11b8 100644 --- a/app/models/project_services/pipelines_email_service.rb +++ b/app/models/project_services/pipelines_email_service.rb @@ -80,6 +80,6 @@ class PipelinesEmailService < Service end def retrieve_recipients(data) - recipients.to_s.split(',').reject(&:blank?) + recipients.to_s.split(/[,(?:\r?\n) ]+/).reject(&:empty?) end end diff --git a/changelogs/unreleased/37759-also-treat-newlines-as-separator.yml b/changelogs/unreleased/37759-also-treat-newlines-as-separator.yml new file mode 100644 index 00000000000..6894e650c11 --- /dev/null +++ b/changelogs/unreleased/37759-also-treat-newlines-as-separator.yml @@ -0,0 +1,5 @@ +--- +title: Allow using newlines in pipeline email service recipients +merge_request: 14250 +author: +type: fixed diff --git a/spec/models/project_services/pipelines_email_service_spec.rb b/spec/models/project_services/pipelines_email_service_spec.rb index 5faab9ba38b..be07ca2d945 100644 --- a/spec/models/project_services/pipelines_email_service_spec.rb +++ b/spec/models/project_services/pipelines_email_service_spec.rb @@ -6,7 +6,8 @@ describe PipelinesEmailService, :mailer do end let(:project) { create(:project, :repository) } - let(:recipient) { 'test@gitlab.com' } + let(:recipients) { 'test@gitlab.com' } + let(:receivers) { [recipients] } let(:data) do Gitlab::DataBuilder::Pipeline.build(pipeline) @@ -48,18 +49,24 @@ describe PipelinesEmailService, :mailer do shared_examples 'sending email' do before do + subject.recipients = recipients + perform_enqueued_jobs do run end end it 'sends email' do - should_only_email(double(notification_email: recipient), kind: :bcc) + emails = receivers.map { |r| double(notification_email: r) } + + should_only_email(*emails, kind: :bcc) end end shared_examples 'not sending email' do before do + subject.recipients = recipients + perform_enqueued_jobs do run end @@ -75,10 +82,6 @@ describe PipelinesEmailService, :mailer do subject.test(data) end - before do - subject.recipients = recipient - end - context 'when pipeline is failed' do before do data[:object_attributes][:status] = 'failed' @@ -104,10 +107,6 @@ describe PipelinesEmailService, :mailer do end context 'with recipients' do - before do - subject.recipients = recipient - end - context 'with failed pipeline' do before do data[:object_attributes][:status] = 'failed' @@ -152,9 +151,7 @@ describe PipelinesEmailService, :mailer do end context 'with empty recipients list' do - before do - subject.recipients = ' ,, ' - end + let(:recipients) { ' ,, ' } context 'with failed pipeline' do before do @@ -165,5 +162,19 @@ describe PipelinesEmailService, :mailer do it_behaves_like 'not sending email' end end + + context 'with recipients list separating with newlines' do + let(:recipients) { "\ntest@gitlab.com, \r\nexample@gitlab.com" } + let(:receivers) { %w[test@gitlab.com example@gitlab.com] } + + context 'with failed pipeline' do + before do + data[:object_attributes][:status] = 'failed' + pipeline.update(status: 'failed') + end + + it_behaves_like 'sending email' + end + end end end -- cgit v1.2.3 From d8bf06926eb67a02bea039261589df5fd2c2fbb6 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 14 Sep 2017 14:14:39 +0000 Subject: Merge branch '37845-fix-oauth-provider-forced-encoding' into 'master' Don't force the encoding of the OAuth provider in Gitlab::OAuth::AuthHash#provider Closes #37845 See merge request gitlab-org/gitlab-ce!14263 --- lib/gitlab/o_auth/auth_hash.rb | 2 +- spec/lib/gitlab/o_auth/auth_hash_spec.rb | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/gitlab/o_auth/auth_hash.rb b/lib/gitlab/o_auth/auth_hash.rb index 1f331b1e91d..5b5ed449f94 100644 --- a/lib/gitlab/o_auth/auth_hash.rb +++ b/lib/gitlab/o_auth/auth_hash.rb @@ -13,7 +13,7 @@ module Gitlab end def provider - @provider ||= Gitlab::Utils.force_utf8(auth_hash.provider.to_s) + @provider ||= auth_hash.provider.to_s end def name diff --git a/spec/lib/gitlab/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/o_auth/auth_hash_spec.rb index d5f4da3ce36..dbcc200b90b 100644 --- a/spec/lib/gitlab/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/o_auth/auth_hash_spec.rb @@ -1,10 +1,11 @@ require 'spec_helper' describe Gitlab::OAuth::AuthHash do + let(:provider) { 'ldap'.freeze } let(:auth_hash) do described_class.new( OmniAuth::AuthHash.new( - provider: provider_ascii, + provider: provider, uid: uid_ascii, info: info_hash ) @@ -20,7 +21,6 @@ describe Gitlab::OAuth::AuthHash do let(:last_name_raw) { "K\xC3\xBC\xC3\xA7\xC3\xBCk" } let(:name_raw) { "Onur K\xC3\xBC\xC3\xA7\xC3\xBCk" } - let(:provider_ascii) { 'ldap'.force_encoding(Encoding::ASCII_8BIT) } let(:uid_ascii) { uid_raw.force_encoding(Encoding::ASCII_8BIT) } let(:email_ascii) { email_raw.force_encoding(Encoding::ASCII_8BIT) } let(:nickname_ascii) { nickname_raw.force_encoding(Encoding::ASCII_8BIT) } @@ -28,7 +28,6 @@ describe Gitlab::OAuth::AuthHash do let(:last_name_ascii) { last_name_raw.force_encoding(Encoding::ASCII_8BIT) } let(:name_ascii) { name_raw.force_encoding(Encoding::ASCII_8BIT) } - let(:provider_utf8) { provider_ascii.force_encoding(Encoding::UTF_8) } let(:uid_utf8) { uid_ascii.force_encoding(Encoding::UTF_8) } let(:email_utf8) { email_ascii.force_encoding(Encoding::UTF_8) } let(:nickname_utf8) { nickname_ascii.force_encoding(Encoding::UTF_8) } @@ -46,7 +45,7 @@ describe Gitlab::OAuth::AuthHash do end context 'defaults' do - it { expect(auth_hash.provider).to eql provider_utf8 } + it { expect(auth_hash.provider).to eq provider } it { expect(auth_hash.uid).to eql uid_utf8 } it { expect(auth_hash.email).to eql email_utf8 } it { expect(auth_hash.username).to eql nickname_utf8 } -- cgit v1.2.3