From fbc9a1ac69145a3b6f8d4d4f96363b0f81225652 Mon Sep 17 00:00:00 2001 From: Andrew Winata Date: Fri, 1 Jun 2018 15:02:52 +1000 Subject: Docs clarify API to share project to a group --- doc/api/members.md | 4 ++++ doc/api/projects.md | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/api/members.md b/doc/api/members.md index 3234f833eae..fca5ce16baf 100644 --- a/doc/api/members.md +++ b/doc/api/members.md @@ -173,3 +173,7 @@ DELETE /projects/:id/members/:user_id curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/:id/members/:user_id curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/:id/members/:user_id ``` + +## Give a group access to a project + +Look at [share project with group](projects.md#share-project-with-group) diff --git a/doc/api/projects.md b/doc/api/projects.md index d3e95926322..30a41839f28 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -1198,7 +1198,7 @@ POST /projects/:id/share | --------- | ---- | -------- | ----------- | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) | | `group_id` | integer | yes | The ID of the group to share with | -| `group_access` | integer | yes | The permissions level to grant the group | +| `group_access` | integer | yes | The [permissions level](members.md) to grant the group | | `expires_at` | string | no | Share expiration date in ISO 8601 format: 2016-09-26 | ## Delete a shared project link within a group -- cgit v1.2.1 From a1d0a16bfbef8654684bca828505632bcfaaaeba Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 14 Jun 2018 21:31:54 -0500 Subject: Fix flakey time-senstive group filter specs This passed previously because the filtered group search is debounced by 0.5s. The test cleared the input, entered `group1`, cleared the input, entered nothing, and the all of groups are still listed because of the 0.5s debounce hasn't triggered and the test passes before anything is actually filtered. Even if we assert that the list is filtered before clearing the input, the test still fails because the nature of the `fill_in 'filter', with: ""` method is that ["if you're setting the value to "", no keys are ever actually sent, hence no [`input`] event"](https://github.com/teamcapybara/capybara/issues/203#issuecomment-557281) and we never filter back to everything in the list. So the solution is two-fold, add in the assertions that the list is actually filtered after each step. Then use a method that fills the input with proper events fired. --- spec/features/dashboard/groups_list_spec.rb | 4 ++++ spec/features/explore/groups_list_spec.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/spec/features/dashboard/groups_list_spec.rb b/spec/features/dashboard/groups_list_spec.rb index ed47f7ed390..29280bd6e06 100644 --- a/spec/features/dashboard/groups_list_spec.rb +++ b/spec/features/dashboard/groups_list_spec.rb @@ -65,7 +65,11 @@ feature 'Dashboard Groups page', :js do fill_in 'filter', with: group.name wait_for_requests + expect(page).to have_content(group.name) + expect(page).not_to have_content(nested_group.parent.name) + fill_in 'filter', with: '' + page.find('[name="filter"]').send_keys(:enter) wait_for_requests expect(page).to have_content(group.name) diff --git a/spec/features/explore/groups_list_spec.rb b/spec/features/explore/groups_list_spec.rb index 801a33979ff..ad02b454aee 100644 --- a/spec/features/explore/groups_list_spec.rb +++ b/spec/features/explore/groups_list_spec.rb @@ -35,7 +35,11 @@ describe 'Explore Groups page', :js do fill_in 'filter', with: group.name wait_for_requests + expect(page).to have_content(group.full_name) + expect(page).not_to have_content(public_group.full_name) + fill_in 'filter', with: "" + page.find('[name="filter"]').send_keys(:enter) wait_for_requests expect(page).to have_content(group.full_name) -- cgit v1.2.1 From 69de7b42cf7d3f0c99d63f1778f7f0b9d15ddfd8 Mon Sep 17 00:00:00 2001 From: Ahmad Hassan Date: Wed, 13 Jun 2018 11:19:17 +0200 Subject: Migrate repo backup to gitaly --- GITALY_SERVER_VERSION | 2 +- Gemfile | 2 +- Gemfile.lock | 4 +- Gemfile.rails5.lock | 4 +- .../unreleased/use-backup-custom-hooks-gitaly.yml | 5 + lib/backup/repository.rb | 123 ++++++++++++++------- lib/gitlab/gitaly_client/repository_service.rb | 42 +++++-- 7 files changed, 122 insertions(+), 60 deletions(-) create mode 100644 changelogs/unreleased/use-backup-custom-hooks-gitaly.yml diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index c64d9d48a48..a9a7f3fec01 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -0.105.1 +0.107.0 diff --git a/Gemfile b/Gemfile index 98622cdde84..4bdb255c498 100644 --- a/Gemfile +++ b/Gemfile @@ -419,7 +419,7 @@ group :ed25519 do end # Gitaly GRPC client -gem 'gitaly-proto', '~> 0.101.0', require: 'gitaly' +gem 'gitaly-proto', '~> 0.102.0', require: 'gitaly' gem 'grpc', '~> 1.11.0' # Locked until https://github.com/google/protobuf/issues/4210 is closed diff --git a/Gemfile.lock b/Gemfile.lock index 883e580b86b..8d508cc0f39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -283,7 +283,7 @@ GEM gettext_i18n_rails (>= 0.7.1) po_to_json (>= 1.0.0) rails (>= 3.2.0) - gitaly-proto (0.101.0) + gitaly-proto (0.102.0) google-protobuf (~> 3.1) grpc (~> 1.10) github-linguist (5.3.3) @@ -1039,7 +1039,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.3) - gitaly-proto (~> 0.101.0) + gitaly-proto (~> 0.102.0) github-linguist (~> 5.3.3) gitlab-flowdock-git-hook (~> 1.0.1) gitlab-gollum-lib (~> 4.2) diff --git a/Gemfile.rails5.lock b/Gemfile.rails5.lock index 952e27df29d..bff1d0cba70 100644 --- a/Gemfile.rails5.lock +++ b/Gemfile.rails5.lock @@ -286,7 +286,7 @@ GEM gettext_i18n_rails (>= 0.7.1) po_to_json (>= 1.0.0) rails (>= 3.2.0) - gitaly-proto (0.101.0) + gitaly-proto (0.102.0) google-protobuf (~> 3.1) grpc (~> 1.10) github-linguist (5.3.3) @@ -1049,7 +1049,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.3) - gitaly-proto (~> 0.101.0) + gitaly-proto (~> 0.102.0) github-linguist (~> 5.3.3) gitlab-flowdock-git-hook (~> 1.0.1) gitlab-gollum-lib (~> 4.2) diff --git a/changelogs/unreleased/use-backup-custom-hooks-gitaly.yml b/changelogs/unreleased/use-backup-custom-hooks-gitaly.yml new file mode 100644 index 00000000000..4b9766332c3 --- /dev/null +++ b/changelogs/unreleased/use-backup-custom-hooks-gitaly.yml @@ -0,0 +1,5 @@ +--- +title: migrate backup rake task to gitaly +merge_request: +author: +type: added diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 0119c5d6851..127c2477810 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -16,64 +16,33 @@ module Backup prepare Project.find_each(batch_size: 1000) do |project| + # Create namespace dir or hashed path if missing progress.print " * #{display_repo_path(project)} ... " - path_to_project_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do - path_to_repo(project) - end - path_to_project_bundle = path_to_bundle(project) - - # Create namespace dir or hashed path if missing if project.hashed_storage?(:repository) FileUtils.mkdir_p(File.dirname(File.join(backup_repos_path, project.disk_path))) else FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.full_path)) if project.namespace end - if empty_repo?(project) - progress.puts "[SKIPPED]".color(:cyan) + if !empty_repo?(project) + backup_project(project) else - in_path(path_to_project_repo) do |dir| - FileUtils.mkdir_p(path_to_tars(project)) - cmd = %W(tar -cf #{path_to_tars(project, dir)} -C #{path_to_project_repo} #{dir}) - output, status = Gitlab::Popen.popen(cmd) - - unless status.zero? - progress_warn(project, cmd.join(' '), output) - end - end - - cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_project_repo} bundle create #{path_to_project_bundle} --all) - output, status = Gitlab::Popen.popen(cmd) - - if status.zero? - progress.puts "[DONE]".color(:green) - else - progress_warn(project, cmd.join(' '), output) - end + progress.puts "[SKIPPED]".color(:cyan) end wiki = ProjectWiki.new(project) path_to_wiki_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do path_to_repo(wiki) end - path_to_wiki_bundle = path_to_bundle(wiki) - if File.exist?(path_to_wiki_repo) - progress.print " * #{display_repo_path(wiki)} ... " - - if empty_repo?(wiki) - progress.puts " [SKIPPED]".color(:cyan) - else - cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_wiki_repo} bundle create #{path_to_wiki_bundle} --all) - output, status = Gitlab::Popen.popen(cmd) - if status.zero? - progress.puts " [DONE]".color(:green) - else - progress_warn(wiki, cmd.join(' '), output) - end - end + if File.exist?(path_to_wiki_repo) && !empty_repo?(wiki) + backup_project(wiki) + else + progress.puts "[SKIPPED] Wiki".color(:cyan) end + + progress.puts "[DONE]".color(:green) end end @@ -83,6 +52,40 @@ module Backup end end + def backup_project(project) + gitaly_migrate(:repository_backup) do |is_enabled| + if is_enabled + backup_project_gitaly(project) + else + backup_project_local(project) + end + end + rescue => e + progress_warn(project, e, 'Failed to backup repo') + end + + def backup_project_gitaly(project) + path_to_project_bundle = path_to_bundle(project) + Gitlab::GitalyClient::RepositoryService.new(project.repository) + .create_bundle(path_to_project_bundle) + + backup_custom_hooks(project) + end + + def backup_project_local(project) + path_to_project_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + path_to_repo(project) + end + + path_to_project_bundle = path_to_bundle(project) + + backup_custom_hooks(project) + + cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{path_to_project_repo} bundle create #{path_to_project_bundle} --all) + output, status = Gitlab::Popen.popen(cmd) + progress_warn(project, cmd.join(' '), output) unless status.zero? + end + def delete_all_repositories(name, repository_storage) gitaly_migrate(:delete_all_repositories) do |is_enabled| if is_enabled @@ -129,13 +132,47 @@ module Backup .restore_custom_hooks(custom_hooks_path) end + def local_backup_custom_hooks(project) + in_path(path_to_tars(project)) do |dir| + path_to_project_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do + path_to_repo(project) + end + break unless File.exist?(File.join(path_to_project_repo, dir)) + + FileUtils.mkdir_p(path_to_tars(project)) + cmd = %W(tar -cf #{path_to_tars(project, dir)} -c #{path_to_project_repo} #{dir}) + output, status = Gitlab::Popen.popen(cmd) + + unless status.zero? + progress_warn(project, cmd.join(' '), output) + end + end + end + + def gitaly_backup_custom_hooks(project) + FileUtils.mkdir_p(path_to_tars(project)) + custom_hooks_path = path_to_tars(project, 'custom_hooks') + Gitlab::GitalyClient::RepositoryService.new(project.repository) + .backup_custom_hooks(custom_hooks_path) + end + + def backup_custom_hooks(project) + gitaly_migrate(:backup_custom_hooks) do |is_enabled| + if is_enabled + gitaly_backup_custom_hooks(project) + else + local_backup_custom_hooks(project) + end + end + end + def restore_custom_hooks(project) in_path(path_to_tars(project)) do |dir| gitaly_migrate(:restore_custom_hooks) do |is_enabled| if is_enabled - local_restore_custom_hooks(project, dir) - else gitaly_restore_custom_hooks(project, dir) + else + local_restore_custom_hooks(project, dir) end end end diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb index 4340f779e53..ca986434221 100644 --- a/lib/gitlab/gitaly_client/repository_service.rb +++ b/lib/gitlab/gitaly_client/repository_service.rb @@ -196,20 +196,21 @@ module Gitlab end def create_bundle(save_path) - request = Gitaly::CreateBundleRequest.new(repository: @gitaly_repo) - response = GitalyClient.call( - @storage, - :repository_service, + gitaly_fetch_stream_to_file( + save_path, :create_bundle, - request, - timeout: GitalyClient.default_timeout + Gitaly::CreateBundleRequest, + GitalyClient.default_timeout ) + end - File.open(save_path, 'wb') do |f| - response.each do |message| - f.write(message.data) - end - end + def backup_custom_hooks(save_path) + gitaly_fetch_stream_to_file( + save_path, + :backup_custom_hooks, + Gitaly::BackupCustomHooksRequest, + GitalyClient.default_timeout + ) end def create_from_bundle(bundle_path) @@ -309,6 +310,25 @@ module Gitlab private + def gitaly_fetch_stream_to_file(save_path, rpc_name, request_class, timeout) + request = request_class.new(repository: @gitaly_repo) + response = GitalyClient.call( + @storage, + :repository_service, + rpc_name, + request, + timeout: timeout + ) + + File.open(save_path, 'wb') do |f| + response.each do |message| + f.write(message.data) + end + end + # If the file is empty means that we recieved an empty stream, we delete the file + FileUtils.rm(save_path) if File.zero?(save_path) + end + def gitaly_repo_stream_request(file_path, rpc_name, request_class, timeout) request = request_class.new(repository: @gitaly_repo) enum = Enumerator.new do |y| -- cgit v1.2.1 From 37bd3d44c6c985fc6e2a61488aadd31b01f36eb0 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 14 Jun 2018 15:30:40 -0500 Subject: Fix missing underline on focus states for anchor tags --- app/assets/stylesheets/bootstrap_migration.scss | 5 +++++ app/assets/stylesheets/framework/contextual_sidebar.scss | 1 + 2 files changed, 6 insertions(+) diff --git a/app/assets/stylesheets/bootstrap_migration.scss b/app/assets/stylesheets/bootstrap_migration.scss index 5da0e672288..cf952f026f5 100644 --- a/app/assets/stylesheets/bootstrap_migration.scss +++ b/app/assets/stylesheets/bootstrap_migration.scss @@ -89,6 +89,11 @@ a { color: $gl-link-color; } +a:not(.btn):focus, +a:not(.btn):active { + text-decoration: underline; +} + hr { overflow: hidden; } diff --git a/app/assets/stylesheets/framework/contextual_sidebar.scss b/app/assets/stylesheets/framework/contextual_sidebar.scss index 9cbaaa5dc8d..cccd1a6d942 100644 --- a/app/assets/stylesheets/framework/contextual_sidebar.scss +++ b/app/assets/stylesheets/framework/contextual_sidebar.scss @@ -193,6 +193,7 @@ &:focus { background: $link-active-background; color: $gl-text-color; + text-decoration: none; } } -- cgit v1.2.1 From a6312081d811d87ea2c3778c52acaa8476361eff Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Sat, 16 Jun 2018 13:59:26 +0200 Subject: use eslint config parameter instead of sed eslint has the possibility to ignore inline config `no-inline-config`, so we should use that --- .gitlab-ci.yml | 2 -- package.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7304b9c057..30c21b452e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -815,8 +815,6 @@ lint:javascript:report: - setup-test-env before_script: [] script: - - date - - find app/ spec/ -name '*.js' -exec sed --in-place 's|/\* eslint-disable .*\*/||' {} \; # run report over all files - date - yarn run eslint-report || true # ignore exit code artifacts: diff --git a/package.json b/package.json index 6a52af10dc3..cfe347c6eaa 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "dev-server": "nodemon -w 'config/webpack.config.js' --exec 'webpack-dev-server --config config/webpack.config.js'", "eslint": "eslint --max-warnings 0 --ext .js,.vue .", "eslint-fix": "eslint --max-warnings 0 --ext .js,.vue --fix .", - "eslint-report": "eslint --max-warnings 0 --ext .js,.vue --format html --output-file ./eslint-report.html .", + "eslint-report": "eslint --max-warnings 0 --ext .js,.vue --format html --output-file ./eslint-report.html --no-inline-config .", "karma": "BABEL_ENV=${BABEL_ENV:=karma} karma start --single-run true config/karma.config.js", "karma-coverage": "BABEL_ENV=coverage karma start --single-run true config/karma.config.js", "karma-start": "BABEL_ENV=karma karma start config/karma.config.js", -- cgit v1.2.1 From 07e95b0cd48192804324a3c47729b5641df54fe6 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 18 Jun 2018 12:02:56 +0200 Subject: Expose whether current user can push into a branch on branches API --- changelogs/unreleased/dm-branch-api-can-push.yml | 5 +++++ doc/api/branches.md | 11 ++++++++--- lib/api/entities.rb | 4 ++++ spec/fixtures/api/schemas/public_api/v4/branch.json | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/dm-branch-api-can-push.yml diff --git a/changelogs/unreleased/dm-branch-api-can-push.yml b/changelogs/unreleased/dm-branch-api-can-push.yml new file mode 100644 index 00000000000..3be8962089b --- /dev/null +++ b/changelogs/unreleased/dm-branch-api-can-push.yml @@ -0,0 +1,5 @@ +--- +title: Expose whether current user can push into a branch on branches API +merge_request: +author: +type: added diff --git a/doc/api/branches.md b/doc/api/branches.md index 01bb30c3859..bfb21608d28 100644 --- a/doc/api/branches.md +++ b/doc/api/branches.md @@ -29,6 +29,7 @@ Example response: "protected": true, "developers_can_push": false, "developers_can_merge": false, + "can_push": true, "commit": { "author_email": "john@example.com", "author_name": "John Smith", @@ -76,6 +77,7 @@ Example response: "protected": true, "developers_can_push": false, "developers_can_merge": false, + "can_push": true, "commit": { "author_email": "john@example.com", "author_name": "John Smith", @@ -140,7 +142,8 @@ Example response: "merged": false, "protected": true, "developers_can_push": true, - "developers_can_merge": true + "developers_can_merge": true, + "can_push": true } ``` @@ -188,7 +191,8 @@ Example response: "merged": false, "protected": false, "developers_can_push": false, - "developers_can_merge": false + "developers_can_merge": false, + "can_push": true } ``` @@ -231,7 +235,8 @@ Example response: "merged": false, "protected": false, "developers_can_push": false, - "developers_can_merge": false + "developers_can_merge": false, + "can_push": true } ``` diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 1cc8fcb8408..bb48a86fe9e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -349,6 +349,10 @@ module API expose :developers_can_merge do |repo_branch, options| options[:project].protected_branches.developers_can?(:merge, repo_branch.name) end + + expose :can_push do |repo_branch, options| + Gitlab::UserAccess.new(options[:current_user], project: options[:project]).can_push_to_branch?(repo_branch.name) + end end class TreeObject < Grape::Entity diff --git a/spec/fixtures/api/schemas/public_api/v4/branch.json b/spec/fixtures/api/schemas/public_api/v4/branch.json index a3581178974..a8891680d06 100644 --- a/spec/fixtures/api/schemas/public_api/v4/branch.json +++ b/spec/fixtures/api/schemas/public_api/v4/branch.json @@ -14,7 +14,8 @@ "merged": { "type": "boolean" }, "protected": { "type": "boolean" }, "developers_can_push": { "type": "boolean" }, - "developers_can_merge": { "type": "boolean" } + "developers_can_merge": { "type": "boolean" }, + "can_push": { "type": "boolean" } }, "additionalProperties": false } -- cgit v1.2.1 From acdc0d73274b80fb104eea73e86eb4b9f92c848d Mon Sep 17 00:00:00 2001 From: bikebilly Date: Mon, 18 Jun 2018 22:23:21 -0400 Subject: Change Milestone labels to Release Scoping labels --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dcdf520ee6b..6c46dc7ac73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ _This notice should stay as the first item in the CONTRIBUTING.md file._ - [Type labels (~"feature proposal", ~bug, ~customer, etc.)](#type-labels-feature-proposal-bug-customer-etc) - [Subject labels (~wiki, ~"container registry", ~ldap, ~api, etc.)](#subject-labels-wiki-container-registry-ldap-api-etc) - [Team labels (~"CI/CD", ~Discussion, ~Quality, ~Platform, etc.)](#team-labels-cicd-discussion-quality-platform-etc) - - [Milestone labels (~Deliverable, ~Stretch, ~"Next Patch Release")](#milestone-labels-deliverable-stretch-next-patch-release) + - [Release Scoping labels (~Deliverable, ~Stretch, ~"Next Patch Release")](#milestone-labels-deliverable-stretch-next-patch-release) - [Priority labels (~P1, ~P2, ~P3 , ~P4)](#bug-priority-labels-p1-p2-p3-p4) - [Severity labels (~S1, ~S2, ~S3 , ~S4)](#bug-severity-labels-s1-s2-s3-s4) - [Label for community contributors (~"Accepting Merge Requests")](#label-for-community-contributors-accepting-merge-requests) @@ -132,7 +132,7 @@ Most issues will have labels for at least one of the following: - Type: ~"feature proposal", ~bug, ~customer, etc. - Subject: ~wiki, ~"container registry", ~ldap, ~api, ~frontend, etc. - Team: ~"CI/CD", ~Discussion, ~Quality, ~Platform, etc. -- Milestone: ~Deliverable, ~Stretch, ~"Next Patch Release" +- Release Scoping: ~Deliverable, ~Stretch, ~"Next Patch Release" - Priority: ~P1, ~P2, ~P3, ~P4 - Severity: ~S1, ~S2, ~S3, ~S4 @@ -193,10 +193,10 @@ indicate if an issue needs backend work, frontend work, or both. Team labels are always capitalized so that they show up as the first label for any issue. -### Milestone labels (~Deliverable, ~Stretch, ~"Next Patch Release") +### Release Scoping labels (~Deliverable, ~Stretch, ~"Next Patch Release") -Milestone labels help us clearly communicate expectations of the work for the -release. There are three levels of Milestone labels: +Release Scoping labels help us clearly communicate expectations of the work for the +release. There are three levels of Release Scoping labels: - ~Deliverable: Issues that are expected to be delivered in the current milestone. -- cgit v1.2.1 From 17302f73bd2ee5758acc544eb516bc2c6e80d60d Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Tue, 19 Jun 2018 00:16:41 -0400 Subject: Clarify jupyterhub docs to indicate OAuth is enabled and HTTPS is not yet supported. --- doc/user/project/clusters/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/project/clusters/index.md b/doc/user/project/clusters/index.md index 48bb2e543c1..58a483bb3b2 100644 --- a/doc/user/project/clusters/index.md +++ b/doc/user/project/clusters/index.md @@ -156,7 +156,7 @@ added directly to your configured cluster. Those applications are needed for | [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) | 10.2+ | Ingress can provide load balancing, SSL termination, and name-based virtual hosting. It acts as a web proxy for your applications and is useful if you want to use [Auto DevOps] or deploy your own web apps. | | [Prometheus](https://prometheus.io/docs/introduction/overview/) | 10.4+ | Prometheus is an open-source monitoring and alerting system useful to supervise your deployed applications | | [GitLab Runner](https://docs.gitlab.com/runner/) | 10.6+ | GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with [GitLab CI/CD](https://about.gitlab.com/features/gitlab-ci-cd/), the open-source continuous integration service included with GitLab that coordinates the jobs. When installing the GitLab Runner via the applications, it will run in **privileged mode** by default. Make sure you read the [security implications](#security-implications) before doing so. | -| [JupyterHub](http://jupyter.org/) | 11.0+ | The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. | +| [JupyterHub](http://jupyter.org/) | 11.0+ | [JupyterHub](https://jupyterhub.readthedocs.io/en/stable/) is a multi-user service for managing notebooks across a team. [Jupyter Notebooks](https://jupyter-notebook.readthedocs.io/en/latest/) provide a web-based interactive programming environment used for data analysis, visualization, and machine learning. **Note**: Authentication will be enabled for any user of the GitLab server via OAuth2. HTTPS will be supported in a future release. | ## Getting the external IP address -- cgit v1.2.1 From 1ac7c52e0d05f7e2d504e2d08db682ec324c1691 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 19 Jun 2018 12:28:09 +0200 Subject: Use Go 1.10 for source installations --- doc/install/installation.md | 10 +++++----- doc/update/10.8-to-11.0.md | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 6cd1fb4c2d7..ef415246583 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -154,12 +154,12 @@ page](https://golang.org/dl). # Remove former Go installation folder sudo rm -rf /usr/local/go - - curl --remote-name --progress https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz - echo '1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772 go1.8.3.linux-amd64.tar.gz' | shasum -a256 -c - && \ - sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz + + curl --remote-name --progress https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz + echo 'fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035 go1.10.3.linux-amd64.tar.gz' | shasum -a256 -c - && \ + sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/ - rm go1.8.3.linux-amd64.tar.gz + rm go1.10.3.linux-amd64.tar.gz ## 4. Node diff --git a/doc/update/10.8-to-11.0.md b/doc/update/10.8-to-11.0.md index 78a47ab939f..f9b6044bd2f 100644 --- a/doc/update/10.8-to-11.0.md +++ b/doc/update/10.8-to-11.0.md @@ -81,8 +81,8 @@ More information can be found on the [yarn website](https://yarnpkg.com/en/docs/ ### 5. Update Go -NOTE: GitLab 9.2 and higher only supports Go 1.8.3 and dropped support for Go -1.5.x through 1.7.x. Be sure to upgrade your installation if necessary. +NOTE: GitLab 11.0 and higher only supports Go 1.9.x and newer, and dropped support for Go +1.5.x through 1.8.x. Be sure to upgrade your installation if necessary. You can check which version you are running with `go version`. @@ -92,11 +92,11 @@ Download and install Go: # Remove former Go installation folder sudo rm -rf /usr/local/go -curl --remote-name --progress https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz -echo '1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772 go1.8.3.linux-amd64.tar.gz' | shasum -a256 -c - && \ - sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz +curl --remote-name --progress https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz +echo 'fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f43004f901035 go1.10.3.linux-amd64.tar.gz' | shasum -a256 -c - && \ + sudo tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz sudo ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/ -rm go1.8.3.linux-amd64.tar.gz +rm go1.10.3.linux-amd64.tar.gz ``` ### 6. Get latest code -- cgit v1.2.1 From a1e1d64000da97cf61e9b3191c012ec213eb1812 Mon Sep 17 00:00:00 2001 From: Matthieu Fronton Date: Tue, 19 Jun 2018 12:53:00 +0000 Subject: Point out the specific anchor inside the document --- doc/user/project/integrations/microsoft_teams.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/user/project/integrations/microsoft_teams.md b/doc/user/project/integrations/microsoft_teams.md index eaad2d5138a..5cf80a298ad 100644 --- a/doc/user/project/integrations/microsoft_teams.md +++ b/doc/user/project/integrations/microsoft_teams.md @@ -2,7 +2,7 @@ ## On Microsoft Teams -To enable Microsoft Teams integration you must create an incoming webhook integration on Microsoft Teams by following the steps described in this [document](https://msdn.microsoft.com/en-us/microsoft-teams/connectors). +To enable Microsoft Teams integration you must create an incoming webhook integration on Microsoft Teams by following the steps described in this [document](https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/connectors#setting-up-a-custom-incoming-webhook). ## On GitLab -- cgit v1.2.1 From 5607c57c41a57cb6cbd8c2df90ad0cda6138964a Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Tue, 19 Jun 2018 18:39:47 +0530 Subject: Use gitaly to figure out git version for usage ping --- lib/gitlab/git/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/git/version.rb b/lib/gitlab/git/version.rb index 11184ca3457..1e14e8b652a 100644 --- a/lib/gitlab/git/version.rb +++ b/lib/gitlab/git/version.rb @@ -4,7 +4,7 @@ module Gitlab extend Gitlab::Git::Popen def self.git_version - Gitlab::VersionInfo.parse(popen(%W(#{Gitlab.config.git.bin_path} --version), nil).first) + Gitlab::VersionInfo.parse(Gitaly::Server.all.first.git_binary_version) end end end -- cgit v1.2.1 From 73be160cf1bc2d114a936841fb9c4b830fdf315f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 18 Jun 2018 16:41:20 +0200 Subject: Make Page::Main::Login#sign_in_using_credentials gracefully bail out when user is already logged-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- qa/qa/page/main/login.rb | 65 ++++++++++++++++++++++++++---------------------- qa/qa/page/menu/main.rb | 3 ++- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index 596205fe540..26c99efc53d 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -26,53 +26,58 @@ module QA end def initialize + # The login page is usually the entry point for all the scenarios so + # we need to wait for the instance to start. That said, in some cases + # we are already logged-in so we check both cases here. wait(max: 500) do - page.has_css?('.application') + page.has_css?('.login-page') || + Page::Menu::Main.act { has_personal_area? } end end - def set_initial_password_if_present - if page.has_content?('Change your password') - fill_in :user_password, with: Runtime::User.password - fill_in :user_password_confirmation, with: Runtime::User.password - click_button 'Change your password' + def sign_in_using_credentials + # Don't try to log-in if we're already logged-in + return if Page::Menu::Main.act { has_personal_area? } + + using_wait_time 0 do + set_initial_password_if_present + + if Runtime::User.ldap_user? + sign_in_using_ldap_credentials + else + sign_in_using_gitlab_credentials + end end end - def sign_in_using_credentials - if Runtime::User.ldap_user? - sign_in_using_ldap_credentials - else - sign_in_using_gitlab_credentials - end + def self.path + '/users/sign_in' end - def sign_in_using_ldap_credentials - using_wait_time 0 do - set_initial_password_if_present + private - click_link 'LDAP' + def sign_in_using_ldap_credentials + click_link 'LDAP' - fill_in :username, with: Runtime::User.ldap_username - fill_in :password, with: Runtime::User.ldap_password - click_button 'Sign in' - end + fill_in :username, with: Runtime::User.ldap_username + fill_in :password, with: Runtime::User.ldap_password + click_button 'Sign in' end def sign_in_using_gitlab_credentials - using_wait_time 0 do - set_initial_password_if_present - - click_link 'Standard' if page.has_content?('LDAP') + click_link 'Standard' if page.has_content?('LDAP') - fill_in :user_login, with: Runtime::User.name - fill_in :user_password, with: Runtime::User.password - click_button 'Sign in' - end + fill_in :user_login, with: Runtime::User.name + fill_in :user_password, with: Runtime::User.password + click_button 'Sign in' end - def self.path - '/users/sign_in' + def set_initial_password_if_present + return unless page.has_content?('Change your password') + + fill_in :user_password, with: Runtime::User.password + fill_in :user_password_confirmation, with: Runtime::User.password + click_button 'Change your password' end end end diff --git a/qa/qa/page/menu/main.rb b/qa/qa/page/menu/main.rb index 644fedecc90..fda9c45c091 100644 --- a/qa/qa/page/menu/main.rb +++ b/qa/qa/page/menu/main.rb @@ -55,7 +55,8 @@ module QA end def has_personal_area? - page.has_selector?('.qa-user-avatar') + # No need to wait, either we're logged-in, or not. + using_wait_time(0) { page.has_selector?('.qa-user-avatar') } end private -- cgit v1.2.1 From 64cda7746c08939306a6b98751d5a5c5280cc5b9 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Tue, 19 Jun 2018 15:57:27 +0200 Subject: LFS changes are detected by Gitaly Closes https://gitlab.com/gitlab-org/gitaly/issues/935 --- lib/gitlab/git/lfs_changes.rb | 60 ++------------------------------- spec/lib/gitlab/git/lfs_changes_spec.rb | 41 +++------------------- 2 files changed, 7 insertions(+), 94 deletions(-) diff --git a/lib/gitlab/git/lfs_changes.rb b/lib/gitlab/git/lfs_changes.rb index f3cc388ea41..f0fab1e76a3 100644 --- a/lib/gitlab/git/lfs_changes.rb +++ b/lib/gitlab/git/lfs_changes.rb @@ -7,67 +7,11 @@ module Gitlab end def new_pointers(object_limit: nil, not_in: nil) - @repository.gitaly_migrate(:blob_get_new_lfs_pointers) do |is_enabled| - if is_enabled - @repository.gitaly_blob_client.get_new_lfs_pointers(@newrev, object_limit, not_in) - else - git_new_pointers(object_limit, not_in) - end - end + @repository.gitaly_blob_client.get_new_lfs_pointers(@newrev, object_limit, not_in) end def all_pointers - @repository.gitaly_migrate(:blob_get_all_lfs_pointers) do |is_enabled| - if is_enabled - @repository.gitaly_blob_client.get_all_lfs_pointers(@newrev) - else - git_all_pointers - end - end - end - - private - - def git_new_pointers(object_limit, not_in) - @new_pointers ||= begin - rev_list.new_objects(rev_list_params(not_in: not_in)) do |object_ids| - object_ids = object_ids.take(object_limit) if object_limit - - Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) - end - end - end - - def git_all_pointers - params = {} - if rev_list_supports_new_options? - params[:options] = ["--filter=blob:limit=#{Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE}"] - end - - rev_list.all_objects(rev_list_params(params)) do |object_ids| - Gitlab::Git::Blob.batch_lfs_pointers(@repository, object_ids) - end - end - - def rev_list - Gitlab::Git::RevList.new(@repository, newrev: @newrev) - end - - # We're passing the `--in-commit-order` arg to ensure we don't wait - # for git to traverse all commits before returning pointers. - # This is required in order to improve the performance of LFS integrity check - def rev_list_params(params = {}) - params[:options] ||= [] - params[:options] << "--in-commit-order" if rev_list_supports_new_options? - params[:require_path] = true - - params - end - - def rev_list_supports_new_options? - return @option_supported if defined?(@option_supported) - - @option_supported = Gitlab::Git.version >= Gitlab::VersionInfo.parse('2.16.0') + @repository.gitaly_blob_client.get_all_lfs_pointers(@newrev) end end end diff --git a/spec/lib/gitlab/git/lfs_changes_spec.rb b/spec/lib/gitlab/git/lfs_changes_spec.rb index d0dd8c6303f..c5e7ab959b2 100644 --- a/spec/lib/gitlab/git/lfs_changes_spec.rb +++ b/spec/lib/gitlab/git/lfs_changes_spec.rb @@ -1,50 +1,19 @@ require 'spec_helper' describe Gitlab::Git::LfsChanges do - let(:project) { create(:project, :repository) } + set(:project) { create(:project, :repository) } let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' } let(:blob_object_id) { '0c304a93cb8430108629bbbcaa27db3343299bc0' } subject { described_class.new(project.repository, newrev) } describe '#new_pointers' do - shared_examples 'new pointers' do - it 'filters new objects to find lfs pointers' do - expect(subject.new_pointers(not_in: []).first.id).to eq(blob_object_id) - end - - it 'limits new_objects using object_limit' do - expect(subject.new_pointers(object_limit: 1)).to eq([]) - end - end - - context 'with gitaly enabled' do - it_behaves_like 'new pointers' + it 'filters new objects to find lfs pointers' do + expect(subject.new_pointers(not_in: []).first.id).to eq(blob_object_id) end - context 'with gitaly disabled', :skip_gitaly_mock do - it_behaves_like 'new pointers' - - it 'uses rev-list to find new objects' do - rev_list = double - allow(Gitlab::Git::RevList).to receive(:new).and_return(rev_list) - - expect(rev_list).to receive(:new_objects).and_return([]) - - subject.new_pointers - end - end - end - - describe '#all_pointers', :skip_gitaly_mock do - it 'uses rev-list to find all objects' do - rev_list = double - allow(Gitlab::Git::RevList).to receive(:new).and_return(rev_list) - allow(rev_list).to receive(:all_objects).and_yield([blob_object_id]) - - expect(Gitlab::Git::Blob).to receive(:batch_lfs_pointers).with(project.repository, [blob_object_id]) - - subject.all_pointers + it 'limits new_objects using object_limit' do + expect(subject.new_pointers(object_limit: 1)).to eq([]) end end end -- cgit v1.2.1 From 0cde6bb7a68a34c79bf0f641d7ccd425c4f49c34 Mon Sep 17 00:00:00 2001 From: George Tsiolis Date: Tue, 19 Jun 2018 17:17:12 +0300 Subject: Highlight cluster settings message --- app/views/projects/clusters/gcp/login.html.haml | 5 +++-- changelogs/unreleased/highlight-cluster-settings-message.yml | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/highlight-cluster-settings-message.yml diff --git a/app/views/projects/clusters/gcp/login.html.haml b/app/views/projects/clusters/gcp/login.html.haml index 55a42ac4847..96c7a648676 100644 --- a/app/views/projects/clusters/gcp/login.html.haml +++ b/app/views/projects/clusters/gcp/login.html.haml @@ -16,5 +16,6 @@ = _('or') = link_to('create a new Google account', 'https://accounts.google.com/SignUpWithoutGmail?service=cloudconsole&continue=https%3A%2F%2Fconsole.cloud.google.com%2Ffreetrial%3Futm_campaign%3D2018_cpanel%26utm_source%3Dgitlab%26utm_medium%3Dreferral', target: '_blank', rel: 'noopener noreferrer') - else - - link = link_to(s_('ClusterIntegration|properly configured'), help_page_path("integration/google"), target: '_blank', rel: 'noopener noreferrer') - = s_('Google authentication is not %{link_to_documentation}. Ask your GitLab administrator if you want to use this service.').html_safe % { link_to_documentation: link } + .settings-message.text-center + - link = link_to(s_('ClusterIntegration|properly configured'), help_page_path("integration/google"), target: '_blank', rel: 'noopener noreferrer') + = s_('Google authentication is not %{link_to_documentation}. Ask your GitLab administrator if you want to use this service.').html_safe % { link_to_documentation: link } diff --git a/changelogs/unreleased/highlight-cluster-settings-message.yml b/changelogs/unreleased/highlight-cluster-settings-message.yml new file mode 100644 index 00000000000..4e029941c51 --- /dev/null +++ b/changelogs/unreleased/highlight-cluster-settings-message.yml @@ -0,0 +1,5 @@ +--- +title: Highlight cluster settings message +merge_request: 19996 +author: George Tsiolis +type: changed -- cgit v1.2.1 From 5308b51ef43dceb3832edb4156bf3ece51099b67 Mon Sep 17 00:00:00 2001 From: Ahmad Hassan Date: Mon, 18 Jun 2018 16:42:39 +0200 Subject: Output done for wiki and repo --- lib/backup/repository.rb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 127c2477810..605a913cc6f 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -4,7 +4,6 @@ require_relative 'helper' module Backup class Repository include Backup::Helper - # rubocop:disable Metrics/AbcSize attr_reader :progress @@ -16,7 +15,6 @@ module Backup prepare Project.find_each(batch_size: 1000) do |project| - # Create namespace dir or hashed path if missing progress.print " * #{display_repo_path(project)} ... " if project.hashed_storage?(:repository) @@ -27,22 +25,19 @@ module Backup if !empty_repo?(project) backup_project(project) + progress.puts "[DONE]".color(:green) else progress.puts "[SKIPPED]".color(:cyan) end wiki = ProjectWiki.new(project) - path_to_wiki_repo = Gitlab::GitalyClient::StorageSettings.allow_disk_access do - path_to_repo(wiki) - end - if File.exist?(path_to_wiki_repo) && !empty_repo?(wiki) + if !empty_repo?(wiki) backup_project(wiki) + progress.puts "[DONE] Wiki".color(:green) else progress.puts "[SKIPPED] Wiki".color(:cyan) end - - progress.puts "[DONE]".color(:green) end end @@ -100,8 +95,6 @@ module Backup path = repository_storage.legacy_disk_path return unless File.exist?(path) - # Move all files in the existing repos directory except . and .. to - # repositories.old. directory bk_repos_path = File.join(Gitlab.config.backup.path, "tmp", "#{name}-repositories.old." + Time.now.to_i.to_s) FileUtils.mkdir_p(bk_repos_path, mode: 0700) files = Dir.glob(File.join(path, "*"), File::FNM_DOTMATCH) - [File.join(path, "."), File.join(path, "..")] @@ -223,7 +216,6 @@ module Backup end end end - # rubocop:enable Metrics/AbcSize protected @@ -261,9 +253,7 @@ module Backup def prepare FileUtils.rm_rf(backup_repos_path) - # Ensure the parent dir of backup_repos_path exists FileUtils.mkdir_p(Gitlab.config.backup.path) - # Fail if somebody raced to create backup_repos_path before us FileUtils.mkdir(backup_repos_path, mode: 0700) end @@ -279,7 +269,6 @@ module Backup end def empty_repo?(project_or_wiki) - # Protect against stale caches project_or_wiki.repository.expire_emptiness_caches project_or_wiki.repository.empty? end -- cgit v1.2.1 From 59b91de52de1e2cce416825887ec2f9ca8fe019b Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 18 Jun 2018 17:26:54 -0500 Subject: Fix cancel automatic merge button height --- app/assets/stylesheets/pages/merge_requests.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index 99fe4a578be..596d3aa171c 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -46,6 +46,7 @@ .btn { font-size: $gl-font-size; + max-height: 26px; &[disabled] { opacity: 0.3; -- cgit v1.2.1 From 9d5f5c43119197b9c522ae121af5564f43d06574 Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Tue, 19 Jun 2018 09:27:09 -0600 Subject: Fix redis_cacheable deserialization --- app/models/concerns/redis_cacheable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb index b5425295130..3bdc1330d23 100644 --- a/app/models/concerns/redis_cacheable.rb +++ b/app/models/concerns/redis_cacheable.rb @@ -48,7 +48,7 @@ module RedisCacheable def cast_value_from_cache(attribute, value) if Gitlab.rails5? - self.class.type_for_attribute(attribute).cast(value) + self.class.type_for_attribute(attribute.to_s).cast(value) else self.class.column_for_attribute(attribute).type_cast_from_database(value) end -- cgit v1.2.1 From 7357209f91ae4c0b504f47e36220bd04a0e2feca Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Wed, 6 Jun 2018 18:14:10 -0600 Subject: Implement filtering by filename on code search --- changelogs/unreleased/ce-5024-filename-search.yml | 5 +++ doc/api/search.md | 9 ++++ lib/gitlab/file_finder.rb | 17 ++++--- lib/gitlab/search/parsed_query.rb | 23 ++++++++++ lib/gitlab/search/query.rb | 55 +++++++++++++++++++++++ spec/lib/gitlab/file_finder_spec.rb | 20 ++++++++- spec/lib/gitlab/search/query_spec.rb | 39 ++++++++++++++++ spec/requests/api/search_spec.rb | 24 ++++++++++ 8 files changed, 186 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/ce-5024-filename-search.yml create mode 100644 lib/gitlab/search/parsed_query.rb create mode 100644 lib/gitlab/search/query.rb create mode 100644 spec/lib/gitlab/search/query_spec.rb diff --git a/changelogs/unreleased/ce-5024-filename-search.yml b/changelogs/unreleased/ce-5024-filename-search.yml new file mode 100644 index 00000000000..a8bf9b1f802 --- /dev/null +++ b/changelogs/unreleased/ce-5024-filename-search.yml @@ -0,0 +1,5 @@ +--- +title: Add filename filtering to code search +merge_request: 19509 +author: +type: added diff --git a/doc/api/search.md b/doc/api/search.md index 107ddaffa6a..9716f682ace 100644 --- a/doc/api/search.md +++ b/doc/api/search.md @@ -776,6 +776,15 @@ Example response: ### Scope: blobs +Filters are available for this scope: +- filename +- path +- extension + +to use a filter simply include it in your query like so: `a query filename:some_name*`. + +You may use wildcards (`*`) to use glob matching. + ```bash curl --request GET --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/6/search?scope=blobs&search=installation ``` diff --git a/lib/gitlab/file_finder.rb b/lib/gitlab/file_finder.rb index f42088f980e..af8270c8db8 100644 --- a/lib/gitlab/file_finder.rb +++ b/lib/gitlab/file_finder.rb @@ -14,14 +14,21 @@ module Gitlab end def find(query) - by_content = find_by_content(query) + query = Gitlab::Search::Query.new(query) do + filter :filename, matcher: ->(filter, blob) { blob.filename =~ /#{filter[:regex_value]}$/i } + filter :path, matcher: ->(filter, blob) { blob.filename =~ /#{filter[:regex_value]}/i } + filter :extension, matcher: ->(filter, blob) { blob.filename =~ /\.#{filter[:regex_value]}$/i } + end + + by_content = find_by_content(query.term) already_found = Set.new(by_content.map(&:filename)) - by_filename = find_by_filename(query, except: already_found) + by_filename = find_by_filename(query.term, except: already_found) + + files = (by_content + by_filename) + .sort_by(&:filename) - (by_content + by_filename) - .sort_by(&:filename) - .map { |blob| [blob.filename, blob] } + query.filter_results(files).map { |blob| [blob.filename, blob] } end private diff --git a/lib/gitlab/search/parsed_query.rb b/lib/gitlab/search/parsed_query.rb new file mode 100644 index 00000000000..23595f23f01 --- /dev/null +++ b/lib/gitlab/search/parsed_query.rb @@ -0,0 +1,23 @@ +module Gitlab + module Search + class ParsedQuery + attr_reader :term, :filters + + def initialize(term, filters) + @term = term + @filters = filters + end + + def filter_results(results) + filters = @filters.reject { |filter| filter[:matcher].nil? } + return unless filters + + results.select do |result| + filters.all? do |filter| + filter[:matcher].call(filter, result) + end + end + end + end + end +end diff --git a/lib/gitlab/search/query.rb b/lib/gitlab/search/query.rb new file mode 100644 index 00000000000..8583bce7792 --- /dev/null +++ b/lib/gitlab/search/query.rb @@ -0,0 +1,55 @@ +module Gitlab + module Search + class Query < SimpleDelegator + def initialize(query, filter_opts = {}, &block) + @raw_query = query.dup + @filters = [] + @filter_options = { default_parser: :downcase.to_proc }.merge(filter_opts) + + self.instance_eval(&block) if block_given? + + @query = Gitlab::Search::ParsedQuery.new(*extract_filters) + # set the ParsedQuery as our default delegator thanks to SimpleDelegator + super(@query) + end + + private + + def filter(name, **attributes) + filter = { parser: @filter_options[:default_parser], name: name }.merge(attributes) + + @filters << filter + end + + def filter_options(**options) + @filter_options.merge!(options) + end + + def extract_filters + fragments = [] + + filters = @filters.each_with_object([]) do |filter, parsed_filters| + match = @raw_query.split.find { |part| part =~ /\A#{filter[:name]}:/ } + next unless match + + input = match.split(':')[1..-1].join + next if input.empty? + + filter[:value] = parse_filter(filter, input) + filter[:regex_value] = Regexp.escape(filter[:value]).gsub('\*', '.*?') + fragments << match + + parsed_filters << filter + end + + query = (@raw_query.split - fragments).join(' ') + + [query, filters] + end + + def parse_filter(filter, input) + filter[:parser].call(input) + end + end + end +end diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index d6d9e4001a3..b49c5817131 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -3,11 +3,29 @@ require 'spec_helper' describe Gitlab::FileFinder do describe '#find' do let(:project) { create(:project, :public, :repository) } + subject { described_class.new(project, project.default_branch) } it_behaves_like 'file finder' do - subject { described_class.new(project, project.default_branch) } let(:expected_file_by_name) { 'files/images/wm.svg' } let(:expected_file_by_content) { 'CHANGELOG' } end + + it 'filters by name' do + results = subject.find('files filename:wm.svg') + + expect(results.count).to eq(1) + end + + it 'filters by path' do + results = subject.find('white path:images') + + expect(results.count).to eq(1) + end + + it 'filters by extension' do + results = subject.find('files extension:svg') + + expect(results.count).to eq(1) + end end end diff --git a/spec/lib/gitlab/search/query_spec.rb b/spec/lib/gitlab/search/query_spec.rb new file mode 100644 index 00000000000..2d00428fffa --- /dev/null +++ b/spec/lib/gitlab/search/query_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe Gitlab::Search::Query do + let(:query) { 'base filter:wow anotherfilter:noway name:maybe other:mmm leftover' } + let(:subject) do + described_class.new(query) do + filter :filter + filter :name, parser: :upcase.to_proc + filter :other + end + end + + it { expect(described_class).to be < SimpleDelegator } + + it 'leaves undefined filters in the main query' do + expect(subject.term).to eq('base anotherfilter:noway leftover') + end + + it 'parses filters' do + expect(subject.filters.count).to eq(3) + expect(subject.filters.map { |f| f[:value] }).to match_array(%w[wow MAYBE mmm]) + end + + context 'with an empty filter' do + let(:query) { 'some bar name: baz' } + + it 'ignores empty filters' do + expect(subject.term).to eq('some bar name: baz') + end + end + + context 'with a pipe' do + let(:query) { 'base | nofilter' } + + it 'does not escape the pipe' do + expect(subject.term).to eq(query) + end + end +end diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index aca4aa40027..f8e468be170 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -312,6 +312,30 @@ describe API::Search do end it_behaves_like 'response is correct', schema: 'public_api/v4/blobs', size: 2 + + context 'filters' do + it 'by filename' do + get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon filename:PROCESS.md' + + expect(response).to have_gitlab_http_status(200) + expect(json_response.size).to eq(2) + expect(json_response.first['filename']).to eq('PROCESS.md') + end + + it 'by path' do + get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon path:markdown' + + expect(response).to have_gitlab_http_status(200) + expect(json_response.size).to eq(8) + end + + it 'by extension' do + get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon extension:md' + + expect(response).to have_gitlab_http_status(200) + expect(json_response.size).to eq(11) + end + end end end end -- cgit v1.2.1 From 9a65af63e050ce1a44ef3c9feed35a4e1b96929d Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 19 Jun 2018 16:39:34 +0100 Subject: Add docs for the cleanup step of a background column type change A background column type change needs a cleanup step, like any background migration. We should call that out explicitly in the documentation. --- doc/development/what_requires_downtime.md | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/doc/development/what_requires_downtime.md b/doc/development/what_requires_downtime.md index b8be8daa157..f502866333e 100644 --- a/doc/development/what_requires_downtime.md +++ b/doc/development/what_requires_downtime.md @@ -252,6 +252,53 @@ Keep in mind that the relation passed to `change_column_type_using_background_migration` _must_ include `EachBatch`, otherwise it will raise a `TypeError`. +This migration then needs to be followed in a separate release (_not_ a patch +release) by a cleanup migration, which should steal from the queue and handle +any remaining rows. For example: + +```ruby +class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + class Issue < ActiveRecord::Base + self.table_name = 'issues' + include EachBatch + end + + def up + Gitlab::BackgroundMigration.steal('CopyColumn') + Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange') + + migrate_remaining_rows if migrate_column_type? + end + + def down + # Previous migrations already revert the changes made here. + end + + def migrate_remaining_rows + Issue.where('closed_at_for_type_change IS NULL AND closed_at IS NOT NULL').each_batch do |batch| + batch.update_all('closed_at_for_type_change = closed_at') + end + + cleanup_concurrent_column_type_change(:issues, :closed_at) + end + + def migrate_column_type? + # Some environments may have already executed the previous version of this + # migration, thus we don't need to migrate those environments again. + column_for('issues', 'closed_at').type == :datetime # rubocop:disable Migration/Datetime + end +end +``` + +For more information, see [the documentation on cleaning up background +migrations](background_migrations.md#cleaning-up). + ## Adding Indexes Adding indexes is an expensive process that blocks INSERT and UPDATE queries for -- cgit v1.2.1 From dea03a0815ddceeadbb809cd4ed94f6603e4c411 Mon Sep 17 00:00:00 2001 From: Constance Okoghenun Date: Tue, 19 Jun 2018 16:43:57 +0000 Subject: =?UTF-8?q?Resolve=20"Remove=20=E2=80=9Ccommented=E2=80=9D=20from?= =?UTF-8?q?=20comment=20system=20notes"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/notes/components/noteable_note.vue | 1 - app/views/shared/notes/_note.html.haml | 2 -- spec/javascripts/notes/components/noteable_note_spec.js | 1 - 3 files changed, 4 deletions(-) diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue index 713f93456b1..9225a6b1a7c 100644 --- a/app/assets/javascripts/notes/components/noteable_note.vue +++ b/app/assets/javascripts/notes/components/noteable_note.vue @@ -170,7 +170,6 @@ export default { :author="author" :created-at="note.created_at" :note-id="note.id" - action-text="commented" /> { it('should render note header content', () => { expect(vm.$el.querySelector('.note-header .note-header-author-name').textContent.trim()).toEqual(note.author.name); - expect(vm.$el.querySelector('.note-header .note-headline-meta').textContent.trim()).toContain('commented'); }); it('should render note actions', () => { -- cgit v1.2.1 From 9214e273a8759cbcd21ea1ef62fd9d594cec1e1d Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Tue, 19 Jun 2018 18:33:18 +0200 Subject: Rails5 fix expected: 1 time with arguments: (97, anything, {"squash"=>false}) received: 0 times --- changelogs/unreleased/rails5-fix-48104.yml | 6 ++++++ spec/controllers/projects/merge_requests_controller_spec.rb | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/rails5-fix-48104.yml diff --git a/changelogs/unreleased/rails5-fix-48104.yml b/changelogs/unreleased/rails5-fix-48104.yml new file mode 100644 index 00000000000..6cf519ad791 --- /dev/null +++ b/changelogs/unreleased/rails5-fix-48104.yml @@ -0,0 +1,6 @@ +--- +title: 'Rails5 fix expected: 1 time with arguments: (97, anything, {"squash"=>false}) + received: 0 times' +merge_request: 20004 +author: Jasper Maes +type: fixed diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index a412e74581d..7f5f0b76c51 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -337,7 +337,12 @@ describe Projects::MergeRequestsController do context 'when the sha parameter matches the source SHA' do def merge_with_sha(params = {}) - post :merge, base_params.merge(sha: merge_request.diff_head_sha).merge(params) + post_params = base_params.merge(sha: merge_request.diff_head_sha).merge(params) + if Gitlab.rails5? + post :merge, params: post_params, as: :json + else + post :merge, post_params + end end it 'returns :success' do -- cgit v1.2.1 From 73ade323c8993451199a965ec2330d9c7334c2e2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 19 Jun 2018 15:45:39 -0500 Subject: Make the stubbed methods for SAML authorize paths more specific Globally stubbing any instance of `Object` seems like a very bad idea, and it led to test failures here: - https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/76025159 - https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/76024972 --- spec/support/helpers/login_helpers.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb index f7b71bf42e3..329f18cd288 100644 --- a/spec/support/helpers/login_helpers.rb +++ b/spec/support/helpers/login_helpers.rb @@ -152,8 +152,13 @@ module LoginHelpers end def stub_saml_authorize_path_helpers - allow_any_instance_of(Object).to receive(:user_saml_omniauth_authorize_path).and_return('/users/auth/saml') - allow_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + allow_any_instance_of(ActionDispatch::Routing::RoutesProxy) + .to receive(:user_saml_omniauth_authorize_path) + .and_return('/users/auth/saml') + allow(Devise::OmniAuth::UrlHelpers) + .to receive(:omniauth_authorize_path) + .with(:user, "saml") + .and_return('/users/auth/saml') end def stub_omniauth_config(messages) -- cgit v1.2.1 From 74bb2e728b8daab4073d15370ecee32ed8458a02 Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Tue, 19 Jun 2018 22:47:58 +0200 Subject: Rails5 fix Projects::PagesController spec --- changelogs/unreleased/rails5-fix-pages-controller.yml | 5 +++++ spec/controllers/projects/pages_controller_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/rails5-fix-pages-controller.yml diff --git a/changelogs/unreleased/rails5-fix-pages-controller.yml b/changelogs/unreleased/rails5-fix-pages-controller.yml new file mode 100644 index 00000000000..eeb3747c4eb --- /dev/null +++ b/changelogs/unreleased/rails5-fix-pages-controller.yml @@ -0,0 +1,5 @@ +--- +title: Rails5 fix Projects::PagesController spec +merge_request: 20007 +author: Jasper Maes +type: fixed diff --git a/spec/controllers/projects/pages_controller_spec.rb b/spec/controllers/projects/pages_controller_spec.rb index 11f54eef531..8d2fa6a1740 100644 --- a/spec/controllers/projects/pages_controller_spec.rb +++ b/spec/controllers/projects/pages_controller_spec.rb @@ -71,7 +71,7 @@ describe Projects::PagesController do { namespace_id: project.namespace, project_id: project, - project: { pages_https_only: false } + project: { pages_https_only: 'false' } } end @@ -96,7 +96,7 @@ describe Projects::PagesController do it 'calls the update service' do expect(Projects::UpdateService) .to receive(:new) - .with(project, user, request_params[:project]) + .with(project, user, ActionController::Parameters.new(request_params[:project]).permit!) .and_return(update_service) patch :update, request_params -- cgit v1.2.1 From 3e3f527991eb53e91a618d6fa806b93617bbc68d Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Tue, 19 Jun 2018 21:22:31 +0000 Subject: Resolve "Branch name status color is not correct anymore" --- app/assets/javascripts/create_merge_request_dropdown.js | 8 ++++---- app/assets/stylesheets/framework/forms.scss | 4 ++++ app/views/projects/issues/_new_branch.html.haml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/create_merge_request_dropdown.js b/app/assets/javascripts/create_merge_request_dropdown.js index 108082799ef..f77a5730b77 100644 --- a/app/assets/javascripts/create_merge_request_dropdown.js +++ b/app/assets/javascripts/create_merge_request_dropdown.js @@ -366,7 +366,7 @@ export default class CreateMergeRequestDropdown { removeMessage(target) { const { input, message } = this.getTargetData(target); const inputClasses = ['gl-field-error-outline', 'gl-field-success-outline']; - const messageClasses = ['gl-field-hint', 'gl-field-error-message', 'gl-field-success-message']; + const messageClasses = ['text-muted', 'text-danger', 'text-success']; inputClasses.forEach(cssClass => input.classList.remove(cssClass)); messageClasses.forEach(cssClass => message.classList.remove(cssClass)); @@ -393,7 +393,7 @@ export default class CreateMergeRequestDropdown { this.removeMessage(target); input.classList.add('gl-field-success-outline'); - message.classList.add('gl-field-success-message'); + message.classList.add('text-success'); message.textContent = sprintf(__('%{text} is available'), { text }); message.style.display = 'inline-block'; } @@ -403,7 +403,7 @@ export default class CreateMergeRequestDropdown { const text = target === 'branch' ? __('branch name') : __('source'); this.removeMessage(target); - message.classList.add('gl-field-hint'); + message.classList.add('text-muted'); message.textContent = sprintf(__('Checking %{text} availability…'), { text }); message.style.display = 'inline-block'; } @@ -415,7 +415,7 @@ export default class CreateMergeRequestDropdown { this.removeMessage(target); input.classList.add('gl-field-error-outline'); - message.classList.add('gl-field-error-message'); + message.classList.add('text-danger'); message.textContent = text; message.style.display = 'inline-block'; } diff --git a/app/assets/stylesheets/framework/forms.scss b/app/assets/stylesheets/framework/forms.scss index 03520f42997..2b2e6d69e33 100644 --- a/app/assets/stylesheets/framework/forms.scss +++ b/app/assets/stylesheets/framework/forms.scss @@ -201,6 +201,10 @@ label { } .gl-show-field-errors { + .form-control { + height: 34px; + } + .gl-field-success-outline { border: 1px solid $green-600; diff --git a/app/views/projects/issues/_new_branch.html.haml b/app/views/projects/issues/_new_branch.html.haml index acb1a446ec4..a678cb6f058 100644 --- a/app/views/projects/issues/_new_branch.html.haml +++ b/app/views/projects/issues/_new_branch.html.haml @@ -40,7 +40,7 @@ %label{ for: 'new-branch-name' } = _('Branch name') %input#new-branch-name.js-branch-name.form-control{ type: 'text', placeholder: "#{@issue.to_branch_name}", value: "#{@issue.to_branch_name}" } - %span.js-branch-message.form-text.text-muted + %span.js-branch-message.form-text .form-group %label{ for: 'source-name' } -- cgit v1.2.1 From 76e8b82d9d59e940e733a811ef2875fcd7835760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=BCttemann?= Date: Wed, 20 Jun 2018 02:41:52 +0000 Subject: Correct cURL syntax --- doc/api/pages_domains.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/pages_domains.md b/doc/api/pages_domains.md index 20275b902c6..da2ffcfe40a 100644 --- a/doc/api/pages_domains.md +++ b/doc/api/pages_domains.md @@ -122,11 +122,11 @@ POST /projects/:id/pages/domains | `key` | file/string | no | The certificate key in PEM format. | ```bash -curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="domain=ssl.domain.example" --form="certificate=@/path/to/cert.pem" --form="key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "domain=ssl.domain.example" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains ``` ```bash -curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="domain=ssl.domain.example" --form="certificate=$CERT_PEM" --form="key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "domain=ssl.domain.example" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains ``` ```json @@ -158,11 +158,11 @@ PUT /projects/:id/pages/domains/:domain | `key` | file/string | no | The certificate key in PEM format. | ```bash -curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="certificate=@/path/to/cert.pem" --form="key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "certificate=@/path/to/cert.pem" --form "key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example ``` ```bash -curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="certificate=$CERT_PEM" --form="key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "certificate=$CERT_PEM" --form "key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example ``` ```json -- cgit v1.2.1 From d4f6e1f21c40c729d5ed3a3f02d6a84777a40163 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 20 Jun 2018 14:18:16 +1100 Subject: [Rails5] Fix ActionCable '/cable' mountpoint conflict Since Rails 5.0 the new framework has been added. It's called ActionCable. It brings WebSockets support to rails applications. By default the mountpoint of WebSocket requests is `/cable` [1]. GitLab allows using top level names as namespaces or usernames. For example, `gitlab.com/cable` at this moment leads to a user with the nickname `cable`. This commit changes ActionCable's mountpoint to a reserved top level word `-`. This is just a stub and should not be be used in real work. Please set correct mountpoints for each environments when configuring ActionCable for real using. [1]: https://github.com/rails/rails/blob/5-0-stable/actioncable/lib/action_cable.rb#L38 --- ...-that-could-cause-conflicts-with-existing-namespaced-routes.yml | 5 +++++ config/application.rb | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 changelogs/unreleased/blackst0ne-rails5-found-new-routes-that-could-cause-conflicts-with-existing-namespaced-routes.yml diff --git a/changelogs/unreleased/blackst0ne-rails5-found-new-routes-that-could-cause-conflicts-with-existing-namespaced-routes.yml b/changelogs/unreleased/blackst0ne-rails5-found-new-routes-that-could-cause-conflicts-with-existing-namespaced-routes.yml new file mode 100644 index 00000000000..c8d916af824 --- /dev/null +++ b/changelogs/unreleased/blackst0ne-rails5-found-new-routes-that-could-cause-conflicts-with-existing-namespaced-routes.yml @@ -0,0 +1,5 @@ +--- +title: "[Rails5] Fix ActionCable '/cable' mountpoint conflict" +merge_request: 20015 +author: "@blackst0ne" +type: fixed diff --git a/config/application.rb b/config/application.rb index 95f6d2c9af1..385eb65e7f4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,6 +57,13 @@ module Gitlab # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" + # ActionCable mount point. + # The default Rails' mount point is `/cable` which may conflict with existing + # namespaces/users. + # https://github.com/rails/rails/blob/5-0-stable/actioncable/lib/action_cable.rb#L38 + # Please change this value when configuring ActionCable for real usage. + config.action_cable.mount_path = "-" if rails5? + # Configure sensitive parameters which will be filtered from the log file. # # Parameters filtered: -- cgit v1.2.1 From 59154779d81c6359428af5f5cbdedbbd7ed32d5c Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 20 Jun 2018 12:34:58 +0900 Subject: The json keys of ref switcher should not be translated --- app/controllers/projects_controller.rb | 4 ++-- changelogs/unreleased/48100-fix-branch-not-shown.yml | 6 ++++++ spec/controllers/projects_controller_spec.rb | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/48100-fix-branch-not-shown.yml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a93b116c6fe..efb30ba4715 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -247,13 +247,13 @@ class ProjectsController < Projects::ApplicationController if find_branches branches = BranchesFinder.new(@repository, params).execute.take(100).map(&:name) - options[s_('RefSwitcher|Branches')] = branches + options['Branches'] = branches end if find_tags && @repository.tag_count.nonzero? tags = TagsFinder.new(@repository, params).execute.take(100).map(&:name) - options[s_('RefSwitcher|Tags')] = tags + options['Tags'] = tags end # If reference is commit id - we should add it to branch/tag selectbox diff --git a/changelogs/unreleased/48100-fix-branch-not-shown.yml b/changelogs/unreleased/48100-fix-branch-not-shown.yml new file mode 100644 index 00000000000..917c5c23f67 --- /dev/null +++ b/changelogs/unreleased/48100-fix-branch-not-shown.yml @@ -0,0 +1,6 @@ +--- +title: Fix branches are not shown in Merge Request dropdown when preferred language + is not English +merge_request: 20016 +author: Hiroyuki Sato +type: fixed diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 705b30f0130..90e698925b6 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -597,6 +597,22 @@ describe ProjectsController do expect(parsed_body["Tags"]).to include("v1.0.0") expect(parsed_body["Commits"]).to include("123456") end + + context "when preferred language is Japanese" do + before do + user.update!(preferred_language: 'ja') + sign_in(user) + end + + it "gets a list of branches, tags and commits" do + get :refs, namespace_id: public_project.namespace, id: public_project, ref: "123456" + + parsed_body = JSON.parse(response.body) + expect(parsed_body["Branches"]).to include("master") + expect(parsed_body["Tags"]).to include("v1.0.0") + expect(parsed_body["Commits"]).to include("123456") + end + end end describe 'POST #preview_markdown' do -- cgit v1.2.1 From e3046dcabe6d87eefd37ba124d42bcb721ec0a6c Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Wed, 20 Jun 2018 08:25:29 +0200 Subject: Rails5 fix Admin::HooksController --- app/controllers/admin/hooks_controller.rb | 2 +- changelogs/unreleased/rails5-fix-48142.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/rails5-fix-48142.yml diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb index 2b47819303e..fb788c47ef1 100644 --- a/app/controllers/admin/hooks_controller.rb +++ b/app/controllers/admin/hooks_controller.rb @@ -9,7 +9,7 @@ class Admin::HooksController < Admin::ApplicationController end def create - @hook = SystemHook.new(hook_params) + @hook = SystemHook.new(hook_params.to_h) if @hook.save redirect_to admin_hooks_path, notice: 'Hook was successfully created.' diff --git a/changelogs/unreleased/rails5-fix-48142.yml b/changelogs/unreleased/rails5-fix-48142.yml new file mode 100644 index 00000000000..bfd95cfbe8b --- /dev/null +++ b/changelogs/unreleased/rails5-fix-48142.yml @@ -0,0 +1,5 @@ +--- +title: Rails5 fix Admin::HooksController +merge_request: 20017 +author: Jasper Maes +type: fixed -- cgit v1.2.1 From 46b56b18f5bf94662a8500e2b8789f504b5d6ea8 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Tue, 19 Jun 2018 17:55:02 +0200 Subject: Move mergablility check to Gitaly Closes https://gitlab.com/gitlab-org/gitaly/issues/889 --- app/models/repository.rb | 2 +- lib/gitlab/git/repository.rb | 17 ++-------------- spec/models/repository_spec.rb | 46 +++++++++++++++++------------------------- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index e4202505634..de889d18729 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -847,7 +847,7 @@ class Repository @root_ref_sha ||= commit(root_ref).sha end - delegate :merged_branch_names, :can_be_merged?, to: :raw_repository + delegate :merged_branch_names, to: :raw_repository def merge_base(first_commit_id, second_commit_id) first_commit_id = commit(first_commit_id).try(:id) || first_commit_id diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index ab0e6e33db7..7af40e62395 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -1413,13 +1413,8 @@ module Gitlab end def can_be_merged?(source_sha, target_branch) - gitaly_migrate(:can_be_merged) do |is_enabled| - if is_enabled - gitaly_can_be_merged?(source_sha, find_branch(target_branch, true).target) - else - rugged_can_be_merged?(source_sha, target_branch) - end - end + target_sha = find_branch(target_branch, true).target + !gitaly_conflicts_client(source_sha, target_sha).conflicts? end def search_files_by_name(query, ref) @@ -2236,14 +2231,6 @@ module Gitlab run_git(['fetch', remote_name], env: env).last.zero? end - def gitaly_can_be_merged?(their_commit, our_commit) - !gitaly_conflicts_client(our_commit, their_commit).conflicts? - end - - def rugged_can_be_merged?(their_commit, our_commit) - !rugged.merge_commits(our_commit, their_commit).conflicts? - end - def gitlab_projects_error raise CommandError, @gitlab_projects.output end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index b6df048d4ca..d817a8376f4 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -434,44 +434,34 @@ describe Repository do end describe '#can_be_merged?' do - shared_examples 'can be merged' do - context 'mergeable branches' do - subject { repository.can_be_merged?('0b4bc9a49b562e85de7cc9e834518ea6828729b9', 'master') } + context 'mergeable branches' do + subject { repository.can_be_merged?('0b4bc9a49b562e85de7cc9e834518ea6828729b9', 'master') } - it { is_expected.to be_truthy } - end - - context 'non-mergeable branches without conflict sides missing' do - subject { repository.can_be_merged?('bb5206fee213d983da88c47f9cf4cc6caf9c66dc', 'feature') } - - it { is_expected.to be_falsey } - end + it { is_expected.to be_truthy } + end - context 'non-mergeable branches with conflict sides missing' do - subject { repository.can_be_merged?('conflict-missing-side', 'conflict-start') } + context 'non-mergeable branches without conflict sides missing' do + subject { repository.can_be_merged?('bb5206fee213d983da88c47f9cf4cc6caf9c66dc', 'feature') } - it { is_expected.to be_falsey } - end + it { is_expected.to be_falsey } + end - context 'non merged branch' do - subject { repository.merged_to_root_ref?('fix') } + context 'non-mergeable branches with conflict sides missing' do + subject { repository.can_be_merged?('conflict-missing-side', 'conflict-start') } - it { is_expected.to be_falsey } - end + it { is_expected.to be_falsey } + end - context 'non existent branch' do - subject { repository.merged_to_root_ref?('non_existent_branch') } + context 'non merged branch' do + subject { repository.merged_to_root_ref?('fix') } - it { is_expected.to be_nil } - end + it { is_expected.to be_falsey } end - context 'when Gitaly can_be_merged feature is enabled' do - it_behaves_like 'can be merged' - end + context 'non existent branch' do + subject { repository.merged_to_root_ref?('non_existent_branch') } - context 'when Gitaly can_be_merged feature is disabled', :disable_gitaly do - it_behaves_like 'can be merged' + it { is_expected.to be_nil } end end -- cgit v1.2.1 From 3df04bd17fe3823dfd178edfce2e4bc1e3c48e24 Mon Sep 17 00:00:00 2001 From: Constance Okoghenun Date: Wed, 20 Jun 2018 07:36:50 +0000 Subject: Updated horizontal ellipsis icon for text-expander --- .../javascripts/vue_shared/components/expand_button.vue | 13 ++++++++++++- app/assets/stylesheets/pages/commits.scss | 10 +++++++--- app/views/projects/commits/_commit.html.haml | 3 ++- app/views/projects/pipelines/_info.html.haml | 2 +- changelogs/unreleased/text-expander-icon-update.yml | 5 +++++ .../javascripts/vue_shared/components/expand_button_spec.js | 2 +- 6 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/text-expander-icon-update.yml diff --git a/app/assets/javascripts/vue_shared/components/expand_button.vue b/app/assets/javascripts/vue_shared/components/expand_button.vue index 0fdea651130..e6e92594b65 100644 --- a/app/assets/javascripts/vue_shared/components/expand_button.vue +++ b/app/assets/javascripts/vue_shared/components/expand_button.vue @@ -1,5 +1,7 @@