From 7a1c5ba7471b233c994f5b5b313085d0d1292b5d Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 28 Apr 2017 08:56:04 +1100 Subject: Add index on ci_runners.contacted_at --- .../add_index_on_ci_runners_contacted_at.yml | 4 ++++ ...0426181740_add_index_on_ci_runners_contacted_at.rb | 19 +++++++++++++++++++ db/schema.rb | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml create mode 100644 db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb diff --git a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml new file mode 100644 index 00000000000..10c3206c2ff --- /dev/null +++ b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml @@ -0,0 +1,4 @@ +--- +title: Add index on ci_runners.contacted_at +merge_request: 10876 +author: blackst0ne diff --git a/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb b/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb new file mode 100644 index 00000000000..879825a1934 --- /dev/null +++ b/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb @@ -0,0 +1,19 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexOnCiRunnersContactedAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_runners, :contacted_at + end + + def down + remove_concurrent_index :ci_runners, :contacted_at if index_exists?(:ci_runners, :contacted_at) + end +end diff --git a/db/schema.rb b/db/schema.rb index 49d7c996661..a615a078e49 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426175636) do +ActiveRecord::Schema.define(version: 20170425101740) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -296,6 +296,7 @@ ActiveRecord::Schema.define(version: 20170426175636) do t.boolean "locked", default: false, null: false end + add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree add_index "ci_runners", ["token"], name: "index_ci_runners_on_token", using: :btree -- cgit v1.2.1 From df948f8ac21568eac0cef059c2e96d009d702cc2 Mon Sep 17 00:00:00 2001 From: haseeb Date: Sun, 13 Aug 2017 12:58:19 +0530 Subject: fix Merge request reference in merge commit is not global --- app/models/merge_request.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index f90194041b1..de0d541f1c7 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -682,9 +682,9 @@ class MergeRequest < ActiveRecord::Base if !include_description && closes_issues_references.present? message << "Closes #{closes_issues_references.to_sentence}" end - + message << "#{description}" if include_description && description.present? - message << "See merge request #{to_reference}" + message << "See merge request #{to_reference(full: true)}" message.join("\n\n") end -- cgit v1.2.1 From f2251d1978a7fc8bad7ebb3766ed97d05e5f49e9 Mon Sep 17 00:00:00 2001 From: haseeb Date: Sun, 13 Aug 2017 18:09:30 +0530 Subject: fixes failing tests for full reference change --- spec/features/merge_requests/merge_commit_message_toggle_spec.rb | 4 ++-- spec/models/merge_request_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb index 429bc277d73..08a3bb84aac 100644 --- a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb +++ b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb @@ -19,7 +19,7 @@ feature 'Clicking toggle commit message link', js: true do "Merge branch 'feature' into 'master'", merge_request.title, "Closes #{issue_1.to_reference} and #{issue_2.to_reference}", - "See merge request #{merge_request.to_reference}" + "See merge request #{merge_request.to_reference(full: true)}" ].join("\n\n") end let(:message_with_description) do @@ -27,7 +27,7 @@ feature 'Clicking toggle commit message link', js: true do "Merge branch 'feature' into 'master'", merge_request.title, merge_request.description, - "See merge request #{merge_request.to_reference}" + "See merge request #{merge_request.to_reference(full: true)}" ].join("\n\n") end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 026bdbd26d1..e2b0d9ab005 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -604,7 +604,7 @@ describe MergeRequest do request = build_stubbed(:merge_request) expect(request.merge_commit_message) - .to match("See merge request #{request.to_reference}") + .to match("See merge request #{request.to_reference(full: true)}") end it 'excludes multiple linebreak runs when description is blank' do -- cgit v1.2.1 From 725a4fef5aeea02bea3f943133d075177424117d Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 9 Aug 2017 09:24:48 -0400 Subject: Add thenable ajax calls. --- app/assets/javascripts/api.js | 6 ++---- app/assets/javascripts/repo/components/repo_commit_section.vue | 5 +++-- app/assets/javascripts/repo/services/repo_service.js | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 56f91e95bb9..28119362455 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -99,15 +99,13 @@ const Api = { commitMultiple(id, data, callback) { const url = Api.buildUrl(Api.commitPath) .replace(':id', id); - return $.ajax({ + return this.wrapAjaxCall({ url, type: 'POST', contentType: 'application/json; charset=utf-8', data: JSON.stringify(data), dataType: 'json', - }) - .done(commitData => callback(commitData)) - .fail(message => callback(message.responseJSON)); + }); }, // Return text for a specific license diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue index 5ec4a9b6593..d06cdf2cbc2 100644 --- a/app/assets/javascripts/repo/components/repo_commit_section.vue +++ b/app/assets/javascripts/repo/components/repo_commit_section.vue @@ -42,10 +42,11 @@ export default { actions, }; Store.submitCommitsLoading = true; - Service.commitFiles(payload, this.resetCommitState); + Service.commitFiles(payload) + .then(this.resetCommitState); }, - resetCommitState() { + resetCommitState(data) { this.submitCommitsLoading = false; this.changedFiles = []; this.commitMessage = ''; diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js index 3cf204e6ec8..310c03fc019 100644 --- a/app/assets/javascripts/repo/services/repo_service.js +++ b/app/assets/javascripts/repo/services/repo_service.js @@ -65,14 +65,14 @@ const RepoService = { return urlArray.join('/'); }, - commitFiles(payload, cb) { - Api.commitMultiple(Store.projectId, payload, (data) => { + commitFiles(payload) { + return Api.commitMultiple(Store.projectId, payload) + .then((data) => { if (data.short_id && data.stats) { Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); } else { Flash(data.message); } - cb(); }); }, }; -- cgit v1.2.1 From cdd741ee22b3d02ea75fa4021497f80867c09f39 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 17 Aug 2017 13:05:09 -0500 Subject: fix eslint violations in repo editor files --- app/assets/javascripts/api.js | 3 ++- .../javascripts/repo/components/repo_commit_section.vue | 5 +++-- app/assets/javascripts/repo/services/repo_service.js | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 28119362455..4319bfcc57f 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -96,7 +96,8 @@ const Api = { .done(projects => callback(projects)); }, - commitMultiple(id, data, callback) { + commitMultiple(id, data) { + // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions const url = Api.buildUrl(Api.commitPath) .replace(':id', id); return this.wrapAjaxCall({ diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue index d06cdf2cbc2..1282828b504 100644 --- a/app/assets/javascripts/repo/components/repo_commit_section.vue +++ b/app/assets/javascripts/repo/components/repo_commit_section.vue @@ -43,10 +43,11 @@ export default { }; Store.submitCommitsLoading = true; Service.commitFiles(payload) - .then(this.resetCommitState); + .then(this.resetCommitState) + .catch(() => Flash('An error occured while committing your changes')); }, - resetCommitState(data) { + resetCommitState() { this.submitCommitsLoading = false; this.changedFiles = []; this.commitMessage = ''; diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js index 310c03fc019..a8a4b419ae8 100644 --- a/app/assets/javascripts/repo/services/repo_service.js +++ b/app/assets/javascripts/repo/services/repo_service.js @@ -67,13 +67,13 @@ const RepoService = { commitFiles(payload) { return Api.commitMultiple(Store.projectId, payload) - .then((data) => { - if (data.short_id && data.stats) { - Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); - } else { - Flash(data.message); - } - }); + .then((data) => { + if (data.short_id && data.stats) { + Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); + } else { + Flash(data.message); + } + }); }, }; -- cgit v1.2.1 From 597f9c12bbd9954f5a8b2580cfa34a3afcd31d86 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 18 Aug 2017 16:42:52 +1100 Subject: Use full path of project's avatar in webhooks --- app/models/project.rb | 2 +- .../unreleased/use_full_path_in_project_avatar_url_webhook.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/use_full_path_in_project_avatar_url_webhook.yml diff --git a/app/models/project.rb b/app/models/project.rb index be248bc99e1..e0085302867 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1009,7 +1009,7 @@ class Project < ActiveRecord::Base name: name, description: description, web_url: web_url, - avatar_url: avatar_url, + avatar_url: avatar_url(only_path: false), git_ssh_url: ssh_url_to_repo, git_http_url: http_url_to_repo, namespace: namespace.name, diff --git a/changelogs/unreleased/use_full_path_in_project_avatar_url_webhook.yml b/changelogs/unreleased/use_full_path_in_project_avatar_url_webhook.yml new file mode 100644 index 00000000000..0c3acce1455 --- /dev/null +++ b/changelogs/unreleased/use_full_path_in_project_avatar_url_webhook.yml @@ -0,0 +1,5 @@ +--- +title: Use full path of project's avatar in webhooks +merge_request: 13649 +author: Vitaliy @blackst0ne Klachkov +type: changed -- cgit v1.2.1 From d515ec4df908fc65496904f4705ae903db54b6a8 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 18 Aug 2017 09:54:53 +0100 Subject: Fixes the breadcrumb container when in issue boards Closes #36561 --- app/views/layouts/nav/_breadcrumbs.html.haml | 3 ++- app/views/projects/boards/_show.html.haml | 1 + changelogs/unreleased/issue-boards-breadcrumbs-container.yml | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/issue-boards-breadcrumbs-container.yml diff --git a/app/views/layouts/nav/_breadcrumbs.html.haml b/app/views/layouts/nav/_breadcrumbs.html.haml index 4db84771f4e..653452871a0 100644 --- a/app/views/layouts/nav/_breadcrumbs.html.haml +++ b/app/views/layouts/nav/_breadcrumbs.html.haml @@ -1,8 +1,9 @@ - breadcrumb_link = breadcrumb_title_link +- container = @no_breadcrumb_container ? 'container-fluid' : container_class - hide_top_links = @hide_top_links || false %nav.breadcrumbs{ role: "navigation" } - .breadcrumbs-container{ class: [container_class, @content_class] } + .breadcrumbs-container{ class: [container, @content_class] } - if defined?(@new_sidebar) = button_tag class: 'toggle-mobile-nav', type: 'button' do %span.sr-only Open sidebar diff --git a/app/views/projects/boards/_show.html.haml b/app/views/projects/boards/_show.html.haml index 2076e46fde8..5354ec8522e 100644 --- a/app/views/projects/boards/_show.html.haml +++ b/app/views/projects/boards/_show.html.haml @@ -1,3 +1,4 @@ +- @no_breadcrumb_container = true - @no_container = true - @content_class = "issue-boards-content" - page_title "Boards" diff --git a/changelogs/unreleased/issue-boards-breadcrumbs-container.yml b/changelogs/unreleased/issue-boards-breadcrumbs-container.yml new file mode 100644 index 00000000000..5e042de7000 --- /dev/null +++ b/changelogs/unreleased/issue-boards-breadcrumbs-container.yml @@ -0,0 +1,5 @@ +--- +title: Fix breadcrumbs container in issue boards +merge_request: +author: +type: fixed -- cgit v1.2.1 From 43dea824c1a0d0306714d691bb88ce3490adcae6 Mon Sep 17 00:00:00 2001 From: Marcia Ramos Date: Fri, 18 Aug 2017 16:44:28 -0300 Subject: use inline links instead of referenced --- doc/development/doc_styleguide.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/doc/development/doc_styleguide.md b/doc/development/doc_styleguide.md index 90d1d9657b9..798f40eef3d 100644 --- a/doc/development/doc_styleguide.md +++ b/doc/development/doc_styleguide.md @@ -113,13 +113,12 @@ merge request. ## Links -- If a link makes the paragraph to span across multiple lines, do not use - the regular Markdown approach: `[Text](https://example.com)`. Instead use - `[Text][identifier]` and at the very bottom of the document add: - `[identifier]: https://example.com`. This is another way to create Markdown - links which keeps the document clear and concise. Bonus points if you also - add an alternative text: `[identifier]: https://example.com "Alternative text"` - that appears when hovering your mouse on a link +- Use the regular inline link markdown markup `[Text](https://example.com)`. + It's easier to read, review, and maintain. +- If there's a link that repeats several times through the same document, + you can use `[Text][identifier]` and at the bottom of the section or the + document add: `[identifier]: https://example.com`, in which case, we do + encourage you to also add an alternative text: `[identifier]: https://example.com "Alternative text"` that appears when hovering your mouse on a link. ### Linking to inline docs -- cgit v1.2.1 From ffca8c1c3794d1e51ffee1c52c55c57c1e53c621 Mon Sep 17 00:00:00 2001 From: Marcia Ramos Date: Fri, 18 Aug 2017 16:44:51 -0300 Subject: Indexes GFM markdown guide --- doc/user/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/user/index.md b/doc/user/index.md index d664fd62754..0892db14900 100644 --- a/doc/user/index.md +++ b/doc/user/index.md @@ -119,6 +119,13 @@ When performing inline reviews to implementations to your codebase through merge requests you can gather feedback through [resolvable discussions](discussions/index.md#resolvable-discussions). +### GitLab Flavored Markdown (GFM) + +Read through the [GFM documentation](markdown.md) to learn how to apply +the best of GitLab Flavored Markdown in your discussions, comments, +issues and merge requests descriptions, and everywhere else GMF is +supported. + ## Todos Never forget to reply to your collaborators. [GitLab Todos](../workflow/todos.md) -- cgit v1.2.1 From d9c6bb0d34b96ffb78b9e65b5b2110b752cf5a55 Mon Sep 17 00:00:00 2001 From: Bryce Johnson Date: Fri, 18 Aug 2017 17:09:13 -0400 Subject: Move ConvDev index to Overview from Monitoring. --- app/views/admin/dashboard/_head.html.haml | 4 ++++ app/views/admin/monitoring/_head.html.haml | 4 ---- app/views/layouts/nav/_new_admin_sidebar.html.haml | 8 ++++---- .../34413-move-convdev-index-location-to-after-cohorts.yml | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/34413-move-convdev-index-location-to-after-cohorts.yml diff --git a/app/views/admin/dashboard/_head.html.haml b/app/views/admin/dashboard/_head.html.haml index dff549f502c..c2151710884 100644 --- a/app/views/admin/dashboard/_head.html.haml +++ b/app/views/admin/dashboard/_head.html.haml @@ -31,3 +31,7 @@ = link_to admin_cohorts_path, title: 'Cohorts' do %span Cohorts + = nav_link(controller: :conversational_development_index) do + = link_to admin_conversational_development_index_path, title: 'ConvDev Index' do + %span + ConvDev Index diff --git a/app/views/admin/monitoring/_head.html.haml b/app/views/admin/monitoring/_head.html.haml index 901e30275fd..b3530915068 100644 --- a/app/views/admin/monitoring/_head.html.haml +++ b/app/views/admin/monitoring/_head.html.haml @@ -3,10 +3,6 @@ = render 'shared/nav_scroll' .nav-links.sub-nav.scrolling-tabs %ul{ class: (container_class) } - = nav_link(controller: :conversational_development_index) do - = link_to admin_conversational_development_index_path, title: 'ConvDev Index' do - %span - ConvDev Index = nav_link(controller: :system_info) do = link_to admin_system_info_path, title: 'System Info' do %span diff --git a/app/views/layouts/nav/_new_admin_sidebar.html.haml b/app/views/layouts/nav/_new_admin_sidebar.html.haml index 3cbcd841aff..424d084f0fe 100644 --- a/app/views/layouts/nav/_new_admin_sidebar.html.haml +++ b/app/views/layouts/nav/_new_admin_sidebar.html.haml @@ -42,6 +42,10 @@ = link_to admin_cohorts_path, title: 'Cohorts' do %span Cohorts + = nav_link(controller: :conversational_development_index) do + = link_to admin_conversational_development_index_path, title: 'ConvDev Index' do + %span + ConvDev Index = nav_link(controller: %w(conversational_development_index system_info background_jobs logs health_check requests_profiles)) do = link_to admin_conversational_development_index_path, title: 'Monitoring' do @@ -51,10 +55,6 @@ Monitoring %ul.sidebar-sub-level-items - = nav_link(controller: :conversational_development_index) do - = link_to admin_conversational_development_index_path, title: 'ConvDev Index' do - %span - ConvDev Index = nav_link(controller: :system_info) do = link_to admin_system_info_path, title: 'System Info' do %span diff --git a/changelogs/unreleased/34413-move-convdev-index-location-to-after-cohorts.yml b/changelogs/unreleased/34413-move-convdev-index-location-to-after-cohorts.yml new file mode 100644 index 00000000000..d33b55ef681 --- /dev/null +++ b/changelogs/unreleased/34413-move-convdev-index-location-to-after-cohorts.yml @@ -0,0 +1,4 @@ +--- +title: Move ConvDev Index location to after Cohorts. +merge_request: !13398 +author: -- cgit v1.2.1 From c5b3632f904744dd23d8079caaf44fa3b24e7e1b Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Fri, 18 Aug 2017 16:53:00 -0500 Subject: fix failing specs in repo_commit_section_spec.js --- spec/javascripts/repo/components/repo_commit_section_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/javascripts/repo/components/repo_commit_section_spec.js b/spec/javascripts/repo/components/repo_commit_section_spec.js index 249a2f36fcd..6f6faf5422b 100644 --- a/spec/javascripts/repo/components/repo_commit_section_spec.js +++ b/spec/javascripts/repo/components/repo_commit_section_spec.js @@ -111,7 +111,7 @@ describe('RepoCommitSection', () => { expect(submitCommit.disabled).toBeFalsy(); spyOn(vm, 'makeCommit').and.callThrough(); - spyOn(Api, 'commitMultiple'); + spyOn(Api, 'commitMultiple').and.callFake(() => Promise.resolve()); submitCommit.click(); -- cgit v1.2.1 From 05147e209e8eef7aa817d992c87956220ae14943 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Sat, 19 Aug 2017 23:12:05 +0900 Subject: Add filtered search to group merge requests dashboard --- app/assets/javascripts/dispatcher.js | 4 ++-- app/views/groups/merge_requests.html.haml | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index 2bba7f55de1..b71c449090e 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -184,13 +184,13 @@ import initChangesDropdown from './init_changes_dropdown'; break; case 'dashboard:issues': case 'dashboard:merge_requests': - case 'groups:merge_requests': new ProjectSelect(); initLegacyFilters(); break; case 'groups:issues': + case 'groups:merge_requests': if (filteredSearchEnabled) { - const filteredSearchManager = new gl.FilteredSearchManager('issues'); + const filteredSearchManager = new gl.FilteredSearchManager(page === 'groups:issues' ? 'issues' : 'merge_requests'); filteredSearchManager.setup(); } new ProjectSelect(); diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index 997c82c77d9..ad5ab4b5d87 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -1,5 +1,9 @@ - page_title "Merge Requests" +- content_for :page_specific_javascripts do + = webpack_bundle_tag 'common_vue' + = webpack_bundle_tag 'filtered_search' + - if show_new_nav? && current_user - content_for :breadcrumbs_extra do = render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request" @@ -13,7 +17,7 @@ .nav-controls{ class: ("visible-xs" if show_new_nav?) } = render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request" - = render 'shared/issuable/filter', type: :merge_requests + = render 'shared/issuable/search_bar', type: :merge_requests .row-content-block.second-block Only merge requests from -- cgit v1.2.1 From 2ec7cfc91d81c843e82060c7c17da81aac68cb48 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 20 Aug 2017 04:35:06 -0700 Subject: Add spec for deleting protected tags --- .../projects/protected_tags_controller_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/controllers/projects/protected_tags_controller_spec.rb b/spec/controllers/projects/protected_tags_controller_spec.rb index 64658988b3f..b6de90039f3 100644 --- a/spec/controllers/projects/protected_tags_controller_spec.rb +++ b/spec/controllers/projects/protected_tags_controller_spec.rb @@ -8,4 +8,21 @@ describe Projects::ProtectedTagsController do get(:index, namespace_id: project.namespace.to_param, project_id: project) end end + + describe "DELETE #destroy" do + let(:project) { create(:project, :repository) } + let(:protected_tag) { create(:protected_tag, :developers_can_create, project: project) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + end + + it "deletes the protected tag" do + delete(:destroy, namespace_id: project.namespace.to_param, project_id: project, id: protected_tag.id) + + expect { ProtectedTag.find(protected_tag.id) }.to raise_error(ActiveRecord::RecordNotFound) + end + end end -- cgit v1.2.1 From 1a3835796f74652f4adc9448b06a2623d4c81d59 Mon Sep 17 00:00:00 2001 From: Alexandros Keramidas Date: Mon, 21 Aug 2017 08:00:32 +0000 Subject: Point to /developers on docs/administration/authentiq.md --- doc/administration/auth/authentiq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/administration/auth/authentiq.md b/doc/administration/auth/authentiq.md index 1528f1d2b17..252ff1f4b15 100644 --- a/doc/administration/auth/authentiq.md +++ b/doc/administration/auth/authentiq.md @@ -4,7 +4,7 @@ To enable the Authentiq OmniAuth provider for passwordless authentication you mu Authentiq will generate a Client ID and the accompanying Client Secret for you to use. -1. Get your Client credentials (Client ID and Client Secret) at [Authentiq](https://www.authentiq.com/register). +1. Get your Client credentials (Client ID and Client Secret) at [Authentiq](https://www.authentiq.com/developers). 2. On your GitLab server, open the configuration file: -- cgit v1.2.1 From 0f01ce365731542570c9135d7cbf6390ffa42ced Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 13:05:01 +0200 Subject: Extend pipelines queue mixin and add a default queue --- app/workers/concerns/pipeline_queue.rb | 12 +++++++++++- app/workers/pipeline_update_worker.rb | 2 ++ spec/workers/concerns/pipeline_queue_spec.rb | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/workers/concerns/pipeline_queue.rb b/app/workers/concerns/pipeline_queue.rb index ca3860e1d38..ed882e3ecef 100644 --- a/app/workers/concerns/pipeline_queue.rb +++ b/app/workers/concerns/pipeline_queue.rb @@ -1,8 +1,18 @@ +## # Concern for setting Sidekiq settings for the various CI pipeline workers. +# module PipelineQueue extend ActiveSupport::Concern included do - sidekiq_options queue: :pipeline + sidekiq_options queue: 'pipelines-default' + end + + class_methods do + def enqueue_in(queue:, group:) + raise ArgumentError if queue.empty? || group.empty? + + sidekiq_options queue: "pipelines-#{queue}-#{group}" + end end end diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb index 96c4152c674..086d00b7ec8 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -2,6 +2,8 @@ class PipelineUpdateWorker include Sidekiq::Worker include PipelineQueue + enqueue_in queue: :pipeline, group: :processing + def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) .try(:update_status) diff --git a/spec/workers/concerns/pipeline_queue_spec.rb b/spec/workers/concerns/pipeline_queue_spec.rb index 40794d0e42a..3049f2b2ab4 100644 --- a/spec/workers/concerns/pipeline_queue_spec.rb +++ b/spec/workers/concerns/pipeline_queue_spec.rb @@ -8,7 +8,17 @@ describe PipelineQueue do end end - it 'sets the queue name of a worker' do - expect(worker.sidekiq_options['queue'].to_s).to eq('pipeline') + it 'sets a default pipelines queue automatically' do + expect(worker.sidekiq_options['queue']) + .to eq 'pipelines-default' + end + + describe '.enqueue_in' do + it 'sets a custom sidekiq queue with prefix, name and group' do + worker.enqueue_in(queue: :build, group: :processing) + + expect(worker.sidekiq_options['queue']) + .to eq 'pipelines-build-processing' + end end end -- cgit v1.2.1 From ce274fd61bbe11c7a1353bff2176273e9b30e197 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 13:32:00 +0200 Subject: Make it possible to check if worker uses a known queue --- config/sidekiq_queues.yml | 1 + spec/support/shared_examples/sidekiq_worker_shared_examples.rb | 10 ++++++++++ spec/workers/pipeline_update_worker_spec.rb | 2 ++ 3 files changed, 13 insertions(+) create mode 100644 spec/support/shared_examples/sidekiq_worker_shared_examples.rb diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 83abc83c9f0..7816c0fa92e 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -27,6 +27,7 @@ - [new_merge_request, 2] - [build, 2] - [pipeline, 2] + - [pipelines-pipeline-processing, 2] - [gitlab_shell, 2] - [email_receiver, 2] - [emails_on_push, 2] diff --git a/spec/support/shared_examples/sidekiq_worker_shared_examples.rb b/spec/support/shared_examples/sidekiq_worker_shared_examples.rb new file mode 100644 index 00000000000..712cad2a0d9 --- /dev/null +++ b/spec/support/shared_examples/sidekiq_worker_shared_examples.rb @@ -0,0 +1,10 @@ +shared_examples 'sidekiq worker' do + let(:queues) do + YAML.load_file(Rails.root.join('config', 'sidekiq_queues.yml')) + .fetch(:queues, []).map(&:first) + end + + it 'is going to be processed inside a known sidekiq queue' do + expect(described_class.sidekiq_options['queue']).to be_in queues + end +end diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb index 0b456cfd0da..60e7e23f0b4 100644 --- a/spec/workers/pipeline_update_worker_spec.rb +++ b/spec/workers/pipeline_update_worker_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe PipelineUpdateWorker do + it_behaves_like 'sidekiq worker' + describe '#perform' do context 'when pipeline exists' do let(:pipeline) { create(:ci_pipeline) } -- cgit v1.2.1 From 48776f2786d22cecab97417141d43060c6cdee26 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 13:49:57 +0200 Subject: Simplify pipeline sidekiq queues naming scheme --- app/workers/concerns/pipeline_queue.rb | 8 ++++---- app/workers/pipeline_update_worker.rb | 2 +- config/sidekiq_queues.yml | 2 +- spec/workers/concerns/pipeline_queue_spec.rb | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/workers/concerns/pipeline_queue.rb b/app/workers/concerns/pipeline_queue.rb index ed882e3ecef..ddf45b91345 100644 --- a/app/workers/concerns/pipeline_queue.rb +++ b/app/workers/concerns/pipeline_queue.rb @@ -5,14 +5,14 @@ module PipelineQueue extend ActiveSupport::Concern included do - sidekiq_options queue: 'pipelines-default' + sidekiq_options queue: 'pipeline_default' end class_methods do - def enqueue_in(queue:, group:) - raise ArgumentError if queue.empty? || group.empty? + def enqueue_in(group:) + raise ArgumentError, 'Unspecified queue group!' if group.empty? - sidekiq_options queue: "pipelines-#{queue}-#{group}" + sidekiq_options queue: "pipeline_#{group}" end end end diff --git a/app/workers/pipeline_update_worker.rb b/app/workers/pipeline_update_worker.rb index 086d00b7ec8..5fa399dff4c 100644 --- a/app/workers/pipeline_update_worker.rb +++ b/app/workers/pipeline_update_worker.rb @@ -2,7 +2,7 @@ class PipelineUpdateWorker include Sidekiq::Worker include PipelineQueue - enqueue_in queue: :pipeline, group: :processing + enqueue_in group: :processing def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 7816c0fa92e..8e13ed95f19 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -27,7 +27,7 @@ - [new_merge_request, 2] - [build, 2] - [pipeline, 2] - - [pipelines-pipeline-processing, 2] + - [pipeline_processing, 2] - [gitlab_shell, 2] - [email_receiver, 2] - [emails_on_push, 2] diff --git a/spec/workers/concerns/pipeline_queue_spec.rb b/spec/workers/concerns/pipeline_queue_spec.rb index 3049f2b2ab4..eac5a770e5f 100644 --- a/spec/workers/concerns/pipeline_queue_spec.rb +++ b/spec/workers/concerns/pipeline_queue_spec.rb @@ -10,15 +10,15 @@ describe PipelineQueue do it 'sets a default pipelines queue automatically' do expect(worker.sidekiq_options['queue']) - .to eq 'pipelines-default' + .to eq 'pipeline_default' end describe '.enqueue_in' do - it 'sets a custom sidekiq queue with prefix, name and group' do - worker.enqueue_in(queue: :build, group: :processing) + it 'sets a custom sidekiq queue with prefix and group' do + worker.enqueue_in(group: :processing) expect(worker.sidekiq_options['queue']) - .to eq 'pipelines-build-processing' + .to eq 'pipeline_processing' end end end -- cgit v1.2.1 From 8417507201809daf0554c13ffb695b8142274f4f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 14:02:20 +0200 Subject: Assign all pipeline workers to specific queues --- app/workers/expire_pipeline_cache_worker.rb | 2 ++ app/workers/pipeline_hooks_worker.rb | 2 ++ app/workers/pipeline_metrics_worker.rb | 2 ++ app/workers/pipeline_notification_worker.rb | 2 ++ app/workers/pipeline_process_worker.rb | 2 ++ app/workers/pipeline_success_worker.rb | 2 ++ config/sidekiq_queues.yml | 3 +++ spec/workers/expire_pipeline_cache_worker_spec.rb | 2 ++ spec/workers/pipeline_hooks_worker_spec.rb | 2 ++ spec/workers/pipeline_metrics_worker_spec.rb | 2 ++ spec/workers/pipeline_notification_worker_spec.rb | 2 ++ spec/workers/pipeline_process_worker_spec.rb | 2 ++ spec/workers/pipeline_success_worker_spec.rb | 2 ++ 13 files changed, 27 insertions(+) diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb index 7c02d6cf892..1a0e7f92875 100644 --- a/app/workers/expire_pipeline_cache_worker.rb +++ b/app/workers/expire_pipeline_cache_worker.rb @@ -2,6 +2,8 @@ class ExpirePipelineCacheWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :cache + def perform(pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id) return unless pipeline diff --git a/app/workers/pipeline_hooks_worker.rb b/app/workers/pipeline_hooks_worker.rb index 7e36eacebf8..30a75ec8435 100644 --- a/app/workers/pipeline_hooks_worker.rb +++ b/app/workers/pipeline_hooks_worker.rb @@ -2,6 +2,8 @@ class PipelineHooksWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :hooks + def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) .try(:execute_hooks) diff --git a/app/workers/pipeline_metrics_worker.rb b/app/workers/pipeline_metrics_worker.rb index 070943f1ecc..3795105ef28 100644 --- a/app/workers/pipeline_metrics_worker.rb +++ b/app/workers/pipeline_metrics_worker.rb @@ -2,6 +2,8 @@ class PipelineMetricsWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :metrics + def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| update_metrics_for_active_pipeline(pipeline) if pipeline.active? diff --git a/app/workers/pipeline_notification_worker.rb b/app/workers/pipeline_notification_worker.rb index cdb860b6675..77ff3913ad7 100644 --- a/app/workers/pipeline_notification_worker.rb +++ b/app/workers/pipeline_notification_worker.rb @@ -2,6 +2,8 @@ class PipelineNotificationWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :hooks + def perform(pipeline_id, recipients = nil) pipeline = Ci::Pipeline.find_by(id: pipeline_id) diff --git a/app/workers/pipeline_process_worker.rb b/app/workers/pipeline_process_worker.rb index 357e4a9a1c3..8c067d05081 100644 --- a/app/workers/pipeline_process_worker.rb +++ b/app/workers/pipeline_process_worker.rb @@ -2,6 +2,8 @@ class PipelineProcessWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :processing + def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id) .try(:process!) diff --git a/app/workers/pipeline_success_worker.rb b/app/workers/pipeline_success_worker.rb index cc0eb708cf9..cb8bb2ffe75 100644 --- a/app/workers/pipeline_success_worker.rb +++ b/app/workers/pipeline_success_worker.rb @@ -2,6 +2,8 @@ class PipelineSuccessWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :processing + def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| MergeRequests::MergeWhenPipelineSucceedsService diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 8e13ed95f19..28cfb9419de 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -28,6 +28,9 @@ - [build, 2] - [pipeline, 2] - [pipeline_processing, 2] + - [pipeline_cache, 2] + - [pipeline_metrics, 2] + - [pipeline_hooks, 2] - [gitlab_shell, 2] - [email_receiver, 2] - [emails_on_push, 2] diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb index 54c9a69d329..85b24d5a8f0 100644 --- a/spec/workers/expire_pipeline_cache_worker_spec.rb +++ b/spec/workers/expire_pipeline_cache_worker_spec.rb @@ -43,4 +43,6 @@ describe ExpirePipelineCacheWorker do subject.perform(pipeline.id) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb index 035e329839f..50b724d0111 100644 --- a/spec/workers/pipeline_hooks_worker_spec.rb +++ b/spec/workers/pipeline_hooks_worker_spec.rb @@ -20,4 +20,6 @@ describe PipelineHooksWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb index ef71125c0b6..dac0b24d24a 100644 --- a/spec/workers/pipeline_metrics_worker_spec.rb +++ b/spec/workers/pipeline_metrics_worker_spec.rb @@ -47,4 +47,6 @@ describe PipelineMetricsWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb index eb539ffd893..072866bf375 100644 --- a/spec/workers/pipeline_notification_worker_spec.rb +++ b/spec/workers/pipeline_notification_worker_spec.rb @@ -16,4 +16,6 @@ describe PipelineNotificationWorker, :mailer do subject.perform(Ci::Pipeline.maximum(:id).to_i.succ) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb index 86e9d7f6684..81570c685ed 100644 --- a/spec/workers/pipeline_process_worker_spec.rb +++ b/spec/workers/pipeline_process_worker_spec.rb @@ -19,4 +19,6 @@ describe PipelineProcessWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_success_worker_spec.rb b/spec/workers/pipeline_success_worker_spec.rb index d1c84adda6f..83d006337bd 100644 --- a/spec/workers/pipeline_success_worker_spec.rb +++ b/spec/workers/pipeline_success_worker_spec.rb @@ -21,4 +21,6 @@ describe PipelineSuccessWorker do end end end + + it_behaves_like 'sidekiq worker' end -- cgit v1.2.1 From 4c93668202f8b3a02e3730e696e9ebcd6f08daca Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 14:16:51 +0200 Subject: Remove sidekiq build queue and assign pipeline queue --- app/workers/build_coverage_worker.rb | 4 +++- app/workers/build_finished_worker.rb | 4 +++- app/workers/build_hooks_worker.rb | 4 +++- app/workers/build_success_worker.rb | 4 +++- app/workers/concerns/build_queue.rb | 8 -------- app/workers/expire_job_cache_worker.rb | 4 +++- spec/workers/build_coverage_worker_spec.rb | 2 ++ spec/workers/build_finished_worker_spec.rb | 2 ++ spec/workers/build_hooks_worker_spec.rb | 2 ++ spec/workers/build_success_worker_spec.rb | 2 ++ spec/workers/concerns/build_queue_spec.rb | 14 -------------- spec/workers/expire_job_cache_worker_spec.rb | 2 ++ 12 files changed, 25 insertions(+), 27 deletions(-) delete mode 100644 app/workers/concerns/build_queue.rb delete mode 100644 spec/workers/concerns/build_queue_spec.rb diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb index f7ae996bb17..fd5ba11f73e 100644 --- a/app/workers/build_coverage_worker.rb +++ b/app/workers/build_coverage_worker.rb @@ -1,6 +1,8 @@ class BuildCoverageWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :processing def perform(build_id) Ci::Build.find_by(id: build_id)&.update_coverage diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb index 466410bf08c..e2a1b3dcc41 100644 --- a/app/workers/build_finished_worker.rb +++ b/app/workers/build_finished_worker.rb @@ -1,6 +1,8 @@ class BuildFinishedWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :processing def perform(build_id) Ci::Build.find_by(id: build_id).try do |build| diff --git a/app/workers/build_hooks_worker.rb b/app/workers/build_hooks_worker.rb index 9965af935d4..dedaf2835e6 100644 --- a/app/workers/build_hooks_worker.rb +++ b/app/workers/build_hooks_worker.rb @@ -1,6 +1,8 @@ class BuildHooksWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :hooks def perform(build_id) Ci::Build.find_by(id: build_id) diff --git a/app/workers/build_success_worker.rb b/app/workers/build_success_worker.rb index bf009dfab0f..20ec24bd18a 100644 --- a/app/workers/build_success_worker.rb +++ b/app/workers/build_success_worker.rb @@ -1,6 +1,8 @@ class BuildSuccessWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :processing def perform(build_id) Ci::Build.find_by(id: build_id).try do |build| diff --git a/app/workers/concerns/build_queue.rb b/app/workers/concerns/build_queue.rb deleted file mode 100644 index cf0ead40a8b..00000000000 --- a/app/workers/concerns/build_queue.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Concern for setting Sidekiq settings for the various CI build workers. -module BuildQueue - extend ActiveSupport::Concern - - included do - sidekiq_options queue: :build - end -end diff --git a/app/workers/expire_job_cache_worker.rb b/app/workers/expire_job_cache_worker.rb index e383202260d..98a7500bffe 100644 --- a/app/workers/expire_job_cache_worker.rb +++ b/app/workers/expire_job_cache_worker.rb @@ -1,6 +1,8 @@ class ExpireJobCacheWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :cache def perform(job_id) job = CommitStatus.joins(:pipeline, :project).find_by(id: job_id) diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb index ba20488f663..e49750f6a3e 100644 --- a/spec/workers/build_coverage_worker_spec.rb +++ b/spec/workers/build_coverage_worker_spec.rb @@ -20,4 +20,6 @@ describe BuildCoverageWorker do end end end + + it_behaves_like 'sidekiq_worker' end diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb index 2868167c7d4..463e8c6a60a 100644 --- a/spec/workers/build_finished_worker_spec.rb +++ b/spec/workers/build_finished_worker_spec.rb @@ -27,4 +27,6 @@ describe BuildFinishedWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb index 97654a93f5c..3d98ffabf0a 100644 --- a/spec/workers/build_hooks_worker_spec.rb +++ b/spec/workers/build_hooks_worker_spec.rb @@ -20,4 +20,6 @@ describe BuildHooksWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb index dba70883130..a82ed5c187d 100644 --- a/spec/workers/build_success_worker_spec.rb +++ b/spec/workers/build_success_worker_spec.rb @@ -33,4 +33,6 @@ describe BuildSuccessWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/concerns/build_queue_spec.rb b/spec/workers/concerns/build_queue_spec.rb deleted file mode 100644 index 6bf955e0be2..00000000000 --- a/spec/workers/concerns/build_queue_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe BuildQueue do - let(:worker) do - Class.new do - include Sidekiq::Worker - include BuildQueue - end - end - - it 'sets the queue name of a worker' do - expect(worker.sidekiq_options['queue'].to_s).to eq('build') - end -end diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb index 1b614342a18..552e2c350de 100644 --- a/spec/workers/expire_job_cache_worker_spec.rb +++ b/spec/workers/expire_job_cache_worker_spec.rb @@ -28,4 +28,6 @@ describe ExpireJobCacheWorker do end end end + + it_behaves_like 'sidekiq worker' end -- cgit v1.2.1 From ad12ee2a78ed590194661b3d5365b0eaa14bff80 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 14:24:05 +0200 Subject: Assign some CI/CD workers to pipeline default queue --- app/workers/build_coverage_worker.rb | 2 -- app/workers/pipeline_metrics_worker.rb | 2 -- app/workers/pipeline_notification_worker.rb | 2 -- config/sidekiq_queues.yml | 2 +- 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/workers/build_coverage_worker.rb b/app/workers/build_coverage_worker.rb index fd5ba11f73e..cd4af85d047 100644 --- a/app/workers/build_coverage_worker.rb +++ b/app/workers/build_coverage_worker.rb @@ -2,8 +2,6 @@ class BuildCoverageWorker include Sidekiq::Worker include PipelineQueue - enqueue_in group: :processing - def perform(build_id) Ci::Build.find_by(id: build_id)&.update_coverage end diff --git a/app/workers/pipeline_metrics_worker.rb b/app/workers/pipeline_metrics_worker.rb index 3795105ef28..070943f1ecc 100644 --- a/app/workers/pipeline_metrics_worker.rb +++ b/app/workers/pipeline_metrics_worker.rb @@ -2,8 +2,6 @@ class PipelineMetricsWorker include Sidekiq::Worker include PipelineQueue - enqueue_in group: :metrics - def perform(pipeline_id) Ci::Pipeline.find_by(id: pipeline_id).try do |pipeline| update_metrics_for_active_pipeline(pipeline) if pipeline.active? diff --git a/app/workers/pipeline_notification_worker.rb b/app/workers/pipeline_notification_worker.rb index 77ff3913ad7..cdb860b6675 100644 --- a/app/workers/pipeline_notification_worker.rb +++ b/app/workers/pipeline_notification_worker.rb @@ -2,8 +2,6 @@ class PipelineNotificationWorker include Sidekiq::Worker include PipelineQueue - enqueue_in group: :hooks - def perform(pipeline_id, recipients = nil) pipeline = Ci::Pipeline.find_by(id: pipeline_id) diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 28cfb9419de..2eeb0762b76 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -28,8 +28,8 @@ - [build, 2] - [pipeline, 2] - [pipeline_processing, 2] + - [pipeline_default, 2] - [pipeline_cache, 2] - - [pipeline_metrics, 2] - [pipeline_hooks, 2] - [gitlab_shell, 2] - [email_receiver, 2] -- cgit v1.2.1 From 82056644d5c3be0b9cc4a268ff367944472bb11e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 14:25:58 +0200 Subject: Adjust sidekiq queues weights in queues config file --- config/sidekiq_queues.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sidekiq_queues.yml b/config/sidekiq_queues.yml index 2eeb0762b76..24c001362c6 100644 --- a/config/sidekiq_queues.yml +++ b/config/sidekiq_queues.yml @@ -27,9 +27,9 @@ - [new_merge_request, 2] - [build, 2] - [pipeline, 2] - - [pipeline_processing, 2] - - [pipeline_default, 2] - - [pipeline_cache, 2] + - [pipeline_processing, 5] + - [pipeline_default, 3] + - [pipeline_cache, 3] - [pipeline_hooks, 2] - [gitlab_shell, 2] - [email_receiver, 2] -- cgit v1.2.1 From 15f486e305b32ddaa8eeaf528dc79e04ed6aa98a Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 21 Aug 2017 14:31:09 +0200 Subject: Add sidekiq worker shared examples to workers specs --- spec/workers/authorized_projects_worker_spec.rb | 2 ++ spec/workers/background_migration_worker_spec.rb | 2 ++ spec/workers/create_gpg_signature_worker_spec.rb | 2 ++ spec/workers/delete_merged_branches_worker_spec.rb | 2 ++ spec/workers/delete_user_worker_spec.rb | 2 ++ spec/workers/email_receiver_worker_spec.rb | 2 ++ spec/workers/emails_on_push_worker_spec.rb | 2 ++ spec/workers/every_sidekiq_worker_spec.rb | 2 ++ spec/workers/expire_build_artifacts_worker_spec.rb | 2 ++ spec/workers/expire_build_instance_artifacts_worker_spec.rb | 2 ++ spec/workers/git_garbage_collect_worker_spec.rb | 2 ++ spec/workers/gitlab_usage_ping_worker_spec.rb | 2 ++ spec/workers/group_destroy_worker_spec.rb | 2 ++ spec/workers/invalid_gpg_signature_update_worker_spec.rb | 2 ++ spec/workers/merge_worker_spec.rb | 2 ++ spec/workers/namespaceless_project_destroy_worker_spec.rb | 2 ++ spec/workers/new_issue_worker_spec.rb | 2 ++ spec/workers/new_merge_request_worker_spec.rb | 2 ++ spec/workers/new_note_worker_spec.rb | 2 ++ spec/workers/pipeline_schedule_worker_spec.rb | 2 ++ spec/workers/pipeline_update_worker_spec.rb | 4 ++-- spec/workers/post_receive_spec.rb | 2 ++ spec/workers/process_commit_worker_spec.rb | 2 ++ spec/workers/project_cache_worker_spec.rb | 2 ++ spec/workers/project_destroy_worker_spec.rb | 2 ++ spec/workers/propagate_service_template_worker_spec.rb | 2 ++ spec/workers/prune_old_events_worker_spec.rb | 2 ++ spec/workers/reactive_caching_worker_spec.rb | 2 ++ spec/workers/remove_expired_group_links_worker_spec.rb | 2 ++ spec/workers/remove_expired_members_worker_spec.rb | 2 ++ spec/workers/remove_old_web_hook_logs_worker_spec.rb | 2 ++ spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb | 2 ++ spec/workers/repository_fork_worker_spec.rb | 2 ++ spec/workers/repository_import_worker_spec.rb | 2 ++ spec/workers/schedule_update_user_activity_worker_spec.rb | 2 ++ spec/workers/stuck_ci_jobs_worker_spec.rb | 2 ++ spec/workers/stuck_import_jobs_worker_spec.rb | 2 ++ spec/workers/stuck_merge_jobs_worker_spec.rb | 2 ++ spec/workers/system_hook_push_worker_spec.rb | 2 ++ spec/workers/trending_projects_worker_spec.rb | 2 ++ spec/workers/update_merge_requests_worker_spec.rb | 2 ++ spec/workers/update_user_activity_worker_spec.rb | 2 ++ spec/workers/upload_checksum_worker_spec.rb | 2 ++ spec/workers/use_key_worker_spec.rb | 2 ++ 44 files changed, 88 insertions(+), 2 deletions(-) diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb index 03b9b99e263..bf9425b3d09 100644 --- a/spec/workers/authorized_projects_worker_spec.rb +++ b/spec/workers/authorized_projects_worker_spec.rb @@ -47,4 +47,6 @@ describe AuthorizedProjectsWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb index 4f6e3474634..69971cf9243 100644 --- a/spec/workers/background_migration_worker_spec.rb +++ b/spec/workers/background_migration_worker_spec.rb @@ -41,4 +41,6 @@ describe BackgroundMigrationWorker, :sidekiq do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/create_gpg_signature_worker_spec.rb b/spec/workers/create_gpg_signature_worker_spec.rb index 54978baca88..0cfa957be06 100644 --- a/spec/workers/create_gpg_signature_worker_spec.rb +++ b/spec/workers/create_gpg_signature_worker_spec.rb @@ -36,4 +36,6 @@ describe CreateGpgSignatureWorker do described_class.new.perform(anything, nonexisting_project_id) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/delete_merged_branches_worker_spec.rb b/spec/workers/delete_merged_branches_worker_spec.rb index 39009d9e4b2..da20d4e7e3f 100644 --- a/spec/workers/delete_merged_branches_worker_spec.rb +++ b/spec/workers/delete_merged_branches_worker_spec.rb @@ -16,4 +16,6 @@ describe DeleteMergedBranchesWorker do expect(worker.perform('unknown', project.owner.id)).to be_falsy end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb index 36594515005..24fcf41a0c8 100644 --- a/spec/workers/delete_user_worker_spec.rb +++ b/spec/workers/delete_user_worker_spec.rb @@ -17,4 +17,6 @@ describe DeleteUserWorker do described_class.new.perform(current_user.id, user.id, "test" => "test") end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb index e4e77c667b3..d8ffdd4b5ed 100644 --- a/spec/workers/email_receiver_worker_spec.rb +++ b/spec/workers/email_receiver_worker_spec.rb @@ -60,4 +60,6 @@ describe EmailReceiverWorker, :mailer do described_class.new.perform(raw_message) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb index 318aad4bc1e..28031e2292c 100644 --- a/spec/workers/emails_on_push_worker_spec.rb +++ b/spec/workers/emails_on_push_worker_spec.rb @@ -127,4 +127,6 @@ describe EmailsOnPushWorker, :mailer do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index 30908534eb3..34f5bfc8c0c 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -41,4 +41,6 @@ describe 'Every Sidekiq worker' do expect(queue_names).to include(worker.sidekiq_options['queue'].to_s) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb index b47b4a02a68..751e4dfebd8 100644 --- a/spec/workers/expire_build_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_artifacts_worker_spec.rb @@ -47,4 +47,6 @@ describe ExpireBuildArtifactsWorker do Sidekiq::Queues.jobs_by_worker['ExpireBuildInstanceArtifactsWorker'] end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_build_instance_artifacts_worker_spec.rb b/spec/workers/expire_build_instance_artifacts_worker_spec.rb index bed5c5e2ecb..e1e6a5434fc 100644 --- a/spec/workers/expire_build_instance_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_instance_artifacts_worker_spec.rb @@ -74,4 +74,6 @@ describe ExpireBuildInstanceArtifactsWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index 05f971dfd13..f2917986804 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -131,6 +131,8 @@ describe GitGarbageCollectWorker do end end + it_behaves_like 'sidekiq worker' + # Create a new commit on a random new branch def create_objects(project) rugged = project.repository.rugged diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb index 49b4e04dc7c..f5ff6736993 100644 --- a/spec/workers/gitlab_usage_ping_worker_spec.rb +++ b/spec/workers/gitlab_usage_ping_worker_spec.rb @@ -10,4 +10,6 @@ describe GitlabUsagePingWorker do subject.perform end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/group_destroy_worker_spec.rb b/spec/workers/group_destroy_worker_spec.rb index a170c84ab12..2f0c55b1b91 100644 --- a/spec/workers/group_destroy_worker_spec.rb +++ b/spec/workers/group_destroy_worker_spec.rb @@ -16,4 +16,6 @@ describe GroupDestroyWorker do expect(Dir.exist?(project.path)).to be_falsey end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb index 5972696515b..178dc024201 100644 --- a/spec/workers/invalid_gpg_signature_update_worker_spec.rb +++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb @@ -26,4 +26,6 @@ describe InvalidGpgSignatureUpdateWorker do described_class.new.perform(nonexisting_gpg_key_id) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb index ee51000161a..b63c184fdb1 100644 --- a/spec/workers/merge_worker_spec.rb +++ b/spec/workers/merge_worker_spec.rb @@ -38,4 +38,6 @@ describe MergeWorker do expect { worker.perform(merge_request.id, user.id, {}) } .to change { merge_request.reload.merge_jid }.from(nil).to('999') end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb index f2706254284..6d75e7fbfb8 100644 --- a/spec/workers/namespaceless_project_destroy_worker_spec.rb +++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb @@ -76,4 +76,6 @@ describe NamespacelessProjectDestroyWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb index 4e15ccc534b..e82302d5cfe 100644 --- a/spec/workers/new_issue_worker_spec.rb +++ b/spec/workers/new_issue_worker_spec.rb @@ -51,4 +51,6 @@ describe NewIssueWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb index 9e0cbde45b1..a7e2e4376d6 100644 --- a/spec/workers/new_merge_request_worker_spec.rb +++ b/spec/workers/new_merge_request_worker_spec.rb @@ -53,4 +53,6 @@ describe NewMergeRequestWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index 575361c93d4..d935a0ae3b4 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -46,4 +46,6 @@ describe NewNoteWorker do described_class.new.perform(unexistent_note_id) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb index 75197039f5a..4cea91a237c 100644 --- a/spec/workers/pipeline_schedule_worker_spec.rb +++ b/spec/workers/pipeline_schedule_worker_spec.rb @@ -62,4 +62,6 @@ describe PipelineScheduleWorker do expect { subject }.not_to change { project.pipelines.count } end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb index 60e7e23f0b4..cd8ae030ab9 100644 --- a/spec/workers/pipeline_update_worker_spec.rb +++ b/spec/workers/pipeline_update_worker_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe PipelineUpdateWorker do - it_behaves_like 'sidekiq worker' - describe '#perform' do context 'when pipeline exists' do let(:pipeline) { create(:ci_pipeline) } @@ -21,4 +19,6 @@ describe PipelineUpdateWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index af6a3c9f6c7..4968758cb6b 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -140,4 +140,6 @@ describe PostReceive do described_class.new.perform(gl_repository, key_id, base64_changes) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index 24f8ca67594..0580ea60742 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -134,4 +134,6 @@ describe ProcessCommitWorker do expect(commit.authored_date).to be_an_instance_of(Time) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index 6b1f2ff3227..20d18a433d3 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -87,4 +87,6 @@ describe ProjectCacheWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb index f19c9dff941..7c2a293c5f3 100644 --- a/spec/workers/project_destroy_worker_spec.rb +++ b/spec/workers/project_destroy_worker_spec.rb @@ -33,4 +33,6 @@ describe ProjectDestroyWorker do end.not_to raise_error end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb index b8b65ead9b3..21df8eb489e 100644 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -26,4 +26,6 @@ describe PropagateServiceTemplateWorker do subject.perform(service_template.id) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/prune_old_events_worker_spec.rb b/spec/workers/prune_old_events_worker_spec.rb index ea974355050..e9b3061a1be 100644 --- a/spec/workers/prune_old_events_worker_spec.rb +++ b/spec/workers/prune_old_events_worker_spec.rb @@ -23,4 +23,6 @@ describe PruneOldEventsWorker do expect(exactly_12_months_event).to be_present end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/reactive_caching_worker_spec.rb b/spec/workers/reactive_caching_worker_spec.rb index 5f4453c15d6..44aa520d102 100644 --- a/spec/workers/reactive_caching_worker_spec.rb +++ b/spec/workers/reactive_caching_worker_spec.rb @@ -12,4 +12,6 @@ describe ReactiveCachingWorker do subject end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_expired_group_links_worker_spec.rb b/spec/workers/remove_expired_group_links_worker_spec.rb index 689bc3d27b4..2615b049650 100644 --- a/spec/workers/remove_expired_group_links_worker_spec.rb +++ b/spec/workers/remove_expired_group_links_worker_spec.rb @@ -21,4 +21,6 @@ describe RemoveExpiredGroupLinksWorker do expect(non_expiring_project_group_link.reload).to be_present end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_expired_members_worker_spec.rb b/spec/workers/remove_expired_members_worker_spec.rb index 058fdf4c009..1b0af031a83 100644 --- a/spec/workers/remove_expired_members_worker_spec.rb +++ b/spec/workers/remove_expired_members_worker_spec.rb @@ -55,4 +55,6 @@ describe RemoveExpiredMembersWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_old_web_hook_logs_worker_spec.rb b/spec/workers/remove_old_web_hook_logs_worker_spec.rb index 6d26ba5dfa0..4a504f34367 100644 --- a/spec/workers/remove_old_web_hook_logs_worker_spec.rb +++ b/spec/workers/remove_old_web_hook_logs_worker_spec.rb @@ -15,4 +15,6 @@ describe RemoveOldWebHookLogsWorker do expect(WebHookLog.all).not_to include(week_old_record, three_days_old_record) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb index 57f83c1dbe9..fccb64717ad 100644 --- a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb +++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb @@ -52,4 +52,6 @@ describe RemoveUnreferencedLfsObjectsWorker do expect(LfsObject.where(id: referenced_lfs_object2.id)).to be_empty end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index d9e9409840f..6550de6f893 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -69,4 +69,6 @@ describe RepositoryForkWorker do expect(project.reload.import_status).to eq('failed') end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index 100dfc32bbe..d67891aa388 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -43,4 +43,6 @@ describe RepositoryImportWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/schedule_update_user_activity_worker_spec.rb b/spec/workers/schedule_update_user_activity_worker_spec.rb index 32c59381b01..362cd2a6d92 100644 --- a/spec/workers/schedule_update_user_activity_worker_spec.rb +++ b/spec/workers/schedule_update_user_activity_worker_spec.rb @@ -22,4 +22,6 @@ describe ScheduleUpdateUserActivityWorker, :clean_gitlab_redis_shared_state do subject.perform(1) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb index 549635f7f33..f64de2a9c21 100644 --- a/spec/workers/stuck_ci_jobs_worker_spec.rb +++ b/spec/workers/stuck_ci_jobs_worker_spec.rb @@ -132,4 +132,6 @@ describe StuckCiJobsWorker do worker.perform end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb index a82eb54ffe4..64a69fc4872 100644 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -33,4 +33,6 @@ describe StuckImportJobsWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb index a5ad78393c9..a989942f913 100644 --- a/spec/workers/stuck_merge_jobs_worker_spec.rb +++ b/spec/workers/stuck_merge_jobs_worker_spec.rb @@ -47,4 +47,6 @@ describe StuckMergeJobsWorker do end end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/system_hook_push_worker_spec.rb b/spec/workers/system_hook_push_worker_spec.rb index b1d446ed25f..e0588e2a1b3 100644 --- a/spec/workers/system_hook_push_worker_spec.rb +++ b/spec/workers/system_hook_push_worker_spec.rb @@ -16,4 +16,6 @@ describe SystemHookPushWorker do subject.perform(push_data, :push_hooks) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/trending_projects_worker_spec.rb b/spec/workers/trending_projects_worker_spec.rb index c3c6fdcf2d5..a9e0c9d1d77 100644 --- a/spec/workers/trending_projects_worker_spec.rb +++ b/spec/workers/trending_projects_worker_spec.rb @@ -8,4 +8,6 @@ describe TrendingProjectsWorker do described_class.new.perform end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/update_merge_requests_worker_spec.rb b/spec/workers/update_merge_requests_worker_spec.rb index 558ff9109ec..f40c9012db9 100644 --- a/spec/workers/update_merge_requests_worker_spec.rb +++ b/spec/workers/update_merge_requests_worker_spec.rb @@ -24,4 +24,6 @@ describe UpdateMergeRequestsWorker do perform end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/update_user_activity_worker_spec.rb b/spec/workers/update_user_activity_worker_spec.rb index 268ca1d81f2..9cd7ffc2ab4 100644 --- a/spec/workers/update_user_activity_worker_spec.rb +++ b/spec/workers/update_user_activity_worker_spec.rb @@ -32,4 +32,6 @@ describe UpdateUserActivityWorker, :clean_gitlab_redis_shared_state do expect(Gitlab::UserActivities.new.to_a).to be_empty end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/upload_checksum_worker_spec.rb b/spec/workers/upload_checksum_worker_spec.rb index 911360da66c..735aeec1046 100644 --- a/spec/workers/upload_checksum_worker_spec.rb +++ b/spec/workers/upload_checksum_worker_spec.rb @@ -16,4 +16,6 @@ describe UploadChecksumWorker do expect(upload).to have_received(:save!) end end + + it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb index e50c788b82a..c7de5bb6117 100644 --- a/spec/workers/use_key_worker_spec.rb +++ b/spec/workers/use_key_worker_spec.rb @@ -20,4 +20,6 @@ describe UseKeyWorker do expect(worker.perform(key.id + 1)).to eq false end end + + it_behaves_like 'sidekiq worker' end -- cgit v1.2.1 From 4c68ff08bb2c48f85a3f3a79db14ec7402a8ba69 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Fri, 18 Aug 2017 13:36:51 -0700 Subject: add a spec for a participant with a :custom setting where that custom setting is not enabled. --- spec/services/notification_service_spec.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 44b2d28d1d4..5223152ce66 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -130,7 +130,18 @@ describe NotificationService, :mailer do project.add_master(issue.author) project.add_master(assignee) project.add_master(note.author) - create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@subscribed_participant cc this guy') + + @u_custom_off = create_user_with_notification(:custom, 'custom_off') + project.add_guest(@u_custom_off) + + create( + :note_on_issue, + author: @u_custom_off, + noteable: issue, + project_id: issue.project_id, + note: 'i think @subscribed_participant should see this' + ) + update_custom_notification(:new_note, @u_guest_custom, resource: project) update_custom_notification(:new_note, @u_custom_global) end @@ -141,7 +152,7 @@ describe NotificationService, :mailer do reset_delivered_emails! # Ensure create SentNotification by noteable = issue 6 times, not noteable = note - expect(SentNotification).to receive(:record).with(issue, any_args).exactly(8).times + expect(SentNotification).to receive(:record).with(issue, any_args).exactly(9).times notification.new_note(note) @@ -153,6 +164,7 @@ describe NotificationService, :mailer do should_email(@subscriber) should_email(@watcher_and_subscriber) should_email(@subscribed_participant) + should_email(@u_custom_off) should_not_email(@u_guest_custom) should_not_email(@u_guest_watcher) should_not_email(note.author) -- cgit v1.2.1 From 7059af29800da478edbe04f4edf63fd7698909f5 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Fri, 18 Aug 2017 13:39:12 -0700 Subject: actually use the :participating notification type --- app/services/notification_recipient_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index 21c9c314a2a..c9f07c140f7 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -95,7 +95,7 @@ module NotificationRecipientService def add_participants(user) return unless target.respond_to?(:participants) - self << [target.participants(user), :watch] + self << [target.participants(user), :participating] end # Get project/group users with CUSTOM notification level -- cgit v1.2.1 From 3676275a5a07492bb24a8b1925f7221c375a2f42 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Fri, 18 Aug 2017 13:40:09 -0700 Subject: don't rely on order of notification levels factor out #suitable_notification_level? and check manually by notification level. this makes the notification logic clear and actually reflect what is in the documentation as to what should happen with each setting. --- app/models/notification_recipient.rb | 53 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb index dc862565a71..183e098d819 100644 --- a/app/models/notification_recipient.rb +++ b/app/models/notification_recipient.rb @@ -27,46 +27,45 @@ class NotificationRecipient @notification_setting ||= find_notification_setting end - def raw_notification_level - notification_setting&.level&.to_sym - end - def notification_level - # custom is treated the same as watch if it's enabled - otherwise it's - # set to :custom, meaning to send exactly when our type is :participating - # or :mention. - @notification_level ||= - case raw_notification_level - when :custom - if @custom_action && notification_setting&.event_enabled?(@custom_action) - :watch - else - :custom - end - else - raw_notification_level - end + @notification_level ||= notification_setting&.level&.to_sym end def notifiable? return false unless has_access? return false if own_activity? - return true if @type == :subscription - - return false if notification_level.nil? || notification_level == :disabled - - return %i[participating mention].include?(@type) if notification_level == :custom + # even users with :disabled notifications receive manual subscriptions + return !unsubscribed? if @type == :subscription - return false if %i[watch participating].include?(notification_level) && excluded_watcher_action? - - return false unless NotificationSetting.levels[notification_level] <= NotificationSetting.levels[@type] + return false unless suitable_notification_level? + # check this last because it's expensive + # nobody should receive notifications if they've specifically unsubscribed return false if unsubscribed? true end + def suitable_notification_level? + case notification_level + when :disabled, nil + false + when :custom + custom_enabled? || %i[participating mention].include?(@type) + when :watch, :participating + !excluded_watcher_action? + when :mention + @type == :mention + else + false + end + end + + def custom_enabled? + @custom_action && notification_setting&.event_enabled?(@custom_action) + end + def unsubscribed? return false unless @target return false unless @target.respond_to?(:subscriptions) @@ -98,7 +97,7 @@ class NotificationRecipient def excluded_watcher_action? return false unless @custom_action - return false if raw_notification_level == :custom + return false if notification_level == :custom NotificationSetting::EXCLUDED_WATCHER_EVENTS.include?(@custom_action) end -- cgit v1.2.1 From 57fb2d4f8f0c9f5dc563bdb0eb6935748674a299 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Mon, 21 Aug 2017 13:47:15 -0700 Subject: rm a comment that is a lie --- spec/services/notification_service_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 5223152ce66..5b349017c8b 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -151,7 +151,6 @@ describe NotificationService, :mailer do add_users_with_subscription(note.project, issue) reset_delivered_emails! - # Ensure create SentNotification by noteable = issue 6 times, not noteable = note expect(SentNotification).to receive(:record).with(issue, any_args).exactly(9).times notification.new_note(note) -- cgit v1.2.1 From bf7f23531d78c02836decae88895609b14a2980f Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Mon, 21 Aug 2017 14:19:53 -0700 Subject: add a changelog --- changelogs/unreleased/bugfix-notify-custom-participants.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/bugfix-notify-custom-participants.yml diff --git a/changelogs/unreleased/bugfix-notify-custom-participants.yml b/changelogs/unreleased/bugfix-notify-custom-participants.yml new file mode 100644 index 00000000000..32ba1076b09 --- /dev/null +++ b/changelogs/unreleased/bugfix-notify-custom-participants.yml @@ -0,0 +1,5 @@ +--- +title: 13680-notify-custom-participants +merge_request: 13680 +author: jneen +type: fixed -- cgit v1.2.1 From c13f712c77e0837760e79293b6fb41c734741e77 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Fri, 18 Aug 2017 17:43:23 -0700 Subject: implement Repository#== so that with_repo_branch_commit can properly short-circuit --- app/models/repository.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/repository.rb b/app/models/repository.rb index c1e4fcf94a4..1c3080c0efd 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -60,6 +60,12 @@ class Repository @project = project end + def equals(other) + @disk_path == other.disk_path + end + + alias_method :==, :equals + def raw_repository return nil unless full_path -- cgit v1.2.1 From 00b440443808fba04fc55f7e77c61f79e29c21ea Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Mon, 21 Aug 2017 15:20:44 -0700 Subject: skip the branch fetch if we already have the sha --- app/models/repository.rb | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 1c3080c0efd..61fab9764e8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -991,23 +991,27 @@ class Repository end def with_repo_branch_commit(start_repository, start_branch_name) - return yield(nil) if start_repository.empty_repo? + tmp_ref = nil + return yield nil if start_repository.empty_repo? - branch_name_or_sha = + branch_commit = if start_repository == self - start_branch_name + commit(start_branch_name) else - tmp_ref = fetch_ref( - start_repository.path_to_repo, - "#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}", - "refs/tmp/#{SecureRandom.hex}/head" - ) - - start_repository.commit(start_branch_name).sha + sha = start_repository.find_branch(start_branch_name).target + commit(sha) || + begin + tmp_ref = fetch_ref( + start_repository.path_to_repo, + "#{Gitlab::Git::BRANCH_REF_PREFIX}#{start_branch_name}", + "refs/tmp/#{SecureRandom.hex}/head" + ) + + commit(start_repository.commit(start_branch_name).sha) + end end - yield(commit(branch_name_or_sha)) - + yield branch_commit ensure rugged.references.delete(tmp_ref) if tmp_ref end -- cgit v1.2.1 From 75fa692d8def8fed50332f7846dbd8aa058c1d02 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 10:40:56 +0200 Subject: Include build queue worker in the processing group --- app/workers/build_queue_worker.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/workers/build_queue_worker.rb b/app/workers/build_queue_worker.rb index fa9e097e40a..e5ceb9ef715 100644 --- a/app/workers/build_queue_worker.rb +++ b/app/workers/build_queue_worker.rb @@ -1,6 +1,8 @@ class BuildQueueWorker include Sidekiq::Worker - include BuildQueue + include PipelineQueue + + enqueue_in group: :processing def perform(build_id) Ci::Build.find_by(id: build_id).try do |build| -- cgit v1.2.1 From 086f0351df9f013b4b0f3f80f7ab5d18be0d1733 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 10:57:52 +0200 Subject: Do not fire synrchonous hooks when creating a job Fire asynchronous hooks instead. --- app/models/ci/build.rb | 5 ++++- spec/models/ci/build_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 4692fb5644a..936e3c83dfd 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -46,7 +46,10 @@ module Ci before_save :ensure_token before_destroy { unscoped_project } - after_create :execute_hooks + after_create do |build| + BuildHooksWorker.perform_async(build.id) + end + after_commit :update_project_statistics_after_save, on: [:create, :update] after_commit :update_project_statistics, on: :destroy diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 767f0ad9e65..4f77f0d85cd 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -21,6 +21,16 @@ describe Ci::Build do it { is_expected.to respond_to(:has_trace?) } it { is_expected.to respond_to(:trace) } + describe 'callbacks' do + context 'when running after_create callback' do + it 'triggers asynchronous build hooks worker' do + expect(BuildHooksWorker).to receive(:perform_async) + + create(:ci_build) + end + end + end + describe '.manual_actions' do let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) } let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) } -- cgit v1.2.1 From 0a2998b3193cbded4f6b5a33964e9a8d953ecbda Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 11:21:12 +0200 Subject: Add changelog for asynchronous job events fix --- .../unreleased/backstage-gb-after-save-asynchronous-job-hooks.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/backstage-gb-after-save-asynchronous-job-hooks.yml diff --git a/changelogs/unreleased/backstage-gb-after-save-asynchronous-job-hooks.yml b/changelogs/unreleased/backstage-gb-after-save-asynchronous-job-hooks.yml new file mode 100644 index 00000000000..fd0b7c4f43c --- /dev/null +++ b/changelogs/unreleased/backstage-gb-after-save-asynchronous-job-hooks.yml @@ -0,0 +1,5 @@ +--- +title: Fire hooks asynchronously when creating a new job to improve performance +merge_request: 13734 +author: +type: changed -- cgit v1.2.1 From beb8f46e946f217f6132670c16d118f973012a48 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 11:29:42 +0200 Subject: Fix typo in shared examples name in worker specs --- spec/workers/build_coverage_worker_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb index e49750f6a3e..a679e5c7af6 100644 --- a/spec/workers/build_coverage_worker_spec.rb +++ b/spec/workers/build_coverage_worker_spec.rb @@ -21,5 +21,5 @@ describe BuildCoverageWorker do end end - it_behaves_like 'sidekiq_worker' + it_behaves_like 'sidekiq worker' end -- cgit v1.2.1 From c29247aadf97e17647d1c44d4aa2646cca6dcebc Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 11:34:29 +0200 Subject: Fix inconsistent Sidekiq queues names in worker specs --- spec/support/shared_examples/sidekiq_worker_shared_examples.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/shared_examples/sidekiq_worker_shared_examples.rb b/spec/support/shared_examples/sidekiq_worker_shared_examples.rb index 712cad2a0d9..4ff267a7838 100644 --- a/spec/support/shared_examples/sidekiq_worker_shared_examples.rb +++ b/spec/support/shared_examples/sidekiq_worker_shared_examples.rb @@ -5,6 +5,6 @@ shared_examples 'sidekiq worker' do end it 'is going to be processed inside a known sidekiq queue' do - expect(described_class.sidekiq_options['queue']).to be_in queues + expect(described_class.sidekiq_options['queue'].to_s).to be_in queues end end -- cgit v1.2.1 From 75dca155af7a707b5d4a9860008d8bbaea6c2537 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 11:37:35 +0200 Subject: Fix incorrect `let` in pipeline metrics worker specs --- spec/workers/pipeline_metrics_worker_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb index dac0b24d24a..69ad4ddea04 100644 --- a/spec/workers/pipeline_metrics_worker_spec.rb +++ b/spec/workers/pipeline_metrics_worker_spec.rb @@ -2,7 +2,12 @@ require 'spec_helper' describe PipelineMetricsWorker do let(:project) { create(:project, :repository) } - let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref, head_pipeline: pipeline) } + + let!(:merge_request) do + create(:merge_request, source_project: project, + source_branch: pipeline.ref, + head_pipeline: pipeline) + end let(:pipeline) do create(:ci_empty_pipeline, @@ -14,6 +19,8 @@ describe PipelineMetricsWorker do finished_at: Time.now) end + let(:status) { 'pending' } + describe '#perform' do before do described_class.new.perform(pipeline.id) -- cgit v1.2.1 From 73187801df9a128a73b36672c64fc69a87e3c519 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 12:09:22 +0200 Subject: Revert adding shared examples for every sidekiq worker Since this already exists in `every_sidekiq_worker_spec.rb`. --- spec/support/shared_examples/sidekiq_worker_shared_examples.rb | 10 ---------- spec/workers/authorized_projects_worker_spec.rb | 2 -- spec/workers/background_migration_worker_spec.rb | 2 -- spec/workers/build_coverage_worker_spec.rb | 2 -- spec/workers/build_finished_worker_spec.rb | 2 -- spec/workers/build_hooks_worker_spec.rb | 2 -- spec/workers/build_success_worker_spec.rb | 2 -- spec/workers/create_gpg_signature_worker_spec.rb | 2 -- spec/workers/delete_merged_branches_worker_spec.rb | 2 -- spec/workers/delete_user_worker_spec.rb | 2 -- spec/workers/email_receiver_worker_spec.rb | 2 -- spec/workers/emails_on_push_worker_spec.rb | 2 -- spec/workers/every_sidekiq_worker_spec.rb | 2 -- spec/workers/expire_build_artifacts_worker_spec.rb | 2 -- spec/workers/expire_build_instance_artifacts_worker_spec.rb | 2 -- spec/workers/expire_job_cache_worker_spec.rb | 2 -- spec/workers/expire_pipeline_cache_worker_spec.rb | 2 -- spec/workers/git_garbage_collect_worker_spec.rb | 2 -- spec/workers/gitlab_usage_ping_worker_spec.rb | 2 -- spec/workers/group_destroy_worker_spec.rb | 2 -- spec/workers/invalid_gpg_signature_update_worker_spec.rb | 2 -- spec/workers/merge_worker_spec.rb | 2 -- spec/workers/namespaceless_project_destroy_worker_spec.rb | 2 -- spec/workers/new_issue_worker_spec.rb | 2 -- spec/workers/new_merge_request_worker_spec.rb | 2 -- spec/workers/new_note_worker_spec.rb | 2 -- spec/workers/pipeline_hooks_worker_spec.rb | 2 -- spec/workers/pipeline_metrics_worker_spec.rb | 2 -- spec/workers/pipeline_notification_worker_spec.rb | 2 -- spec/workers/pipeline_process_worker_spec.rb | 2 -- spec/workers/pipeline_schedule_worker_spec.rb | 2 -- spec/workers/pipeline_success_worker_spec.rb | 2 -- spec/workers/pipeline_update_worker_spec.rb | 2 -- spec/workers/post_receive_spec.rb | 2 -- spec/workers/process_commit_worker_spec.rb | 2 -- spec/workers/project_cache_worker_spec.rb | 2 -- spec/workers/project_destroy_worker_spec.rb | 2 -- spec/workers/propagate_service_template_worker_spec.rb | 2 -- spec/workers/prune_old_events_worker_spec.rb | 2 -- spec/workers/reactive_caching_worker_spec.rb | 2 -- spec/workers/remove_expired_group_links_worker_spec.rb | 2 -- spec/workers/remove_expired_members_worker_spec.rb | 2 -- spec/workers/remove_old_web_hook_logs_worker_spec.rb | 2 -- spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb | 2 -- spec/workers/repository_fork_worker_spec.rb | 2 -- spec/workers/repository_import_worker_spec.rb | 2 -- spec/workers/schedule_update_user_activity_worker_spec.rb | 2 -- spec/workers/stuck_ci_jobs_worker_spec.rb | 2 -- spec/workers/stuck_import_jobs_worker_spec.rb | 2 -- spec/workers/stuck_merge_jobs_worker_spec.rb | 2 -- spec/workers/system_hook_push_worker_spec.rb | 2 -- spec/workers/trending_projects_worker_spec.rb | 2 -- spec/workers/update_merge_requests_worker_spec.rb | 2 -- spec/workers/update_user_activity_worker_spec.rb | 2 -- spec/workers/upload_checksum_worker_spec.rb | 2 -- spec/workers/use_key_worker_spec.rb | 2 -- 56 files changed, 120 deletions(-) delete mode 100644 spec/support/shared_examples/sidekiq_worker_shared_examples.rb diff --git a/spec/support/shared_examples/sidekiq_worker_shared_examples.rb b/spec/support/shared_examples/sidekiq_worker_shared_examples.rb deleted file mode 100644 index 4ff267a7838..00000000000 --- a/spec/support/shared_examples/sidekiq_worker_shared_examples.rb +++ /dev/null @@ -1,10 +0,0 @@ -shared_examples 'sidekiq worker' do - let(:queues) do - YAML.load_file(Rails.root.join('config', 'sidekiq_queues.yml')) - .fetch(:queues, []).map(&:first) - end - - it 'is going to be processed inside a known sidekiq queue' do - expect(described_class.sidekiq_options['queue'].to_s).to be_in queues - end -end diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb index bf9425b3d09..03b9b99e263 100644 --- a/spec/workers/authorized_projects_worker_spec.rb +++ b/spec/workers/authorized_projects_worker_spec.rb @@ -47,6 +47,4 @@ describe AuthorizedProjectsWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb index 69971cf9243..4f6e3474634 100644 --- a/spec/workers/background_migration_worker_spec.rb +++ b/spec/workers/background_migration_worker_spec.rb @@ -41,6 +41,4 @@ describe BackgroundMigrationWorker, :sidekiq do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb index a679e5c7af6..ba20488f663 100644 --- a/spec/workers/build_coverage_worker_spec.rb +++ b/spec/workers/build_coverage_worker_spec.rb @@ -20,6 +20,4 @@ describe BuildCoverageWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb index 463e8c6a60a..2868167c7d4 100644 --- a/spec/workers/build_finished_worker_spec.rb +++ b/spec/workers/build_finished_worker_spec.rb @@ -27,6 +27,4 @@ describe BuildFinishedWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb index 3d98ffabf0a..97654a93f5c 100644 --- a/spec/workers/build_hooks_worker_spec.rb +++ b/spec/workers/build_hooks_worker_spec.rb @@ -20,6 +20,4 @@ describe BuildHooksWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb index a82ed5c187d..dba70883130 100644 --- a/spec/workers/build_success_worker_spec.rb +++ b/spec/workers/build_success_worker_spec.rb @@ -33,6 +33,4 @@ describe BuildSuccessWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/create_gpg_signature_worker_spec.rb b/spec/workers/create_gpg_signature_worker_spec.rb index 0cfa957be06..54978baca88 100644 --- a/spec/workers/create_gpg_signature_worker_spec.rb +++ b/spec/workers/create_gpg_signature_worker_spec.rb @@ -36,6 +36,4 @@ describe CreateGpgSignatureWorker do described_class.new.perform(anything, nonexisting_project_id) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/delete_merged_branches_worker_spec.rb b/spec/workers/delete_merged_branches_worker_spec.rb index da20d4e7e3f..39009d9e4b2 100644 --- a/spec/workers/delete_merged_branches_worker_spec.rb +++ b/spec/workers/delete_merged_branches_worker_spec.rb @@ -16,6 +16,4 @@ describe DeleteMergedBranchesWorker do expect(worker.perform('unknown', project.owner.id)).to be_falsy end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb index 24fcf41a0c8..36594515005 100644 --- a/spec/workers/delete_user_worker_spec.rb +++ b/spec/workers/delete_user_worker_spec.rb @@ -17,6 +17,4 @@ describe DeleteUserWorker do described_class.new.perform(current_user.id, user.id, "test" => "test") end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb index d8ffdd4b5ed..e4e77c667b3 100644 --- a/spec/workers/email_receiver_worker_spec.rb +++ b/spec/workers/email_receiver_worker_spec.rb @@ -60,6 +60,4 @@ describe EmailReceiverWorker, :mailer do described_class.new.perform(raw_message) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb index 28031e2292c..318aad4bc1e 100644 --- a/spec/workers/emails_on_push_worker_spec.rb +++ b/spec/workers/emails_on_push_worker_spec.rb @@ -127,6 +127,4 @@ describe EmailsOnPushWorker, :mailer do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb index 34f5bfc8c0c..30908534eb3 100644 --- a/spec/workers/every_sidekiq_worker_spec.rb +++ b/spec/workers/every_sidekiq_worker_spec.rb @@ -41,6 +41,4 @@ describe 'Every Sidekiq worker' do expect(queue_names).to include(worker.sidekiq_options['queue'].to_s) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb index 751e4dfebd8..b47b4a02a68 100644 --- a/spec/workers/expire_build_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_artifacts_worker_spec.rb @@ -47,6 +47,4 @@ describe ExpireBuildArtifactsWorker do Sidekiq::Queues.jobs_by_worker['ExpireBuildInstanceArtifactsWorker'] end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_build_instance_artifacts_worker_spec.rb b/spec/workers/expire_build_instance_artifacts_worker_spec.rb index e1e6a5434fc..bed5c5e2ecb 100644 --- a/spec/workers/expire_build_instance_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_instance_artifacts_worker_spec.rb @@ -74,6 +74,4 @@ describe ExpireBuildInstanceArtifactsWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb index 552e2c350de..1b614342a18 100644 --- a/spec/workers/expire_job_cache_worker_spec.rb +++ b/spec/workers/expire_job_cache_worker_spec.rb @@ -28,6 +28,4 @@ describe ExpireJobCacheWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb index 85b24d5a8f0..54c9a69d329 100644 --- a/spec/workers/expire_pipeline_cache_worker_spec.rb +++ b/spec/workers/expire_pipeline_cache_worker_spec.rb @@ -43,6 +43,4 @@ describe ExpirePipelineCacheWorker do subject.perform(pipeline.id) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb index f2917986804..05f971dfd13 100644 --- a/spec/workers/git_garbage_collect_worker_spec.rb +++ b/spec/workers/git_garbage_collect_worker_spec.rb @@ -131,8 +131,6 @@ describe GitGarbageCollectWorker do end end - it_behaves_like 'sidekiq worker' - # Create a new commit on a random new branch def create_objects(project) rugged = project.repository.rugged diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb index f5ff6736993..49b4e04dc7c 100644 --- a/spec/workers/gitlab_usage_ping_worker_spec.rb +++ b/spec/workers/gitlab_usage_ping_worker_spec.rb @@ -10,6 +10,4 @@ describe GitlabUsagePingWorker do subject.perform end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/group_destroy_worker_spec.rb b/spec/workers/group_destroy_worker_spec.rb index 2f0c55b1b91..a170c84ab12 100644 --- a/spec/workers/group_destroy_worker_spec.rb +++ b/spec/workers/group_destroy_worker_spec.rb @@ -16,6 +16,4 @@ describe GroupDestroyWorker do expect(Dir.exist?(project.path)).to be_falsey end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb index 178dc024201..5972696515b 100644 --- a/spec/workers/invalid_gpg_signature_update_worker_spec.rb +++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb @@ -26,6 +26,4 @@ describe InvalidGpgSignatureUpdateWorker do described_class.new.perform(nonexisting_gpg_key_id) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb index b63c184fdb1..ee51000161a 100644 --- a/spec/workers/merge_worker_spec.rb +++ b/spec/workers/merge_worker_spec.rb @@ -38,6 +38,4 @@ describe MergeWorker do expect { worker.perform(merge_request.id, user.id, {}) } .to change { merge_request.reload.merge_jid }.from(nil).to('999') end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb index 6d75e7fbfb8..f2706254284 100644 --- a/spec/workers/namespaceless_project_destroy_worker_spec.rb +++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb @@ -76,6 +76,4 @@ describe NamespacelessProjectDestroyWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb index e82302d5cfe..4e15ccc534b 100644 --- a/spec/workers/new_issue_worker_spec.rb +++ b/spec/workers/new_issue_worker_spec.rb @@ -51,6 +51,4 @@ describe NewIssueWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb index a7e2e4376d6..9e0cbde45b1 100644 --- a/spec/workers/new_merge_request_worker_spec.rb +++ b/spec/workers/new_merge_request_worker_spec.rb @@ -53,6 +53,4 @@ describe NewMergeRequestWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb index d935a0ae3b4..575361c93d4 100644 --- a/spec/workers/new_note_worker_spec.rb +++ b/spec/workers/new_note_worker_spec.rb @@ -46,6 +46,4 @@ describe NewNoteWorker do described_class.new.perform(unexistent_note_id) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb index 50b724d0111..035e329839f 100644 --- a/spec/workers/pipeline_hooks_worker_spec.rb +++ b/spec/workers/pipeline_hooks_worker_spec.rb @@ -20,6 +20,4 @@ describe PipelineHooksWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb index 69ad4ddea04..896f9e6e7f2 100644 --- a/spec/workers/pipeline_metrics_worker_spec.rb +++ b/spec/workers/pipeline_metrics_worker_spec.rb @@ -54,6 +54,4 @@ describe PipelineMetricsWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb index 072866bf375..eb539ffd893 100644 --- a/spec/workers/pipeline_notification_worker_spec.rb +++ b/spec/workers/pipeline_notification_worker_spec.rb @@ -16,6 +16,4 @@ describe PipelineNotificationWorker, :mailer do subject.perform(Ci::Pipeline.maximum(:id).to_i.succ) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb index 81570c685ed..86e9d7f6684 100644 --- a/spec/workers/pipeline_process_worker_spec.rb +++ b/spec/workers/pipeline_process_worker_spec.rb @@ -19,6 +19,4 @@ describe PipelineProcessWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb index 4cea91a237c..75197039f5a 100644 --- a/spec/workers/pipeline_schedule_worker_spec.rb +++ b/spec/workers/pipeline_schedule_worker_spec.rb @@ -62,6 +62,4 @@ describe PipelineScheduleWorker do expect { subject }.not_to change { project.pipelines.count } end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_success_worker_spec.rb b/spec/workers/pipeline_success_worker_spec.rb index 83d006337bd..d1c84adda6f 100644 --- a/spec/workers/pipeline_success_worker_spec.rb +++ b/spec/workers/pipeline_success_worker_spec.rb @@ -21,6 +21,4 @@ describe PipelineSuccessWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb index cd8ae030ab9..0b456cfd0da 100644 --- a/spec/workers/pipeline_update_worker_spec.rb +++ b/spec/workers/pipeline_update_worker_spec.rb @@ -19,6 +19,4 @@ describe PipelineUpdateWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 4968758cb6b..af6a3c9f6c7 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -140,6 +140,4 @@ describe PostReceive do described_class.new.perform(gl_repository, key_id, base64_changes) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb index 0580ea60742..24f8ca67594 100644 --- a/spec/workers/process_commit_worker_spec.rb +++ b/spec/workers/process_commit_worker_spec.rb @@ -134,6 +134,4 @@ describe ProcessCommitWorker do expect(commit.authored_date).to be_an_instance_of(Time) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index 20d18a433d3..6b1f2ff3227 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -87,6 +87,4 @@ describe ProjectCacheWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb index 7c2a293c5f3..f19c9dff941 100644 --- a/spec/workers/project_destroy_worker_spec.rb +++ b/spec/workers/project_destroy_worker_spec.rb @@ -33,6 +33,4 @@ describe ProjectDestroyWorker do end.not_to raise_error end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb index 21df8eb489e..b8b65ead9b3 100644 --- a/spec/workers/propagate_service_template_worker_spec.rb +++ b/spec/workers/propagate_service_template_worker_spec.rb @@ -26,6 +26,4 @@ describe PropagateServiceTemplateWorker do subject.perform(service_template.id) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/prune_old_events_worker_spec.rb b/spec/workers/prune_old_events_worker_spec.rb index e9b3061a1be..ea974355050 100644 --- a/spec/workers/prune_old_events_worker_spec.rb +++ b/spec/workers/prune_old_events_worker_spec.rb @@ -23,6 +23,4 @@ describe PruneOldEventsWorker do expect(exactly_12_months_event).to be_present end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/reactive_caching_worker_spec.rb b/spec/workers/reactive_caching_worker_spec.rb index 44aa520d102..5f4453c15d6 100644 --- a/spec/workers/reactive_caching_worker_spec.rb +++ b/spec/workers/reactive_caching_worker_spec.rb @@ -12,6 +12,4 @@ describe ReactiveCachingWorker do subject end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_expired_group_links_worker_spec.rb b/spec/workers/remove_expired_group_links_worker_spec.rb index 2615b049650..689bc3d27b4 100644 --- a/spec/workers/remove_expired_group_links_worker_spec.rb +++ b/spec/workers/remove_expired_group_links_worker_spec.rb @@ -21,6 +21,4 @@ describe RemoveExpiredGroupLinksWorker do expect(non_expiring_project_group_link.reload).to be_present end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_expired_members_worker_spec.rb b/spec/workers/remove_expired_members_worker_spec.rb index 1b0af031a83..058fdf4c009 100644 --- a/spec/workers/remove_expired_members_worker_spec.rb +++ b/spec/workers/remove_expired_members_worker_spec.rb @@ -55,6 +55,4 @@ describe RemoveExpiredMembersWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_old_web_hook_logs_worker_spec.rb b/spec/workers/remove_old_web_hook_logs_worker_spec.rb index 4a504f34367..6d26ba5dfa0 100644 --- a/spec/workers/remove_old_web_hook_logs_worker_spec.rb +++ b/spec/workers/remove_old_web_hook_logs_worker_spec.rb @@ -15,6 +15,4 @@ describe RemoveOldWebHookLogsWorker do expect(WebHookLog.all).not_to include(week_old_record, three_days_old_record) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb index fccb64717ad..57f83c1dbe9 100644 --- a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb +++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb @@ -52,6 +52,4 @@ describe RemoveUnreferencedLfsObjectsWorker do expect(LfsObject.where(id: referenced_lfs_object2.id)).to be_empty end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 6550de6f893..d9e9409840f 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -69,6 +69,4 @@ describe RepositoryForkWorker do expect(project.reload.import_status).to eq('failed') end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb index d67891aa388..100dfc32bbe 100644 --- a/spec/workers/repository_import_worker_spec.rb +++ b/spec/workers/repository_import_worker_spec.rb @@ -43,6 +43,4 @@ describe RepositoryImportWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/schedule_update_user_activity_worker_spec.rb b/spec/workers/schedule_update_user_activity_worker_spec.rb index 362cd2a6d92..32c59381b01 100644 --- a/spec/workers/schedule_update_user_activity_worker_spec.rb +++ b/spec/workers/schedule_update_user_activity_worker_spec.rb @@ -22,6 +22,4 @@ describe ScheduleUpdateUserActivityWorker, :clean_gitlab_redis_shared_state do subject.perform(1) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb index f64de2a9c21..549635f7f33 100644 --- a/spec/workers/stuck_ci_jobs_worker_spec.rb +++ b/spec/workers/stuck_ci_jobs_worker_spec.rb @@ -132,6 +132,4 @@ describe StuckCiJobsWorker do worker.perform end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb index 64a69fc4872..a82eb54ffe4 100644 --- a/spec/workers/stuck_import_jobs_worker_spec.rb +++ b/spec/workers/stuck_import_jobs_worker_spec.rb @@ -33,6 +33,4 @@ describe StuckImportJobsWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb index a989942f913..a5ad78393c9 100644 --- a/spec/workers/stuck_merge_jobs_worker_spec.rb +++ b/spec/workers/stuck_merge_jobs_worker_spec.rb @@ -47,6 +47,4 @@ describe StuckMergeJobsWorker do end end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/system_hook_push_worker_spec.rb b/spec/workers/system_hook_push_worker_spec.rb index e0588e2a1b3..b1d446ed25f 100644 --- a/spec/workers/system_hook_push_worker_spec.rb +++ b/spec/workers/system_hook_push_worker_spec.rb @@ -16,6 +16,4 @@ describe SystemHookPushWorker do subject.perform(push_data, :push_hooks) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/trending_projects_worker_spec.rb b/spec/workers/trending_projects_worker_spec.rb index a9e0c9d1d77..c3c6fdcf2d5 100644 --- a/spec/workers/trending_projects_worker_spec.rb +++ b/spec/workers/trending_projects_worker_spec.rb @@ -8,6 +8,4 @@ describe TrendingProjectsWorker do described_class.new.perform end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/update_merge_requests_worker_spec.rb b/spec/workers/update_merge_requests_worker_spec.rb index f40c9012db9..558ff9109ec 100644 --- a/spec/workers/update_merge_requests_worker_spec.rb +++ b/spec/workers/update_merge_requests_worker_spec.rb @@ -24,6 +24,4 @@ describe UpdateMergeRequestsWorker do perform end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/update_user_activity_worker_spec.rb b/spec/workers/update_user_activity_worker_spec.rb index 9cd7ffc2ab4..268ca1d81f2 100644 --- a/spec/workers/update_user_activity_worker_spec.rb +++ b/spec/workers/update_user_activity_worker_spec.rb @@ -32,6 +32,4 @@ describe UpdateUserActivityWorker, :clean_gitlab_redis_shared_state do expect(Gitlab::UserActivities.new.to_a).to be_empty end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/upload_checksum_worker_spec.rb b/spec/workers/upload_checksum_worker_spec.rb index 735aeec1046..911360da66c 100644 --- a/spec/workers/upload_checksum_worker_spec.rb +++ b/spec/workers/upload_checksum_worker_spec.rb @@ -16,6 +16,4 @@ describe UploadChecksumWorker do expect(upload).to have_received(:save!) end end - - it_behaves_like 'sidekiq worker' end diff --git a/spec/workers/use_key_worker_spec.rb b/spec/workers/use_key_worker_spec.rb index c7de5bb6117..e50c788b82a 100644 --- a/spec/workers/use_key_worker_spec.rb +++ b/spec/workers/use_key_worker_spec.rb @@ -20,6 +20,4 @@ describe UseKeyWorker do expect(worker.perform(key.id + 1)).to eq false end end - - it_behaves_like 'sidekiq worker' end -- cgit v1.2.1 From 193b199672f5229dd6d2cff30fc8c794bb774bbd Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 12:47:20 +0200 Subject: Add Sidekiq migration helpers for migrating queues --- lib/gitlab/database/migration_helpers.rb | 14 ++++++ spec/lib/gitlab/database/migration_helpers_spec.rb | 51 ++++++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index b83e633c7ed..ecb23e79e80 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -611,6 +611,20 @@ module Gitlab remove_foreign_key(*args) rescue ArgumentError end + + def sidekiq_queue_migrate(queue_from, to: queue_to) + while sidekiq_queue_length(queue_from) > 0 + Sidekiq.redis do |conn| + conn.rpoplpush "queue:#{queue_from}", "queue:#{to}" + end + end + end + + def sidekiq_queue_length(queue_name) + Sidekiq.redis do |conn| + conn.llen("queue:#{queue_name}") + end + end end end end diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index ec2274a70aa..fbbb07f2208 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' describe Gitlab::Database::MigrationHelpers do let(:model) do - ActiveRecord::Migration.new.extend( - described_class - ) + ActiveRecord::Migration.new.extend(described_class) end before do @@ -845,4 +843,51 @@ describe Gitlab::Database::MigrationHelpers do end end end + + describe 'sidekiq migration helpers', :sidekiq, :redis do + let(:worker) do + Class.new do + include Sidekiq::Worker + sidekiq_options queue: 'test' + end + end + + describe '#sidekiq_queue_length' do + context 'when queue is empty' do + it 'returns zero' do + Sidekiq::Testing.disable! do + expect(model.sidekiq_queue_length('test')).to eq 0 + end + end + end + + context 'when queue contains jobs' do + it 'returns correct size of the queue' do + Sidekiq::Testing.disable! do + worker.perform_async('Something', [1]) + worker.perform_async('Something', [2]) + + expect(model.sidekiq_queue_length('test')).to eq 2 + end + end + end + end + + describe '#migrate_sidekiq_queue' do + it 'migrates jobs from one sidekiq queue to another' do + Sidekiq::Testing.disable! do + worker.perform_async('Something', [1]) + worker.perform_async('Something', [2]) + + expect(model.sidekiq_queue_length('test')).to eq 2 + expect(model.sidekiq_queue_length('new_test')).to eq 0 + + model.sidekiq_queue_migrate('test', to: 'new_test') + + expect(model.sidekiq_queue_length('test')).to eq 0 + expect(model.sidekiq_queue_length('new_test')).to eq 2 + end + end + end + end end -- cgit v1.2.1 From 8b4a335ff1b0c7f4f575e63b6399889faec28456 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 12:47:37 +0200 Subject: Add migration that migrates CI/CD queues --- .../20170822101017_migrate_pipeline_sidekiq_queues.rb | 14 ++++++++++++++ db/schema.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb diff --git a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb new file mode 100644 index 00000000000..48fa3af0c60 --- /dev/null +++ b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb @@ -0,0 +1,14 @@ +class MigratePipelineSidekiqQueues < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + sidekiq_queue_migrate 'build', to: 'pipeline_default' + sidekiq_queue_migrate 'pipeline', to: 'pipeline_default' + end + + def down + sidekiq_queue_migrate 'pipeline_default', to: 'pipeline' + end +end diff --git a/db/schema.rb b/db/schema.rb index 80f8cde1818..d22e8235a09 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170820100558) do +ActiveRecord::Schema.define(version: 20170822101017) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" -- cgit v1.2.1 From a7c54a478e6809eb754119b492250c8c1b2f4512 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 13:02:24 +0200 Subject: Add specs for pipeline sidekiq queues migration --- .../migrate_pipeline_sidekiq_queues_spec.rb | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb diff --git a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb new file mode 100644 index 00000000000..fff531a78c5 --- /dev/null +++ b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20170822101017_migrate_pipeline_sidekiq_queues.rb') + +describe MigratePipelineSidekiqQueues, :sidekiq, :redis do + include Gitlab::Database::MigrationHelpers + + context 'when there are jobs in the queues' do + it 'correctly migrates queue when migrating up' do + Sidekiq::Testing.disable! do + stubbed_worker(queue: :pipeline).perform_async('Something', [1]) + stubbed_worker(queue: :build).perform_async('Something', [1]) + + described_class.new.up + + expect(sidekiq_queue_length('pipeline')).to eq 0 + expect(sidekiq_queue_length('build')).to eq 0 + expect(sidekiq_queue_length('pipeline_default')).to eq 2 + end + end + + it 'correctly migrates queue when migrating down' do + Sidekiq::Testing.disable! do + stubbed_worker(queue: :pipeline_default).perform_async('Class', [1]) + stubbed_worker(queue: :pipeline_default).perform_async('Class', [2]) + + described_class.new.down + + expect(sidekiq_queue_length('pipeline')).to eq 2 + expect(sidekiq_queue_length('pipeline_default')).to eq 0 + end + end + end + + context 'when there are no jobs in the queues' do + it 'does not raise error when migrating up' do + expect { described_class.new.up }.not_to raise_error + end + + it 'does not raise error when migrating down' do + expect { described_class.new.down }.not_to raise_error + end + end + + def stubbed_worker(queue:) + Class.new do + include Sidekiq::Worker + sidekiq_options queue: queue + end + end +end -- cgit v1.2.1 From 37881ebb75be2069f49f6faf6e01ca73223e998f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 14:04:34 +0200 Subject: Set a default CI/CD status when it is not known --- app/models/ci/stage.rb | 4 ++++ spec/models/ci/stage_spec.rb | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 4ee972fa68d..754c37518b3 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -17,6 +17,10 @@ module Ci validates :pipeline, presence: true, unless: :importing? validates :name, presence: true, unless: :importing? + after_initialize do |stage| + self.status = DEFAULT_STATUS if self.status.nil? + end + state_machine :status, initial: :created do event :enqueue do transition created: :pending diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb index 74c9d6145e2..586d073eb5e 100644 --- a/spec/models/ci/stage_spec.rb +++ b/spec/models/ci/stage_spec.rb @@ -38,6 +38,17 @@ describe Ci::Stage, :models do expect(stage.status).to eq 'success' end end + + context 'when stage status is not defined' do + before do + stage.update_column(:status, nil) + end + + it 'sets the default value' do + expect(described_class.find(stage.id).status) + .to eq 'created' + end + end end describe 'update_status' do -- cgit v1.2.1 From 3366e38cc1632eba4c9e8683555c6fde6efd5d48 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 14:57:54 +0200 Subject: Fix indentation in migration helpers --- spec/lib/gitlab/database/migration_helpers_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index fbbb07f2208..c25fd459dd7 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -875,18 +875,18 @@ describe Gitlab::Database::MigrationHelpers do describe '#migrate_sidekiq_queue' do it 'migrates jobs from one sidekiq queue to another' do - Sidekiq::Testing.disable! do - worker.perform_async('Something', [1]) - worker.perform_async('Something', [2]) + Sidekiq::Testing.disable! do + worker.perform_async('Something', [1]) + worker.perform_async('Something', [2]) - expect(model.sidekiq_queue_length('test')).to eq 2 - expect(model.sidekiq_queue_length('new_test')).to eq 0 + expect(model.sidekiq_queue_length('test')).to eq 2 + expect(model.sidekiq_queue_length('new_test')).to eq 0 - model.sidekiq_queue_migrate('test', to: 'new_test') + model.sidekiq_queue_migrate('test', to: 'new_test') - expect(model.sidekiq_queue_length('test')).to eq 0 - expect(model.sidekiq_queue_length('new_test')).to eq 2 - end + expect(model.sidekiq_queue_length('test')).to eq 0 + expect(model.sidekiq_queue_length('new_test')).to eq 2 + end end end end -- cgit v1.2.1 From a61f8c44bef6d3b8ad19b7791740960b4fd9a938 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 Aug 2017 14:59:16 +0200 Subject: Enqueue a new stage worker in CI/CD processing queue --- app/workers/stage_update_worker.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/workers/stage_update_worker.rb b/app/workers/stage_update_worker.rb index eef0b11e70b..c301cea5ad6 100644 --- a/app/workers/stage_update_worker.rb +++ b/app/workers/stage_update_worker.rb @@ -2,6 +2,8 @@ class StageUpdateWorker include Sidekiq::Worker include PipelineQueue + enqueue_in group: :processing + def perform(stage_id) Ci::Stage.find_by(id: stage_id).try do |stage| stage.update_status -- cgit v1.2.1 From b0f09406f50882c7e085c2a9b853be5dcf3d79dd Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 22 Aug 2017 14:04:54 +0100 Subject: Always return a simple diff viewer We didn't have a fallback case before, because we believed the conditions were exhaustive. They weren't, so we can always fallback to not previewing. --- lib/gitlab/diff/file.rb | 2 ++ spec/lib/gitlab/diff/file_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index 6d7de52cb80..17a9ec01637 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -250,6 +250,8 @@ module Gitlab DiffViewer::Renamed elsif mode_changed? DiffViewer::ModeChanged + else + DiffViewer::NoPreview end end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index d3d841b0668..ab60d62d88e 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -270,6 +270,20 @@ describe Gitlab::Diff::File do expect(diff_file.simple_viewer).to be_a(DiffViewer::ModeChanged) end end + + context 'when no other conditions apply' do + before do + allow(diff_file).to receive(:content_changed?).and_return(false) + allow(diff_file).to receive(:new_file?).and_return(false) + allow(diff_file).to receive(:deleted_file?).and_return(false) + allow(diff_file).to receive(:renamed_file?).and_return(false) + allow(diff_file).to receive(:mode_changed?).and_return(false) + end + + it 'returns a No Preview viewer' do + expect(diff_file.simple_viewer).to be_a(DiffViewer::NoPreview) + end + end end describe '#rich_viewer' do -- cgit v1.2.1 From dacca321af806c4955dd32d6402cb38044fa2b00 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 22 Aug 2017 14:36:17 +0100 Subject: Update the rbnacl gem to 4.0.2 --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index a0a9dddac10..df50b61e6fb 100644 --- a/Gemfile +++ b/Gemfile @@ -396,7 +396,7 @@ gem 'net-ssh', '~> 4.1.0' # Required for ED25519 SSH host key support group :ed25519 do gem 'rbnacl-libsodium' - gem 'rbnacl', '~> 3.2' + gem 'rbnacl', '~> 4.0' gem 'bcrypt_pbkdf', '~> 1.0' end diff --git a/Gemfile.lock b/Gemfile.lock index ec8349cd1df..f4f6b630a76 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -203,7 +203,7 @@ GEM multi_json fast_gettext (1.4.0) ffaker (2.4.0) - ffi (1.9.10) + ffi (1.9.18) flay (2.8.1) erubis (~> 2.7.0) path_expander (~> 1.0) @@ -682,7 +682,7 @@ GEM rake (12.0.0) rblineprof (0.3.6) debugger-ruby_core_source (~> 1.3) - rbnacl (3.4.0) + rbnacl (4.0.2) ffi rbnacl-libsodium (1.0.11) rbnacl (>= 3.0.1) @@ -1107,7 +1107,7 @@ DEPENDENCIES rainbow (~> 2.2) raindrops (~> 0.18) rblineprof (~> 0.3.6) - rbnacl (~> 3.2) + rbnacl (~> 4.0) rbnacl-libsodium rdoc (~> 4.2) re2 (~> 1.1.1) -- cgit v1.2.1 From 77c01b22d7e21cf20592e3d6d6f05a7beefc118c Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Tue, 22 Aug 2017 08:39:31 -0700 Subject: add a description to the changelog --- changelogs/unreleased/bugfix-notify-custom-participants.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/bugfix-notify-custom-participants.yml b/changelogs/unreleased/bugfix-notify-custom-participants.yml index 32ba1076b09..04fcb95e18a 100644 --- a/changelogs/unreleased/bugfix-notify-custom-participants.yml +++ b/changelogs/unreleased/bugfix-notify-custom-participants.yml @@ -1,5 +1,5 @@ --- -title: 13680-notify-custom-participants +title: Fixed: Notifications weren't sending to participating users with a `Custom` notification setting. merge_request: 13680 author: jneen type: fixed -- cgit v1.2.1 From da4c54e4fb81d5d93d63e4f472a4dcb1e4ff9521 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 08:32:44 +0200 Subject: Run job hooks after transation commits after create --- app/models/ci/build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 936e3c83dfd..095192e9894 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -47,7 +47,7 @@ module Ci before_destroy { unscoped_project } after_create do |build| - BuildHooksWorker.perform_async(build.id) + run_after_commit { BuildHooksWorker.perform_async(build.id) } end after_commit :update_project_statistics_after_save, on: [:create, :update] -- cgit v1.2.1 From faf92651aa5e9c6bcb88acac8de27c878d7edf06 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 08:58:55 +0200 Subject: Fix invalid default argument in migration helpers --- lib/gitlab/database/migration_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index ecb23e79e80..5e2c6cc5cad 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -612,7 +612,7 @@ module Gitlab rescue ArgumentError end - def sidekiq_queue_migrate(queue_from, to: queue_to) + def sidekiq_queue_migrate(queue_from, to:) while sidekiq_queue_length(queue_from) > 0 Sidekiq.redis do |conn| conn.rpoplpush "queue:#{queue_from}", "queue:#{to}" -- cgit v1.2.1 From b0d7918a6773fb7f1696f8077ba812bea23c0983 Mon Sep 17 00:00:00 2001 From: Fabio Busatto Date: Wed, 23 Aug 2017 08:17:20 +0000 Subject: Update README.md --- doc/ci/yaml/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 1869782fe6e..abf4ec7dbf8 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -1065,6 +1065,8 @@ a list of all previous jobs from which the artifacts should be downloaded. You can only define jobs from stages that are executed before the current one. An error will be shown if you define jobs from the current stage or next ones. Defining an empty array will skip downloading any artifacts for that job. +The status of the previous job is not considered when using `dependencies`, so +if it failed or it is a manual job that was not run, no error occurs. --- -- cgit v1.2.1 From 9b9309329207449ef022bdcf06bff5f8eae36032 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 13:05:36 +0200 Subject: Decouple GitOperationService from User --- app/models/repository.rb | 27 ++++++++++++++++++--------- app/services/git_hooks_service.rb | 6 +++--- app/services/git_operation_service.rb | 11 +++++++---- lib/gitlab/git/committer.rb | 21 +++++++++++++++++++++ spec/models/repository_spec.rb | 21 +++++++++++---------- 5 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 lib/gitlab/git/committer.rb diff --git a/app/models/repository.rb b/app/models/repository.rb index c1e4fcf94a4..3c5074e5157 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -164,7 +164,8 @@ class Repository return false unless newrev - GitOperationService.new(user, self).add_branch(branch_name, newrev) + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).add_branch(branch_name, newrev) after_create_branch find_branch(branch_name) @@ -176,7 +177,8 @@ class Repository return false unless newrev - GitOperationService.new(user, self).add_tag(tag_name, newrev, options) + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).add_tag(tag_name, newrev, options) find_tag(tag_name) end @@ -185,7 +187,8 @@ class Repository before_remove_branch branch = find_branch(branch_name) - GitOperationService.new(user, self).rm_branch(branch) + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).rm_branch(branch) after_remove_branch true @@ -195,7 +198,8 @@ class Repository before_remove_tag tag = find_tag(tag_name) - GitOperationService.new(user, self).rm_tag(tag) + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).rm_tag(tag) after_remove_tag true @@ -763,7 +767,8 @@ class Repository author_email: nil, author_name: nil, start_branch_name: nil, start_project: project) - GitOperationService.new(user, self).with_branch( + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -819,7 +824,8 @@ class Repository end def merge(user, source, merge_request, options = {}) - GitOperationService.new(user, self).with_branch( + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).with_branch( merge_request.target_branch) do |start_commit| our_commit = start_commit.sha their_commit = source @@ -846,7 +852,8 @@ class Repository def revert( user, commit, branch_name, start_branch_name: nil, start_project: project) - GitOperationService.new(user, self).with_branch( + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -869,7 +876,8 @@ class Repository def cherry_pick( user, commit, branch_name, start_branch_name: nil, start_project: project) - GitOperationService.new(user, self).with_branch( + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -894,7 +902,8 @@ class Repository end def resolve_conflicts(user, branch_name, params) - GitOperationService.new(user, self).with_branch(branch_name) do + committer = Gitlab::Git::Committer.from_user(user) + GitOperationService.new(committer, self).with_branch(branch_name) do committer = user_to_committer(user) create_commit(params.merge(author: committer, committer: committer)) diff --git a/app/services/git_hooks_service.rb b/app/services/git_hooks_service.rb index eab65d09299..e85007c26e0 100644 --- a/app/services/git_hooks_service.rb +++ b/app/services/git_hooks_service.rb @@ -3,9 +3,9 @@ class GitHooksService attr_accessor :oldrev, :newrev, :ref - def execute(user, project, oldrev, newrev, ref) + def execute(committer, project, oldrev, newrev, ref) @project = project - @user = Gitlab::GlId.gl_id(user) + @gl_id = committer.gl_id @oldrev = oldrev @newrev = newrev @ref = ref @@ -27,6 +27,6 @@ class GitHooksService def run_hook(name) hook = Gitlab::Git::Hook.new(name, @project) - hook.trigger(@user, oldrev, newrev, ref) + hook.trigger(@gl_id, oldrev, newrev, ref) end end diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb index 545ca0742e4..f7fce3d8a5d 100644 --- a/app/services/git_operation_service.rb +++ b/app/services/git_operation_service.rb @@ -1,8 +1,11 @@ class GitOperationService - attr_reader :user, :repository + attr_reader :committer, :repository - def initialize(new_user, new_repository) - @user = new_user + def initialize(committer, new_repository) + if committer && !committer.is_a?(Gitlab::Git::Committer) + raise "expected Gitlab::Git::Committer, got #{committer.inspect}" + end + @committer = committer @repository = new_repository end @@ -119,7 +122,7 @@ class GitOperationService def with_hooks(ref, newrev, oldrev) GitHooksService.new.execute( - user, + committer, repository.project, oldrev, newrev, diff --git a/lib/gitlab/git/committer.rb b/lib/gitlab/git/committer.rb new file mode 100644 index 00000000000..ef3576eaa1c --- /dev/null +++ b/lib/gitlab/git/committer.rb @@ -0,0 +1,21 @@ +module Gitlab + module Git + class Committer + attr_reader :name, :email, :gl_id + + def self.from_user(user) + new(user.name, user.email, Gitlab::GlId.gl_id(user)) + end + + def initialize(name, email, gl_id) + @name = name + @email = email + @gl_id = gl_id + end + + def ==(other) + [name, email, gl_id] == [other.name, other.email, other.gl_id] + end + end + end +end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 4926d5d6c49..0b1a35d1920 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -8,6 +8,7 @@ describe Repository, models: true do let(:repository) { project.repository } let(:broken_repository) { create(:project, :broken_storage).repository } let(:user) { create(:user) } + let(:committer) { Gitlab::Git::Committer.from_user(user) } let(:commit_options) do author = repository.user_to_committer(user) @@ -885,7 +886,7 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do expect_any_instance_of(GitHooksService).to receive(:execute) - .with(user, project, old_rev, blank_sha, 'refs/heads/feature') + .with(committer, project, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end @@ -928,20 +929,20 @@ describe Repository, models: true do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) expect(service).to receive(:execute) - .with(user, project, old_rev, new_rev, 'refs/heads/feature') + .with(committer, project, old_rev, new_rev, 'refs/heads/feature') .and_yield(service).and_return(true) end it 'runs without errors' do expect do - GitOperationService.new(user, repository).with_branch('feature') do + GitOperationService.new(committer, repository).with_branch('feature') do new_rev end end.not_to raise_error end it 'ensures the autocrlf Git option is set to :input' do - service = GitOperationService.new(user, repository) + service = GitOperationService.new(committer, repository) expect(service).to receive(:update_autocrlf_option) @@ -952,7 +953,7 @@ describe Repository, models: true do it 'updates the head' do expect(repository.find_branch('feature').dereferenced_target.id).to eq(old_rev) - GitOperationService.new(user, repository).with_branch('feature') do + GitOperationService.new(committer, repository).with_branch('feature') do new_rev end @@ -974,7 +975,7 @@ describe Repository, models: true do end expect do - GitOperationService.new(user, target_project.repository) + GitOperationService.new(committer, target_project.repository) .with_branch('feature', start_project: project, &:itself) @@ -996,7 +997,7 @@ describe Repository, models: true do repository.add_branch(user, branch, old_rev) expect do - GitOperationService.new(user, repository).with_branch(branch) do + GitOperationService.new(committer, repository).with_branch(branch) do new_rev end end.not_to raise_error @@ -1014,7 +1015,7 @@ describe Repository, models: true do # Updating 'master' to new_rev would lose the commits on 'master' that # are not contained in new_rev. This should not be allowed. expect do - GitOperationService.new(user, repository).with_branch(branch) do + GitOperationService.new(committer, repository).with_branch(branch) do new_rev end end.to raise_error(Repository::CommitError) @@ -1026,7 +1027,7 @@ describe Repository, models: true do allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) expect do - GitOperationService.new(user, repository).with_branch('feature') do + GitOperationService.new(committer, repository).with_branch('feature') do new_rev end end.to raise_error(GitHooksService::PreReceiveError) @@ -1044,7 +1045,7 @@ describe Repository, models: true do expect(repository).not_to receive(:expire_emptiness_caches) expect(repository).to receive(:expire_branches_cache) - GitOperationService.new(user, repository) + GitOperationService.new(committer, repository) .with_branch('new-feature') do new_rev end -- cgit v1.2.1 From 65f83941c39c14c2af9da5064393545ea2f7b3e5 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 13:54:14 +0200 Subject: Make gl_repository a G::G::Repository attribute --- app/models/repository.rb | 2 +- app/services/git_hooks_service.rb | 8 +++---- app/services/git_operation_service.rb | 2 +- db/migrate/20140502125220_migrate_repo_size.rb | 2 +- lib/gitlab/git/hook.rb | 13 +++++++---- lib/gitlab/git/repository.rb | 5 ++-- spec/lib/gitlab/git/blame_spec.rb | 2 +- spec/lib/gitlab/git/blob_spec.rb | 2 +- spec/lib/gitlab/git/branch_spec.rb | 2 +- spec/lib/gitlab/git/commit_spec.rb | 8 +++---- spec/lib/gitlab/git/compare_spec.rb | 2 +- spec/lib/gitlab/git/diff_spec.rb | 2 +- spec/lib/gitlab/git/hook_spec.rb | 9 ++++---- spec/lib/gitlab/git/index_spec.rb | 2 +- spec/lib/gitlab/git/repository_spec.rb | 32 +++++++++++++------------- spec/lib/gitlab/git/tag_spec.rb | 2 +- spec/lib/gitlab/git/tree_spec.rb | 2 +- spec/models/repository_spec.rb | 4 ++-- 18 files changed, 53 insertions(+), 48 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 3c5074e5157..062f532233f 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1194,7 +1194,7 @@ class Repository end def initialize_raw_repository - Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git') + Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', Gitlab::GlRepository.gl_repository(project, false)) end def circuit_breaker diff --git a/app/services/git_hooks_service.rb b/app/services/git_hooks_service.rb index e85007c26e0..c14133230da 100644 --- a/app/services/git_hooks_service.rb +++ b/app/services/git_hooks_service.rb @@ -3,9 +3,9 @@ class GitHooksService attr_accessor :oldrev, :newrev, :ref - def execute(committer, project, oldrev, newrev, ref) - @project = project - @gl_id = committer.gl_id + def execute(committer, repository, oldrev, newrev, ref) + @repository = repository + @gl_id = committer.gl_id @oldrev = oldrev @newrev = newrev @ref = ref @@ -26,7 +26,7 @@ class GitHooksService private def run_hook(name) - hook = Gitlab::Git::Hook.new(name, @project) + hook = Gitlab::Git::Hook.new(name, @repository) hook.trigger(@gl_id, oldrev, newrev, ref) end end diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb index f7fce3d8a5d..d20e4ed9e88 100644 --- a/app/services/git_operation_service.rb +++ b/app/services/git_operation_service.rb @@ -123,7 +123,7 @@ class GitOperationService def with_hooks(ref, newrev, oldrev) GitHooksService.new.execute( committer, - repository.project, + repository, oldrev, newrev, ref) do |service| diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb index f5d5d834307..ca1b054600c 100644 --- a/db/migrate/20140502125220_migrate_repo_size.rb +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -11,7 +11,7 @@ class MigrateRepoSize < ActiveRecord::Migration path = File.join(namespace_path, project['project_path'] + '.git') begin - repo = Gitlab::Git::Repository.new('default', path) + repo = Gitlab::Git::Repository.new('default', path, '') if repo.empty? print '-' else diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb index 8f0c377ef4f..08cede42ba2 100644 --- a/lib/gitlab/git/hook.rb +++ b/lib/gitlab/git/hook.rb @@ -6,15 +6,18 @@ module Gitlab module Git class Hook GL_PROTOCOL = 'web'.freeze - attr_reader :name, :repo_path, :path + attr_reader :name, :path, :repository - def initialize(name, project) + def initialize(name, repository) @name = name - @project = project - @repo_path = project.repository.path + @repository = repository @path = File.join(repo_path.strip, 'hooks', name) end + def repo_path + repository.path + end + def exists? File.exist?(path) end @@ -44,7 +47,7 @@ module Gitlab 'GL_ID' => gl_id, 'PWD' => repo_path, 'GL_PROTOCOL' => GL_PROTOCOL, - 'GL_REPOSITORY' => Gitlab::GlRepository.gl_repository(@project, false) + 'GL_REPOSITORY' => repository.gl_repository } options = { diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index eb3731ba35a..976ea7e4035 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -49,13 +49,14 @@ module Gitlab # Rugged repo object attr_reader :rugged - attr_reader :storage + attr_reader :storage, :gl_repository, :relative_path # 'path' must be the path to a _bare_ git repository, e.g. # /path/to/my-repo.git - def initialize(storage, relative_path) + def initialize(storage, relative_path, gl_repository) @storage = storage @relative_path = relative_path + @gl_repository = gl_repository storage_path = Gitlab.config.repositories.storages[@storage]['path'] @path = File.join(storage_path, @relative_path) diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index 800c245b130..465c2012b05 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" describe Gitlab::Git::Blame, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:blame) do Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md") end diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index dfab0c2fe85..66ba00acb7d 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" describe Gitlab::Git::Blob, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } describe 'initialize' do let(:blob) { Gitlab::Git::Blob.new(name: 'test') } diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index cdf1b8beee3..318a7b7a332 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Branch, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } subject { repository.branches } diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index ac33cd8a2c9..14d64d8c4da 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Commit, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:commit) { described_class.find(repository, SeedRepo::Commit::ID) } let(:rugged_commit) do repository.rugged.lookup(SeedRepo::Commit::ID) @@ -9,7 +9,7 @@ describe Gitlab::Git::Commit, seed_helper: true do describe "Commit info" do before do - repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH).rugged + repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '').rugged @committer = { email: 'mike@smith.com', @@ -59,7 +59,7 @@ describe Gitlab::Git::Commit, seed_helper: true do after do # Erase the new commit so other tests get the original repo - repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH).rugged + repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '').rugged repo.references.update("refs/heads/master", SeedRepo::LastCommit::ID) end end @@ -144,7 +144,7 @@ describe Gitlab::Git::Commit, seed_helper: true do end context 'with broken repo' do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH, '') } it 'returns nil' do expect(described_class.find(repository, SeedRepo::Commit::ID)).to be_nil diff --git a/spec/lib/gitlab/git/compare_spec.rb b/spec/lib/gitlab/git/compare_spec.rb index 4c9f4a28f32..b6a42e422b5 100644 --- a/spec/lib/gitlab/git/compare_spec.rb +++ b/spec/lib/gitlab/git/compare_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Compare, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) } let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) } diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 7ea3386ac2a..dfbdbee48f7 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Diff, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } before do @raw_diff_hash = { diff --git a/spec/lib/gitlab/git/hook_spec.rb b/spec/lib/gitlab/git/hook_spec.rb index 19391a70cf6..ea3e4680b1d 100644 --- a/spec/lib/gitlab/git/hook_spec.rb +++ b/spec/lib/gitlab/git/hook_spec.rb @@ -10,7 +10,8 @@ describe Gitlab::Git::Hook do describe "#trigger" do let(:project) { create(:project, :repository) } - let(:repo_path) { project.repository.path } + let(:repository) { project.repository.raw_repository } + let(:repo_path) { repository.path } let(:user) { create(:user) } let(:gl_id) { Gitlab::GlId.gl_id(user) } @@ -48,7 +49,7 @@ describe Gitlab::Git::Hook do it "returns success with no errors" do create_hook(hook_name) - hook = described_class.new(hook_name, project) + hook = described_class.new(hook_name, repository) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' @@ -66,7 +67,7 @@ describe Gitlab::Git::Hook do context "when the hook is unsuccessful" do it "returns failure with errors" do create_failing_hook(hook_name) - hook = described_class.new(hook_name, project) + hook = described_class.new(hook_name, repository) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' @@ -80,7 +81,7 @@ describe Gitlab::Git::Hook do context "when the hook doesn't exist" do it "returns success with no errors" do - hook = described_class.new('unknown_hook', project) + hook = described_class.new('unknown_hook', repository) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' diff --git a/spec/lib/gitlab/git/index_spec.rb b/spec/lib/gitlab/git/index_spec.rb index 21b71654251..73fbc6a6afa 100644 --- a/spec/lib/gitlab/git/index_spec.rb +++ b/spec/lib/gitlab/git/index_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Gitlab::Git::Index, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:index) { described_class.new(repository) } before do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 8ec8dfe6acf..06fcdd7aa57 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -17,7 +17,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end end - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } describe "Respond to" do subject { repository } @@ -56,14 +56,14 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#rugged" do describe 'when storage is broken', broken_storage: true do it 'raises a storage exception when storage is not available' do - broken_repo = described_class.new('broken', 'a/path.git') + broken_repo = described_class.new('broken', 'a/path.git', '') expect { broken_repo.rugged }.to raise_error(Gitlab::Git::Storage::Inaccessible) end end it 'raises a no repository exception when there is no repo' do - broken_repo = described_class.new('default', 'a/path.git') + broken_repo = described_class.new('default', 'a/path.git', '') expect { broken_repo.rugged }.to raise_error(Gitlab::Git::Repository::NoRepository) end @@ -257,7 +257,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end describe '#submodule_url_for' do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:ref) { 'master' } def submodule_url(path) @@ -295,7 +295,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end context '#submodules' do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } context 'where repo has submodules' do let(:submodules) { repository.send(:submodules, 'master') } @@ -391,7 +391,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#delete_branch" do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.delete_branch("feature") end @@ -407,7 +407,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#create_branch" do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') end it "should create a new branch" do @@ -445,7 +445,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#remote_delete" do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.remote_delete("expendable") end @@ -461,7 +461,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#remote_add" do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.remote_add("new_remote", SeedHelper::GITLAB_GIT_TEST_REPO_URL) end @@ -477,7 +477,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe "#remote_update" do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.remote_update("expendable", url: TEST_NORMAL_REPO_PATH) end @@ -506,7 +506,7 @@ describe Gitlab::Git::Repository, seed_helper: true do before(:context) do # Add new commits so that there's a renamed file in the commit history - repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH).rugged + repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '').rugged @commit_with_old_name_id = new_commit_edit_old_file(repo) @rename_commit_id = new_commit_move_file(repo) @commit_with_new_name_id = new_commit_edit_new_file(repo) @@ -514,7 +514,7 @@ describe Gitlab::Git::Repository, seed_helper: true do after(:context) do # Erase our commits so other tests get the original repo - repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH).rugged + repo = Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '').rugged repo.references.update("refs/heads/master", SeedRepo::LastCommit::ID) end @@ -849,7 +849,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe '#autocrlf' do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.rugged.config['core.autocrlf'] = true end @@ -864,7 +864,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe '#autocrlf=' do before(:all) do - @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH) + @repo = Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') @repo.rugged.config['core.autocrlf'] = false end @@ -933,7 +933,7 @@ describe Gitlab::Git::Repository, seed_helper: true do context 'with local and remote branches' do let(:repository) do - Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git')) + Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git'), '') end before do @@ -1128,7 +1128,7 @@ describe Gitlab::Git::Repository, seed_helper: true do describe '#local_branches' do before(:all) do - @repo = Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git')) + @repo = Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git'), '') end after(:all) do diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb index 78d1e120013..cc10679ef1e 100644 --- a/spec/lib/gitlab/git/tag_spec.rb +++ b/spec/lib/gitlab/git/tag_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Tag, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } shared_examples 'Gitlab::Git::Repository#tags' do describe 'first tag' do diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb index 98ddd3c3664..c07a2d91768 100644 --- a/spec/lib/gitlab/git/tree_spec.rb +++ b/spec/lib/gitlab/git/tree_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe Gitlab::Git::Tree, seed_helper: true do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } context :repo do let(:tree) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID) } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 0b1a35d1920..62585fdb35f 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -886,7 +886,7 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do expect_any_instance_of(GitHooksService).to receive(:execute) - .with(committer, project, old_rev, blank_sha, 'refs/heads/feature') + .with(committer, repository, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end @@ -929,7 +929,7 @@ describe Repository, models: true do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) expect(service).to receive(:execute) - .with(committer, project, old_rev, new_rev, 'refs/heads/feature') + .with(committer, repository, old_rev, new_rev, 'refs/heads/feature') .and_yield(service).and_return(true) end -- cgit v1.2.1 From dc7c6bede27abd4507072276ef23b40a74ee297a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 14:18:09 +0200 Subject: Move GitHooksService to Gitlab::Git --- app/services/commits/create_service.rb | 2 +- app/services/create_branch_service.rb | 2 +- app/services/delete_branch_service.rb | 2 +- app/services/git_hooks_service.rb | 32 ------------------- app/services/git_operation_service.rb | 2 +- app/services/merge_requests/merge_service.rb | 2 +- app/services/tags/create_service.rb | 2 +- app/services/tags/destroy_service.rb | 2 +- app/services/validate_new_branch_service.rb | 2 +- db/fixtures/development/17_cycle_analytics.rb | 2 +- lib/gitlab/git/hook.rb | 4 +-- lib/gitlab/git/hooks_service.rb | 37 ++++++++++++++++++++++ spec/features/tags/master_deletes_tag_spec.rb | 4 +-- spec/lib/gitlab/git_access_spec.rb | 2 +- spec/models/repository_spec.rb | 16 +++++----- spec/services/files/update_service_spec.rb | 2 +- spec/services/git_hooks_service_spec.rb | 6 ++-- spec/services/merge_requests/merge_service_spec.rb | 2 +- spec/services/tags/create_service_spec.rb | 2 +- 19 files changed, 65 insertions(+), 60 deletions(-) delete mode 100644 app/services/git_hooks_service.rb create mode 100644 lib/gitlab/git/hooks_service.rb diff --git a/app/services/commits/create_service.rb b/app/services/commits/create_service.rb index c58f04a252b..dbd0b9ef43a 100644 --- a/app/services/commits/create_service.rb +++ b/app/services/commits/create_service.rb @@ -17,7 +17,7 @@ module Commits new_commit = create_commit! success(result: new_commit) - rescue ValidationError, ChangeError, Gitlab::Git::Index::IndexError, Repository::CommitError, GitHooksService::PreReceiveError => ex + rescue ValidationError, ChangeError, Gitlab::Git::Index::IndexError, Repository::CommitError, Gitlab::Git::HooksService::PreReceiveError => ex error(ex.message) end diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index 673ed02f952..0ba6a0ac6b5 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -14,7 +14,7 @@ class CreateBranchService < BaseService else error('Invalid reference name') end - rescue GitHooksService::PreReceiveError => ex + rescue Gitlab::Git::HooksService::PreReceiveError => ex error(ex.message) end diff --git a/app/services/delete_branch_service.rb b/app/services/delete_branch_service.rb index 64b3c0118fb..1f059c31944 100644 --- a/app/services/delete_branch_service.rb +++ b/app/services/delete_branch_service.rb @@ -16,7 +16,7 @@ class DeleteBranchService < BaseService else error('Failed to remove branch') end - rescue GitHooksService::PreReceiveError => ex + rescue Gitlab::Git::HooksService::PreReceiveError => ex error(ex.message) end diff --git a/app/services/git_hooks_service.rb b/app/services/git_hooks_service.rb deleted file mode 100644 index c14133230da..00000000000 --- a/app/services/git_hooks_service.rb +++ /dev/null @@ -1,32 +0,0 @@ -class GitHooksService - PreReceiveError = Class.new(StandardError) - - attr_accessor :oldrev, :newrev, :ref - - def execute(committer, repository, oldrev, newrev, ref) - @repository = repository - @gl_id = committer.gl_id - @oldrev = oldrev - @newrev = newrev - @ref = ref - - %w(pre-receive update).each do |hook_name| - status, message = run_hook(hook_name) - - unless status - raise PreReceiveError, message - end - end - - yield(self).tap do - run_hook('post-receive') - end - end - - private - - def run_hook(name) - hook = Gitlab::Git::Hook.new(name, @repository) - hook.trigger(@gl_id, oldrev, newrev, ref) - end -end diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb index d20e4ed9e88..6a983566526 100644 --- a/app/services/git_operation_service.rb +++ b/app/services/git_operation_service.rb @@ -121,7 +121,7 @@ class GitOperationService end def with_hooks(ref, newrev, oldrev) - GitHooksService.new.execute( + Gitlab::Git::HooksService.new.execute( committer, repository, oldrev, diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index bc846e07f24..5be749cd6a0 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -49,7 +49,7 @@ module MergeRequests raise MergeError, 'Conflicts detected during merge' unless commit_id merge_request.update(merge_commit_sha: commit_id) - rescue GitHooksService::PreReceiveError => e + rescue Gitlab::Git::HooksService::PreReceiveError => e raise MergeError, e.message rescue StandardError => e raise MergeError, "Something went wrong during merge: #{e.message}" diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb index 674792f6138..b3f4a72d6fe 100644 --- a/app/services/tags/create_service.rb +++ b/app/services/tags/create_service.rb @@ -13,7 +13,7 @@ module Tags new_tag = repository.add_tag(current_user, tag_name, target, message) rescue Rugged::TagError return error("Tag #{tag_name} already exists") - rescue GitHooksService::PreReceiveError => ex + rescue Gitlab::Git::HooksService::PreReceiveError => ex return error(ex.message) end diff --git a/app/services/tags/destroy_service.rb b/app/services/tags/destroy_service.rb index a368f4f5b61..d3d46064729 100644 --- a/app/services/tags/destroy_service.rb +++ b/app/services/tags/destroy_service.rb @@ -21,7 +21,7 @@ module Tags else error('Failed to remove tag') end - rescue GitHooksService::PreReceiveError => ex + rescue Gitlab::Git::HooksService::PreReceiveError => ex error(ex.message) end diff --git a/app/services/validate_new_branch_service.rb b/app/services/validate_new_branch_service.rb index d232e85cd33..7d1ed768ee8 100644 --- a/app/services/validate_new_branch_service.rb +++ b/app/services/validate_new_branch_service.rb @@ -13,7 +13,7 @@ class ValidateNewBranchService < BaseService end success - rescue GitHooksService::PreReceiveError => ex + rescue Gitlab::Git::HooksService::PreReceiveError => ex error(ex.message) end end diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 7c1d758dada..383782112a8 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -15,7 +15,7 @@ class Gitlab::Seeder::CycleAnalytics # to disable the `pre_receive` hook in order to remove this # dependency on the GitLab API. def stub_git_pre_receive! - GitHooksService.class_eval do + Gitlab::Git::HooksService.class_eval do def run_hook(name) [true, ''] end diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb index 08cede42ba2..cc35d77c6e4 100644 --- a/lib/gitlab/git/hook.rb +++ b/lib/gitlab/git/hook.rb @@ -1,6 +1,6 @@ -# Gitaly note: JV: looks like this is only used by GitHooksService in +# Gitaly note: JV: looks like this is only used by Gitlab::Git::HooksService in # app/services. We shouldn't bother migrating this until we know how -# GitHooksService will be migrated. +# Gitlab::Git::HooksService will be migrated. module Gitlab module Git diff --git a/lib/gitlab/git/hooks_service.rb b/lib/gitlab/git/hooks_service.rb new file mode 100644 index 00000000000..1da92fcc0e2 --- /dev/null +++ b/lib/gitlab/git/hooks_service.rb @@ -0,0 +1,37 @@ +module Gitlab + module Git + class HooksService + PreReceiveError = Class.new(StandardError) + + attr_accessor :oldrev, :newrev, :ref + + def execute(committer, repository, oldrev, newrev, ref) + @repository = repository + @gl_id = committer.gl_id + @oldrev = oldrev + @newrev = newrev + @ref = ref + + %w(pre-receive update).each do |hook_name| + status, message = run_hook(hook_name) + + unless status + raise PreReceiveError, message + end + end + + yield(self).tap do + run_hook('post-receive') + end + end + + private + + def run_hook(name) + hook = Gitlab::Git::Hook.new(name, @repository) + hook.trigger(@gl_id, oldrev, newrev, ref) + end + end + end +end + diff --git a/spec/features/tags/master_deletes_tag_spec.rb b/spec/features/tags/master_deletes_tag_spec.rb index 4d6fc13557f..d6a6b8fc7d5 100644 --- a/spec/features/tags/master_deletes_tag_spec.rb +++ b/spec/features/tags/master_deletes_tag_spec.rb @@ -36,8 +36,8 @@ feature 'Master deletes tag' do context 'when pre-receive hook fails', js: true do before do - allow_any_instance_of(GitHooksService).to receive(:execute) - .and_raise(GitHooksService::PreReceiveError, 'Do not delete tags') + allow_any_instance_of(Gitlab::Git::HooksService).to receive(:execute) + .and_raise(Gitlab::Git::HooksService::PreReceiveError, 'Do not delete tags') end scenario 'shows the error message' do diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 80dc49e99cb..295a979da76 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -384,7 +384,7 @@ describe Gitlab::GitAccess do def stub_git_hooks # Running the `pre-receive` hook is expensive, and not necessary for this test. - allow_any_instance_of(GitHooksService).to receive(:execute) do |service, &block| + allow_any_instance_of(Gitlab::Git::HooksService).to receive(:execute) do |service, &block| block.call(service) end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 62585fdb35f..462e92b8b62 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -847,7 +847,7 @@ describe Repository, models: true do expect do repository.add_branch(user, 'new_feature', 'master') - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end it 'does not create the branch' do @@ -855,7 +855,7 @@ describe Repository, models: true do expect do repository.add_branch(user, 'new_feature', 'master') - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) expect(repository.find_branch('new_feature')).to be_nil end end @@ -885,7 +885,7 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do - expect_any_instance_of(GitHooksService).to receive(:execute) + expect_any_instance_of(Gitlab::Git::HooksService).to receive(:execute) .with(committer, repository, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error @@ -906,7 +906,7 @@ describe Repository, models: true do expect do repository.rm_branch(user, 'feature') - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end it 'does not delete the branch' do @@ -914,7 +914,7 @@ describe Repository, models: true do expect do repository.rm_branch(user, 'feature') - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) expect(repository.find_branch('feature')).not_to be_nil end end @@ -926,8 +926,8 @@ describe Repository, models: true do context 'when pre hooks were successful' do before do - service = GitHooksService.new - expect(GitHooksService).to receive(:new).and_return(service) + service = Gitlab::Git::HooksService.new + expect(Gitlab::Git::HooksService).to receive(:new).and_return(service) expect(service).to receive(:execute) .with(committer, repository, old_rev, new_rev, 'refs/heads/feature') .and_yield(service).and_return(true) @@ -1030,7 +1030,7 @@ describe Repository, models: true do GitOperationService.new(committer, repository).with_branch('feature') do new_rev end - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end end diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb index cc950ae6bb3..2b4f8cd42ee 100644 --- a/spec/services/files/update_service_spec.rb +++ b/spec/services/files/update_service_spec.rb @@ -76,7 +76,7 @@ describe Files::UpdateService do let(:branch_name) { "#{project.default_branch}-new" } it 'fires hooks only once' do - expect(GitHooksService).to receive(:new).once.and_call_original + expect(Gitlab::Git::HooksService).to receive(:new).once.and_call_original subject.execute end diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb index 3ce01a995b4..ac7be531526 100644 --- a/spec/services/git_hooks_service_spec.rb +++ b/spec/services/git_hooks_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe GitHooksService do +describe Gitlab::Git::HooksService do include RepoHelpers let(:user) { create(:user) } @@ -31,7 +31,7 @@ describe GitHooksService do expect do service.execute(user, project, @blankrev, @newrev, @ref) - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end end @@ -43,7 +43,7 @@ describe GitHooksService do expect do service.execute(user, project, @blankrev, @newrev, @ref) - end.to raise_error(GitHooksService::PreReceiveError) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end end end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index e593bfeeaf7..5cfdb5372f3 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -217,7 +217,7 @@ describe MergeRequests::MergeService do it 'logs and saves error if there is an PreReceiveError exception' do error_message = 'error message' - allow(service).to receive(:repository).and_raise(GitHooksService::PreReceiveError, error_message) + allow(service).to receive(:repository).and_raise(Gitlab::Git::HooksService::PreReceiveError, error_message) allow(service).to receive(:execute_hooks) service.execute(merge_request) diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb index 1b31ce29f7a..57013b54560 100644 --- a/spec/services/tags/create_service_spec.rb +++ b/spec/services/tags/create_service_spec.rb @@ -41,7 +41,7 @@ describe Tags::CreateService do it 'returns an error' do expect(repository).to receive(:add_tag) .with(user, 'v1.1.0', 'master', 'Foo') - .and_raise(GitHooksService::PreReceiveError, 'something went wrong') + .and_raise(Gitlab::Git::HooksService::PreReceiveError, 'something went wrong') response = service.execute('v1.1.0', 'master', 'Foo') -- cgit v1.2.1 From c47b947a7360f21cc1438462587c6e284b40e230 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 16:24:41 +0200 Subject: Move GitHooksService tests --- spec/lib/gitlab/git/hooks_service_spec.rb | 48 +++++++++++++++++++++++++++++ spec/services/git_hooks_service_spec.rb | 50 ------------------------------- 2 files changed, 48 insertions(+), 50 deletions(-) create mode 100644 spec/lib/gitlab/git/hooks_service_spec.rb delete mode 100644 spec/services/git_hooks_service_spec.rb diff --git a/spec/lib/gitlab/git/hooks_service_spec.rb b/spec/lib/gitlab/git/hooks_service_spec.rb new file mode 100644 index 00000000000..e9c0209fe3b --- /dev/null +++ b/spec/lib/gitlab/git/hooks_service_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +describe Gitlab::Git::HooksService, seed_helper: true do + let(:committer) { Gitlab::Git::Committer.new('Jane Doe', 'janedoe@example.com', 'user-456') } + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, 'project-123') } + let(:service) { described_class.new } + + before do + @blankrev = Gitlab::Git::BLANK_SHA + @oldrev = SeedRepo::Commit::PARENT_ID + @newrev = SeedRepo::Commit::ID + @ref = 'refs/heads/feature' + end + + describe '#execute' do + context 'when receive hooks were successful' do + it 'calls post-receive hook' do + hook = double(trigger: [true, nil]) + expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) + + service.execute(committer, repository, @blankrev, @newrev, @ref) { } + end + end + + context 'when pre-receive hook failed' do + it 'does not call post-receive hook' do + expect(service).to receive(:run_hook).with('pre-receive').and_return([false, '']) + expect(service).not_to receive(:run_hook).with('post-receive') + + expect do + service.execute(committer, repository, @blankrev, @newrev, @ref) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) + end + end + + context 'when update hook failed' do + it 'does not call post-receive hook' do + expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil]) + expect(service).to receive(:run_hook).with('update').and_return([false, '']) + expect(service).not_to receive(:run_hook).with('post-receive') + + expect do + service.execute(committer, repository, @blankrev, @newrev, @ref) + end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) + end + end + end +end diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb deleted file mode 100644 index ac7be531526..00000000000 --- a/spec/services/git_hooks_service_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'spec_helper' - -describe Gitlab::Git::HooksService do - include RepoHelpers - - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } - let(:service) { described_class.new } - - before do - @blankrev = Gitlab::Git::BLANK_SHA - @oldrev = sample_commit.parent_id - @newrev = sample_commit.id - @ref = 'refs/heads/feature' - end - - describe '#execute' do - context 'when receive hooks were successful' do - it 'calls post-receive hook' do - hook = double(trigger: [true, nil]) - expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) - - service.execute(user, project, @blankrev, @newrev, @ref) { } - end - end - - context 'when pre-receive hook failed' do - it 'does not call post-receive hook' do - expect(service).to receive(:run_hook).with('pre-receive').and_return([false, '']) - expect(service).not_to receive(:run_hook).with('post-receive') - - expect do - service.execute(user, project, @blankrev, @newrev, @ref) - end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) - end - end - - context 'when update hook failed' do - it 'does not call post-receive hook' do - expect(service).to receive(:run_hook).with('pre-receive').and_return([true, nil]) - expect(service).to receive(:run_hook).with('update').and_return([false, '']) - expect(service).not_to receive(:run_hook).with('post-receive') - - expect do - service.execute(user, project, @blankrev, @newrev, @ref) - end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) - end - end - end -end -- cgit v1.2.1 From da769135fede9dececee8ab3e1f6951de7361e7f Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 16:27:15 +0200 Subject: Rubocop whitespace --- lib/gitlab/git/committer.rb | 2 +- lib/gitlab/git/hooks_service.rb | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/gitlab/git/committer.rb b/lib/gitlab/git/committer.rb index ef3576eaa1c..1f4bcf7a3a0 100644 --- a/lib/gitlab/git/committer.rb +++ b/lib/gitlab/git/committer.rb @@ -2,7 +2,7 @@ module Gitlab module Git class Committer attr_reader :name, :email, :gl_id - + def self.from_user(user) new(user.name, user.email, Gitlab::GlId.gl_id(user)) end diff --git a/lib/gitlab/git/hooks_service.rb b/lib/gitlab/git/hooks_service.rb index 1da92fcc0e2..ea8a87a1290 100644 --- a/lib/gitlab/git/hooks_service.rb +++ b/lib/gitlab/git/hooks_service.rb @@ -2,31 +2,31 @@ module Gitlab module Git class HooksService PreReceiveError = Class.new(StandardError) - + attr_accessor :oldrev, :newrev, :ref - + def execute(committer, repository, oldrev, newrev, ref) @repository = repository @gl_id = committer.gl_id @oldrev = oldrev @newrev = newrev @ref = ref - + %w(pre-receive update).each do |hook_name| status, message = run_hook(hook_name) - + unless status raise PreReceiveError, message end end - + yield(self).tap do run_hook('post-receive') end end - + private - + def run_hook(name) hook = Gitlab::Git::Hook.new(name, @repository) hook.trigger(@gl_id, oldrev, newrev, ref) @@ -34,4 +34,3 @@ module Gitlab end end end - -- cgit v1.2.1 From bc97931e2def4efee8418ce62ebc4818a31cf163 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 22 Aug 2017 16:27:18 +0200 Subject: Fix Hook.new call sites in tests --- spec/features/projects/import_export/import_file_spec.rb | 2 +- spec/lib/gitlab/import_export/repo_restorer_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index 9f2c86923b7..2eb6fab129d 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -99,6 +99,6 @@ feature 'Import/Export - project import integration test', js: true do end def project_hook_exists?(project) - Gitlab::Git::Hook.new('post-receive', project).exists? + Gitlab::Git::Hook.new('post-receive', project.repository.raw_repository).exists? end end diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb index 2786bc92fe5..c49af602a01 100644 --- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb @@ -34,7 +34,7 @@ describe Gitlab::ImportExport::RepoRestorer do it 'has the webhooks' do restorer.restore - expect(Gitlab::Git::Hook.new('post-receive', project)).to exist + expect(Gitlab::Git::Hook.new('post-receive', project.repository.raw_repository)).to exist end end end -- cgit v1.2.1 From f3e4f10de22ce2cbbb5dd830b7dfe0a79f40d1c1 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 23 Aug 2017 10:30:09 +0100 Subject: Update repo_commit_section to spy service --- spec/javascripts/repo/components/repo_commit_section_spec.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spec/javascripts/repo/components/repo_commit_section_spec.js b/spec/javascripts/repo/components/repo_commit_section_spec.js index 6f6faf5422b..1cbb4914005 100644 --- a/spec/javascripts/repo/components/repo_commit_section_spec.js +++ b/spec/javascripts/repo/components/repo_commit_section_spec.js @@ -1,9 +1,9 @@ import Vue from 'vue'; import repoCommitSection from '~/repo/components/repo_commit_section.vue'; import RepoStore from '~/repo/stores/repo_store'; -import Api from '~/api'; +import RepoService from '~/repo/services/repo_service'; -describe('RepoCommitSection', () => { +fdescribe('RepoCommitSection', () => { const branch = 'master'; const projectUrl = 'projectUrl'; const changedFiles = [{ @@ -111,7 +111,7 @@ describe('RepoCommitSection', () => { expect(submitCommit.disabled).toBeFalsy(); spyOn(vm, 'makeCommit').and.callThrough(); - spyOn(Api, 'commitMultiple').and.callFake(() => Promise.resolve()); + spyOn(RepoService, 'commitFiles').and.callFake(() => Promise.resolve()); submitCommit.click(); @@ -119,10 +119,9 @@ describe('RepoCommitSection', () => { expect(vm.makeCommit).toHaveBeenCalled(); expect(submitCommit.querySelector('.fa-spinner.fa-spin')).toBeTruthy(); - const args = Api.commitMultiple.calls.allArgs()[0]; - const { commit_message, actions, branch: payloadBranch } = args[1]; + const args = RepoService.commitFiles.calls.allArgs()[0]; + const { commit_message, actions, branch: payloadBranch } = args[0]; - expect(args[0]).toBe(projectId); expect(commit_message).toBe(commitMessage); expect(actions.length).toEqual(2); expect(payloadBranch).toEqual(branch); -- cgit v1.2.1 From 45d1c9a47ceeea4bffcfecd77ca87bd545f1b052 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 11:46:10 +0200 Subject: Fix pipeline job worker specs --- spec/workers/build_finished_worker_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb index 2868167c7d4..8cc3f37ebe8 100644 --- a/spec/workers/build_finished_worker_spec.rb +++ b/spec/workers/build_finished_worker_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe BuildFinishedWorker do describe '#perform' do context 'when build exists' do - let(:build) { create(:ci_build) } + let!(:build) { create(:ci_build) } it 'calculates coverage and calls hooks' do expect(BuildCoverageWorker) -- cgit v1.2.1 From a99b2d8e124167cad134fb7cad104a922a57299c Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 23 Aug 2017 10:45:46 +0200 Subject: Expose CI_PIPELINE_SOURCE on CI jobs It was missing and expected it wouldn't hurt anyone --- app/models/ci/pipeline.rb | 3 ++- changelogs/unreleased/zj-add-pipeline-source-variable.yml | 5 +++++ doc/ci/variables/README.md | 1 + spec/models/ci/pipeline_spec.rb | 14 +++++++++++++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/zj-add-pipeline-source-variable.yml diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index ea7331cb27f..2d40f8012a3 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -393,7 +393,8 @@ module Ci def predefined_variables [ { key: 'CI_PIPELINE_ID', value: id.to_s, public: true }, - { key: 'CI_CONFIG_PATH', value: ci_yaml_file_path, public: true } + { key: 'CI_CONFIG_PATH', value: ci_yaml_file_path, public: true }, + { key: 'CI_PIPELINE_SOURCE', value: source.to_s, public: true } ] end diff --git a/changelogs/unreleased/zj-add-pipeline-source-variable.yml b/changelogs/unreleased/zj-add-pipeline-source-variable.yml new file mode 100644 index 00000000000..5d98cd8086a --- /dev/null +++ b/changelogs/unreleased/zj-add-pipeline-source-variable.yml @@ -0,0 +1,5 @@ +--- +title: Add CI_PIPELINE_SOURCE variable on CI Jobs +merge_request: +author: +type: added diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index 22e7f6879ed..e55a92dbb71 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -57,6 +57,7 @@ future GitLab releases.** | **CI_RUNNER_TAGS** | 8.10 | 0.5 | The defined runner tags | | **CI_PIPELINE_ID** | 8.10 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally | | **CI_PIPELINE_TRIGGERED** | all | all | The flag to indicate that job was [triggered] | +| **CI_PIPELINE_SOURCE** | 10.0 | all | The source for this pipeline, one of: push, web, trigger, schedule, api, external. Pipelines created before 9.5 will have unknown as source | | **CI_PROJECT_DIR** | all | all | The full path where the repository is cloned and where the job is run | | **CI_PROJECT_ID** | all | all | The unique id of the current project that GitLab CI uses internally | | **CI_PROJECT_NAME** | 8.10 | 0.5 | The project name that is currently being built (actually it is project folder name) | diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index ac75c6501ee..b84e3ff18e8 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Ci::Pipeline, :mailer do let(:user) { create(:user) } - let(:project) { create(:project) } + set(:project) { create(:project) } let(:pipeline) do create(:ci_empty_pipeline, status: :created, project: project) @@ -159,6 +159,18 @@ describe Ci::Pipeline, :mailer do end end + describe '#predefined_variables' do + subject { pipeline.predefined_variables } + + it { is_expected.to be_an(Array) } + + it 'includes the defined keys' do + keys = subject.map { |v| v[:key] } + + expect(keys).to include('CI_PIPELINE_ID', 'CI_CONFIG_PATH', 'CI_PIPELINE_SOURCE') + end + end + describe '#auto_canceled?' do subject { pipeline.auto_canceled? } -- cgit v1.2.1 From d8d2b73b9f17e5af9aeccb1e9ba40045486651b5 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Fri, 18 Aug 2017 17:21:01 +0200 Subject: Improve bare repository import - Allow imports into nested groups - Make sure it sets the correct visibility level when creating new groups While doing this, I moved the import into a testable class, that made it easier to improve. --- .../unreleased/bvl-improve-bare-project-import.yml | 6 + lib/gitlab/bare_repository_importer.rb | 127 +++++++++++++++++++++ lib/tasks/gitlab/import.rake | 65 +---------- spec/lib/gitlab/bare_repository_importer_spec.rb | 88 ++++++++++++++ 4 files changed, 223 insertions(+), 63 deletions(-) create mode 100644 changelogs/unreleased/bvl-improve-bare-project-import.yml create mode 100644 lib/gitlab/bare_repository_importer.rb create mode 100644 spec/lib/gitlab/bare_repository_importer_spec.rb diff --git a/changelogs/unreleased/bvl-improve-bare-project-import.yml b/changelogs/unreleased/bvl-improve-bare-project-import.yml new file mode 100644 index 00000000000..74c1da4ea40 --- /dev/null +++ b/changelogs/unreleased/bvl-improve-bare-project-import.yml @@ -0,0 +1,6 @@ +--- +title: 'Improve bare project import: Allow subgroups, take default visibility level + into account' +merge_request: 13670 +author: +type: fixed diff --git a/lib/gitlab/bare_repository_importer.rb b/lib/gitlab/bare_repository_importer.rb new file mode 100644 index 00000000000..4bc3ccc3a1a --- /dev/null +++ b/lib/gitlab/bare_repository_importer.rb @@ -0,0 +1,127 @@ +module Gitlab + class BareRepositoryImporter + NoAdminError = Class.new(StandardError) + + def self.execute + Gitlab.config.repositories.storages.each do |storage_name, repository_storage| + git_base_path = repository_storage['path'] + repos_to_import = Dir.glob(git_base_path + '/**/*.git') + + repos_to_import.each do |repo_path| + if repo_path.end_with?('.wiki.git') + log " * Skipping wiki repo" + next + end + + log "Processing #{repo_path}".color(:yellow) + + repo_relative_path = repo_path[repository_storage['path'].length..-1] + .sub(/^\//, '') # Remove leading `/` + .sub(/\.git$/, '') # Remove `.git` at the end + new(storage_name, repo_relative_path).create_project_if_needed + end + end + end + + attr_reader :storage_name, :full_path, :group_path, :project_path, :user + delegate :log, to: :class + + def initialize(storage_name, repo_path) + @storage_name = storage_name + @full_path = repo_path + + unless @user = User.admins.order_id_asc.first + raise NoAdminError.new('No admin user found to import repositories') + end + + @group_path, @project_path = File.split(repo_path) + @group_path = nil if @group_path == '.' + end + + def create_project_if_needed + if project = Project.find_by_full_path(full_path) + log " * #{project.name} (#{full_path}) exists" + return project + end + + create_project + end + + private + + def create_project + group = find_or_create_group + + project_params = { + name: project_path, + path: project_path, + repository_storage: storage_name, + namespace_id: group&.id + } + + project = Projects::CreateService.new(user, project_params).execute + + if project.persisted? + log " * Created #{project.name} (#{full_path})".color(:green) + ProjectCacheWorker.perform_async(project.id) + else + log " * Failed trying to create #{project.name} (#{full_path})".color(:red) + log " Errors: #{project.errors.messages}".color(:red) + end + + project + end + + def find_or_create_group + return nil unless group_path + + if namespace = Namespace.find_by_full_path(group_path) + log " * Namespace #{group_path} exists.".color(:green) + return namespace + end + + create_group_path + end + + def create_group_path + group_path_segments = group_path.split('/') + + new_group, parent_group = nil + partial_path_segments = [] + while subgroup_name = group_path_segments.shift + partial_path_segments << subgroup_name + partial_path = partial_path_segments.join('/') + + unless new_group = Group.find_by_full_path(partial_path) + log " * Creating group #{partial_path}.".color(:green) + params = { + path: subgroup_name, + name: subgroup_name, + parent: parent_group, + visibility_level: Gitlab::CurrentSettings.current_application_settings.default_group_visibility + } + new_group = Groups::CreateService.new(user, params).execute + end + + if new_group.persisted? + log " * Group #{partial_path} (#{new_group.id}) available".color(:green) + else + log " * Failed trying to create group #{partial_path}.".color(:red) + log " * Errors: #{new_group.errors.messages}".color(:red) + end + parent_group = new_group + end + + new_group + end + + # This is called from within a rake task only used by Admins, so allow writing + # to STDOUT + # + # rubocop:disable Rails/Output + def self.log(message) + puts message + end + # rubocop:enable Rails/Output + end +end diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake index 6e10ba374bf..d227a0c8bdb 100644 --- a/lib/tasks/gitlab/import.rake +++ b/lib/tasks/gitlab/import.rake @@ -9,6 +9,7 @@ namespace :gitlab do # * The project owner will set to the first administator of the system # * Existing projects will be skipped # + # desc "GitLab | Import bare repositories from repositories -> storages into GitLab project instance" task repos: :environment do if Project.current_application_settings.hashed_storage_enabled @@ -17,69 +18,7 @@ namespace :gitlab do exit 1 end - Gitlab.config.repositories.storages.each_value do |repository_storage| - git_base_path = repository_storage['path'] - repos_to_import = Dir.glob(git_base_path + '/**/*.git') - - repos_to_import.each do |repo_path| - # strip repo base path - repo_path[0..git_base_path.length] = '' - - path = repo_path.sub(/\.git$/, '') - group_name, name = File.split(path) - group_name = nil if group_name == '.' - - puts "Processing #{repo_path}".color(:yellow) - - if path.end_with?('.wiki') - puts " * Skipping wiki repo" - next - end - - project = Project.find_by_full_path(path) - - if project - puts " * #{project.name} (#{repo_path}) exists" - else - user = User.admins.reorder("id").first - - project_params = { - name: name, - path: name - } - - # find group namespace - if group_name - group = Namespace.find_by(path: group_name) - # create group namespace - unless group - group = Group.new(name: group_name) - group.path = group_name - group.owner = user - if group.save - puts " * Created Group #{group.name} (#{group.id})".color(:green) - else - puts " * Failed trying to create group #{group.name}".color(:red) - end - end - # set project group - project_params[:namespace_id] = group.id - end - - project = Projects::CreateService.new(user, project_params).execute - - if project.persisted? - puts " * Created #{project.name} (#{repo_path})".color(:green) - ProjectCacheWorker.perform_async(project.id) - else - puts " * Failed trying to create #{project.name} (#{repo_path})".color(:red) - puts " Errors: #{project.errors.messages}".color(:red) - end - end - end - end - - puts "Done!".color(:green) + Gitlab::BareRepositoryImporter.execute end end end diff --git a/spec/lib/gitlab/bare_repository_importer_spec.rb b/spec/lib/gitlab/bare_repository_importer_spec.rb new file mode 100644 index 00000000000..88d30a2e855 --- /dev/null +++ b/spec/lib/gitlab/bare_repository_importer_spec.rb @@ -0,0 +1,88 @@ +require 'spec_helper' + +describe Gitlab::BareRepositoryImporter, repository: true do + subject(:importer) { described_class.new('default', project_path) } + let(:project_path) { 'a-group/a-sub-group/a-project' } + let!(:admin) { create(:admin) } + + before do + allow(described_class).to receive(:log) + end + + describe '.execute' do + it 'creates a project for a repository in storage' do + FileUtils.mkdir_p(File.join(TestEnv.repos_path, "#{project_path}.git")) + fake_importer = double + + expect(described_class).to receive(:new).with('default', project_path) + .and_return(fake_importer) + expect(fake_importer).to receive(:create_project_if_needed) + + described_class.execute + end + + it 'skips wiki repos' do + FileUtils.mkdir_p(File.join(TestEnv.repos_path, 'the-group', 'the-project.wiki.git')) + + expect(described_class).to receive(:log).with(' * Skipping wiki repo') + expect(described_class).not_to receive(:new) + + described_class.execute + end + end + + describe '#initialize' do + context 'without admin users' do + let(:admin) { nil } + + it 'raises an error' do + expect { importer }.to raise_error(Gitlab::BareRepositoryImporter::NoAdminError) + end + end + end + + describe '#create_project_if_needed' do + it 'starts an import for a project that did not exist' do + expect(importer).to receive(:create_project) + + importer.create_project_if_needed + end + + it 'skips importing when the project already exists' do + group = create(:group, path: 'a-group') + subgroup = create(:group, path: 'a-sub-group', parent: group) + project = create(:project, path: 'a-project', namespace: subgroup) + + expect(importer).not_to receive(:create_project) + expect(importer).to receive(:log).with(" * #{project.name} (a-group/a-sub-group/a-project) exists") + + importer.create_project_if_needed + end + + it 'creates a project with the correct path in the database' do + importer.create_project_if_needed + + expect(Project.find_by_full_path(project_path)).not_to be_nil + end + + it 'creates group and subgroup in the database' do + importer.create_project_if_needed + + parent = Group.find_by_full_path('a-group') + child = parent.children.find_by(path: 'a-sub-group') + + expect(parent).not_to be_nil + expect(child).not_to be_nil + end + + it 'creates the group with correct visibility level' do + allow(Gitlab::CurrentSettings.current_application_settings) + .to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL } + project = importer.create_project_if_needed + + group = project.namespace + + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) + end + end +end -- cgit v1.2.1 From 22ef4ba3a4be66296e5ee9231b4eb39e172c0f1f Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 22 Aug 2017 12:13:25 +0200 Subject: Migrate creation of nested groups into a service --- app/services/groups/nested_create_service.rb | 45 ++++++++++++++++++ lib/gitlab/bare_repository_importer.rb | 35 +------------- lib/tasks/import.rake | 18 +------- spec/lib/gitlab/bare_repository_importer_spec.rb | 20 -------- spec/services/groups/nested_create_service_spec.rb | 53 ++++++++++++++++++++++ 5 files changed, 101 insertions(+), 70 deletions(-) create mode 100644 app/services/groups/nested_create_service.rb create mode 100644 spec/services/groups/nested_create_service_spec.rb diff --git a/app/services/groups/nested_create_service.rb b/app/services/groups/nested_create_service.rb new file mode 100644 index 00000000000..8d793f5c02e --- /dev/null +++ b/app/services/groups/nested_create_service.rb @@ -0,0 +1,45 @@ +module Groups + class NestedCreateService < Groups::BaseService + attr_reader :group_path + + def initialize(user, params) + @current_user, @params = user, params.dup + + @group_path = @params.delete(:group_path) + end + + def execute + return nil unless group_path + + if group = Group.find_by_full_path(group_path) + return group + end + + create_group_path + end + + private + + def create_group_path + group_path_segments = group_path.split('/') + + last_group = nil + partial_path_segments = [] + while subgroup_name = group_path_segments.shift + partial_path_segments << subgroup_name + partial_path = partial_path_segments.join('/') + + new_params = params.reverse_merge( + path: subgroup_name, + name: subgroup_name, + parent: last_group + ) + new_params[:visibility_level] ||= Gitlab::CurrentSettings.current_application_settings.default_group_visibility + + last_group = Group.find_by_full_path(partial_path) || Groups::CreateService.new(current_user, new_params).execute + end + + last_group + end + end +end diff --git a/lib/gitlab/bare_repository_importer.rb b/lib/gitlab/bare_repository_importer.rb index 4bc3ccc3a1a..9323bfc7fb2 100644 --- a/lib/gitlab/bare_repository_importer.rb +++ b/lib/gitlab/bare_repository_importer.rb @@ -80,39 +80,8 @@ module Gitlab return namespace end - create_group_path - end - - def create_group_path - group_path_segments = group_path.split('/') - - new_group, parent_group = nil - partial_path_segments = [] - while subgroup_name = group_path_segments.shift - partial_path_segments << subgroup_name - partial_path = partial_path_segments.join('/') - - unless new_group = Group.find_by_full_path(partial_path) - log " * Creating group #{partial_path}.".color(:green) - params = { - path: subgroup_name, - name: subgroup_name, - parent: parent_group, - visibility_level: Gitlab::CurrentSettings.current_application_settings.default_group_visibility - } - new_group = Groups::CreateService.new(user, params).execute - end - - if new_group.persisted? - log " * Group #{partial_path} (#{new_group.id}) available".color(:green) - else - log " * Failed trying to create group #{partial_path}.".color(:red) - log " * Errors: #{new_group.errors.messages}".color(:red) - end - parent_group = new_group - end - - new_group + log " * Creating Group: #{group_path}" + Groups::NestedCreateService.new(user, group_path: group_path).execute end # This is called from within a rake task only used by Admins, so allow writing diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 96b8f59242c..1206302cb76 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -72,23 +72,7 @@ class GithubImport return @current_user.namespace if names == @current_user.namespace_path return @current_user.namespace unless @current_user.can_create_group? - full_path_namespace = Namespace.find_by_full_path(names) - - return full_path_namespace if full_path_namespace - - names.split('/').inject(nil) do |parent, name| - begin - namespace = Group.create!(name: name, - path: name, - owner: @current_user, - parent: parent) - namespace.add_owner(@current_user) - - namespace - rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid - Namespace.where(parent: parent).find_by_path_or_name(name) - end - end + Groups::NestedCreateService.new(@current_user, group_path: names).execute end def full_path_namespace(names) diff --git a/spec/lib/gitlab/bare_repository_importer_spec.rb b/spec/lib/gitlab/bare_repository_importer_spec.rb index 88d30a2e855..892f2dafc96 100644 --- a/spec/lib/gitlab/bare_repository_importer_spec.rb +++ b/spec/lib/gitlab/bare_repository_importer_spec.rb @@ -64,25 +64,5 @@ describe Gitlab::BareRepositoryImporter, repository: true do expect(Project.find_by_full_path(project_path)).not_to be_nil end - - it 'creates group and subgroup in the database' do - importer.create_project_if_needed - - parent = Group.find_by_full_path('a-group') - child = parent.children.find_by(path: 'a-sub-group') - - expect(parent).not_to be_nil - expect(child).not_to be_nil - end - - it 'creates the group with correct visibility level' do - allow(Gitlab::CurrentSettings.current_application_settings) - .to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL } - project = importer.create_project_if_needed - - group = project.namespace - - expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) - end end end diff --git a/spec/services/groups/nested_create_service_spec.rb b/spec/services/groups/nested_create_service_spec.rb new file mode 100644 index 00000000000..c1526456bac --- /dev/null +++ b/spec/services/groups/nested_create_service_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe Groups::NestedCreateService do + let(:user) { create(:user) } + let(:params) { { group_path: 'a-group/a-sub-group' } } + + subject(:service) { described_class.new(user, params) } + + describe "#execute" do + it 'returns the group if it already existed' do + parent = create(:group, path: 'a-group', owner: user) + child = create(:group, path: 'a-sub-group', parent: parent, owner: user) + + expect(service.execute).to eq(child) + end + + it 'reuses a parent if it already existed' do + parent = create(:group, path: 'a-group') + parent.add_owner(user) + + expect(service.execute.parent).to eq(parent) + end + + it 'creates group and subgroup in the database' do + service.execute + + parent = Group.find_by_full_path('a-group') + child = parent.children.find_by(path: 'a-sub-group') + + expect(parent).not_to be_nil + expect(child).not_to be_nil + end + + it 'creates the group with correct visibility level' do + allow(Gitlab::CurrentSettings.current_application_settings) + .to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL } + + group = service.execute + + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) + end + + context 'adding a visibility level ' do + let(:params) { { group_path: 'a-group/a-sub-group', visibility_level: Gitlab::VisibilityLevel::PRIVATE } } + + it 'overwrites the visibility level' do + group = service.execute + + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + end + end + end +end -- cgit v1.2.1 From f76d8c902a08040eeaacc8c7a3a9506fb55501e7 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Tue, 22 Aug 2017 14:03:40 +0200 Subject: Fix error when importing a GitHub-wiki repository This would occur when Wiki's are enabled on GitHub, but there is no wiki repository --- lib/github/import.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github/import.rb b/lib/github/import.rb index 4cc01593ef4..7b848081e85 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -107,7 +107,7 @@ module Github # this means that repo has wiki enabled, but have no pages. So, # we can skip the import. if e.message !~ /repository not exported/ - errors(:wiki, wiki_url, e.message) + error(:wiki, wiki_url, e.message) end end -- cgit v1.2.1 From 6ec53f5d488fcdc6ef2b076c37a46525b5176224 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 17 Aug 2017 17:21:25 +0200 Subject: Cache the number of open issues and merge requests Every project page displays a navigation menu that in turn displays the number of open issues and merge requests. This means that for every project page we run two COUNT(*) queries, each taking up roughly 30 milliseconds on GitLab.com. By caching these numbers and refreshing them whenever necessary we can reduce loading times of all these pages by up to roughly 60 milliseconds. The number of open issues does not include confidential issues. This is a trade-off to keep the code simple and to ensure refreshing the data only needs 2 COUNT(*) queries instead of 3. A downside is that if a project only has 5 confidential issues the counter will be set to 0. Because we now have 3 similar counting service classes the code previously used in Projects::ForksCountService has mostly been moved to Projects::CountService, which in turn is reused by the various service classes. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36622 --- app/models/issue.rb | 7 +++ app/models/merge_request.rb | 5 ++ app/models/project.rb | 6 +- app/services/issuable_base_service.rb | 4 ++ app/services/issues/create_service.rb | 2 + app/services/merge_requests/create_service.rb | 2 + app/services/projects/count_service.rb | 43 +++++++++++++ app/services/projects/forks_count_service.rb | 28 ++------- app/services/projects/open_issues_count_service.rb | 15 +++++ .../projects/open_merge_requests_count_service.rb | 13 ++++ .../layouts/nav/_new_project_sidebar.html.haml | 6 +- app/views/layouts/nav/_project.html.haml | 6 +- .../unreleased/cache-issue-and-mr-counts.yml | 5 ++ spec/models/issue_spec.rb | 18 ++++++ spec/models/merge_request_spec.rb | 9 +++ spec/services/issues/close_service_spec.rb | 5 ++ spec/services/issues/create_service_spec.rb | 4 ++ spec/services/issues/reopen_service_spec.rb | 7 +++ spec/services/merge_requests/close_service_spec.rb | 7 +++ .../services/merge_requests/create_service_spec.rb | 32 +++++----- .../services/merge_requests/reopen_service_spec.rb | 7 +++ spec/services/projects/count_service_spec.rb | 73 ++++++++++++++++++++++ spec/services/projects/forks_count_service_spec.rb | 32 +--------- .../projects/open_issues_count_service_spec.rb | 21 +++++++ .../open_merge_requests_count_service_spec.rb | 15 +++++ 25 files changed, 301 insertions(+), 71 deletions(-) create mode 100644 app/services/projects/count_service.rb create mode 100644 app/services/projects/open_issues_count_service.rb create mode 100644 app/services/projects/open_merge_requests_count_service.rb create mode 100644 changelogs/unreleased/cache-issue-and-mr-counts.yml create mode 100644 spec/services/projects/count_service_spec.rb create mode 100644 spec/services/projects/open_issues_count_service_spec.rb create mode 100644 spec/services/projects/open_merge_requests_count_service_spec.rb diff --git a/app/models/issue.rb b/app/models/issue.rb index 1c948c8957e..d89b1c96a36 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -53,7 +53,10 @@ class Issue < ActiveRecord::Base scope :preload_associations, -> { preload(:labels, project: :namespace) } + scope :public_only, -> { where(confidential: false) } + after_save :expire_etag_cache + after_commit :update_project_counter_caches, on: :destroy attr_spammable :title, spam_title: true attr_spammable :description, spam_description: true @@ -269,6 +272,10 @@ class Issue < ActiveRecord::Base end end + def update_project_counter_caches + Projects::OpenIssuesCountService.new(project).refresh_cache + end + private # Returns `true` if the given User can read the current Issue. diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index ac08dc0ee1f..7fe7df75944 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -32,6 +32,7 @@ class MergeRequest < ActiveRecord::Base after_create :ensure_merge_request_diff, unless: :importing? after_update :reload_diff_if_branch_changed + after_commit :update_project_counter_caches, on: :destroy # When this attribute is true some MR validation is ignored # It allows us to close or modify broken merge requests @@ -937,6 +938,10 @@ class MergeRequest < ActiveRecord::Base true end + def update_project_counter_caches + Projects::OpenMergeRequestsCountService.new(target_project).refresh_cache + end + private def write_ref diff --git a/app/models/project.rb b/app/models/project.rb index be248bc99e1..ddef8b82dee 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1158,7 +1158,11 @@ class Project < ActiveRecord::Base end def open_issues_count - issues.opened.count + Projects::OpenIssuesCountService.new(self).count + end + + def open_merge_requests_count + Projects::OpenMergeRequestsCountService.new(self).count end def visibility_level_allowed_as_fork?(level = self.visibility_level) diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 4a4f2b91182..1486db046b5 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -192,6 +192,8 @@ class IssuableBaseService < BaseService def after_create(issuable) # To be overridden by subclasses + + issuable.update_project_counter_caches end def before_update(issuable) @@ -200,6 +202,8 @@ class IssuableBaseService < BaseService def after_update(issuable) # To be overridden by subclasses + + issuable.update_project_counter_caches end def update(issuable) diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 234fcbede03..0307634c0b6 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -27,6 +27,8 @@ module Issues todo_service.new_issue(issuable, current_user) user_agent_detail_service.create resolve_discussions_with_issue(issuable) + + super end def resolve_discussions_with_issue(issue) diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index 194413bf321..3d53fe0646b 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -28,6 +28,8 @@ module MergeRequests todo_service.new_merge_request(issuable, current_user) issuable.cache_merge_request_closes_issues!(current_user) update_merge_requests_head_pipeline(issuable) + + super end private diff --git a/app/services/projects/count_service.rb b/app/services/projects/count_service.rb new file mode 100644 index 00000000000..5e633c37bf8 --- /dev/null +++ b/app/services/projects/count_service.rb @@ -0,0 +1,43 @@ +module Projects + # Base class for the various service classes that count project data (e.g. + # issues or forks). + class CountService + def initialize(project) + @project = project + end + + def relation_for_count + raise( + NotImplementedError, + '"relation_for_count" must be implemented and return an ActiveRecord::Relation' + ) + end + + def count + Rails.cache.fetch(cache_key) { uncached_count } + end + + def refresh_cache + Rails.cache.write(cache_key, uncached_count) + end + + def uncached_count + relation_for_count.count + end + + def delete_cache + Rails.cache.delete(cache_key) + end + + def cache_key_name + raise( + NotImplementedError, + '"cache_key_name" must be implemented and return a String' + ) + end + + def cache_key + ['projects', @project.id, cache_key_name] + end + end +end diff --git a/app/services/projects/forks_count_service.rb b/app/services/projects/forks_count_service.rb index e2e2b1da91d..3a0fa84b868 100644 --- a/app/services/projects/forks_count_service.rb +++ b/app/services/projects/forks_count_service.rb @@ -1,30 +1,12 @@ module Projects # Service class for getting and caching the number of forks of a project. - class ForksCountService - def initialize(project) - @project = project + class ForksCountService < CountService + def relation_for_count + @project.forks end - def count - Rails.cache.fetch(cache_key) { uncached_count } - end - - def refresh_cache - Rails.cache.write(cache_key, uncached_count) - end - - def delete_cache - Rails.cache.delete(cache_key) - end - - private - - def uncached_count - @project.forks.count - end - - def cache_key - ['projects', @project.id, 'forks_count'] + def cache_key_name + 'forks_count' end end end diff --git a/app/services/projects/open_issues_count_service.rb b/app/services/projects/open_issues_count_service.rb new file mode 100644 index 00000000000..3c0d186a73c --- /dev/null +++ b/app/services/projects/open_issues_count_service.rb @@ -0,0 +1,15 @@ +module Projects + # Service class for counting and caching the number of open issues of a + # project. + class OpenIssuesCountService < CountService + def relation_for_count + # We don't include confidential issues in this number since this would + # expose the number of confidential issues to non project members. + @project.issues.opened.public_only + end + + def cache_key_name + 'open_issues_count' + end + end +end diff --git a/app/services/projects/open_merge_requests_count_service.rb b/app/services/projects/open_merge_requests_count_service.rb new file mode 100644 index 00000000000..2a90f78b90d --- /dev/null +++ b/app/services/projects/open_merge_requests_count_service.rb @@ -0,0 +1,13 @@ +module Projects + # Service class for counting and caching the number of open merge requests of + # a project. + class OpenMergeRequestsCountService < CountService + def relation_for_count + @project.merge_requests.opened + end + + def cache_key_name + 'open_merge_requests_count' + end + end +end diff --git a/app/views/layouts/nav/_new_project_sidebar.html.haml b/app/views/layouts/nav/_new_project_sidebar.html.haml index 0ef81375c3a..81c84756ff8 100644 --- a/app/views/layouts/nav/_new_project_sidebar.html.haml +++ b/app/views/layouts/nav/_new_project_sidebar.html.haml @@ -86,7 +86,8 @@ %span.nav-item-name Issues - if @project.issues_enabled? - %span.badge.count.issue_counter= number_with_delimiter(IssuesFinder.new(current_user, project_id: @project.id).execute.opened.count) + %span.badge.count.issue_counter + = number_with_delimiter(@project.open_issues_count) %ul.sidebar-sub-level-items = nav_link(controller: :issues) do @@ -116,7 +117,8 @@ = custom_icon('mr_bold') %span.nav-item-name Merge Requests - %span.badge.count.merge_counter.js-merge-counter= number_with_delimiter(MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened.count) + %span.badge.count.merge_counter.js-merge-counter + = number_with_delimiter(@project.open_merge_requests_count) - if project_nav_tab? :pipelines = nav_link(controller: [:pipelines, :builds, :jobs, :pipeline_schedules, :environments, :artifacts]) do diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index 924cd2e9681..b88465848e3 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -28,7 +28,8 @@ %span Issues - if @project.issues_enabled? - %span.badge.count.issue_counter= number_with_delimiter(issuables_count_for_state(:issues, :opened, finder: IssuesFinder.new(current_user, project_id: @project.id))) + %span.badge.count.issue_counter + = number_with_delimiter(@project.open_issues_count) - if project_nav_tab? :merge_requests - controllers = [:merge_requests, 'projects/merge_requests/conflicts'] @@ -37,7 +38,8 @@ = link_to project_merge_requests_path(@project), title: 'Merge Requests', class: 'shortcuts-merge_requests' do %span Merge Requests - %span.badge.count.merge_counter.js-merge-counter= number_with_delimiter(issuables_count_for_state(:merge_requests, :opened, finder: MergeRequestsFinder.new(current_user, project_id: @project.id))) + %span.badge.count.merge_counter.js-merge-counter + = number_with_delimiter(@project.open_merge_requests_count) - if project_nav_tab? :pipelines = nav_link(controller: [:pipelines, :builds, :environments, :artifacts]) do diff --git a/changelogs/unreleased/cache-issue-and-mr-counts.yml b/changelogs/unreleased/cache-issue-and-mr-counts.yml new file mode 100644 index 00000000000..fe3fe3be976 --- /dev/null +++ b/changelogs/unreleased/cache-issue-and-mr-counts.yml @@ -0,0 +1,5 @@ +--- +title: Cache the number of open issues and merge requests +merge_request: +author: +type: other diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 9203f6562f2..de86788d142 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -751,4 +751,22 @@ describe Issue do end end end + + describe 'removing an issue' do + it 'refreshes the number of open issues of the project' do + project = subject.project + + expect { subject.destroy } + .to change { project.open_issues_count }.from(1).to(0) + end + end + + describe '.public_only' do + it 'only returns public issues' do + public_issue = create(:issue) + create(:issue, confidential: true) + + expect(described_class.public_only).to eq([public_issue]) + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 026bdbd26d1..1c72513520d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1692,4 +1692,13 @@ describe MergeRequest do expect(subject.ref_fetched?).to be_falsey end end + + describe 'removing a merge request' do + it 'refreshes the number of open merge requests of the target project' do + project = subject.target_project + + expect { subject.destroy } + .to change { project.open_merge_requests_count }.from(1).to(0) + end + end end diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index a03f68434de..171f70c32a8 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -42,6 +42,11 @@ describe Issues::CloseService do service.execute(issue) end + it 'refreshes the number of open issues' do + expect { service.execute(issue) } + .to change { project.open_issues_count }.from(1).to(0) + end + it 'invalidates counter cache for assignees' do expect_any_instance_of(User).to receive(:invalidate_issue_cache_counts) diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 9b2d9e79f4f..78b11cd7991 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -35,6 +35,10 @@ describe Issues::CreateService do expect(issue.due_date).to eq Date.tomorrow end + it 'refreshes the number of open issues' do + expect { issue }.to change { project.open_issues_count }.from(0).to(1) + end + context 'when current user cannot admin issues in the project' do let(:guest) { create(:user) } diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index 205e9ebd237..48fc98b3b2f 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -34,6 +34,13 @@ describe Issues::ReopenService do described_class.new(project, user).execute(issue) end + it 'refreshes the number of opened issues' do + service = described_class.new(project, user) + + expect { service.execute(issue) } + .to change { project.open_issues_count }.from(0).to(1) + end + context 'when issue is not confidential' do it 'executes issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb index 04bf267d167..7e65369762c 100644 --- a/spec/services/merge_requests/close_service_spec.rb +++ b/spec/services/merge_requests/close_service_spec.rb @@ -52,6 +52,13 @@ describe MergeRequests::CloseService do end end + it 'refreshes the number of open merge requests for a valid MR' do + service = described_class.new(project, user, {}) + + expect { service.execute(merge_request) } + .to change { project.open_merge_requests_count }.from(1).to(0) + end + context 'current user is not authorized to close merge request' do before do perform_enqueued_jobs do diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index a1f3bec42cc..d6409c0d625 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -18,31 +18,35 @@ describe MergeRequests::CreateService do end let(:service) { described_class.new(project, user, opts) } + let(:merge_request) { service.execute } before do project.team << [user, :master] project.team << [assignee, :developer] allow(service).to receive(:execute_hooks) - - @merge_request = service.execute end it 'creates an MR' do - expect(@merge_request).to be_valid - expect(@merge_request.title).to eq('Awesome merge_request') - expect(@merge_request.assignee).to be_nil - expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1') + expect(merge_request).to be_valid + expect(merge_request.title).to eq('Awesome merge_request') + expect(merge_request.assignee).to be_nil + expect(merge_request.merge_params['force_remove_source_branch']).to eq('1') end it 'executes hooks with default action' do - expect(service).to have_received(:execute_hooks).with(@merge_request) + expect(service).to have_received(:execute_hooks).with(merge_request) + end + + it 'refreshes the number of open merge requests' do + expect { service.execute } + .to change { project.open_merge_requests_count }.from(0).to(1) end it 'does not creates todos' do attributes = { project: project, - target_id: @merge_request.id, - target_type: @merge_request.class.name + target_id: merge_request.id, + target_type: merge_request.class.name } expect(Todo.where(attributes).count).to be_zero @@ -51,8 +55,8 @@ describe MergeRequests::CreateService do it 'creates exactly 1 create MR event' do attributes = { action: Event::CREATED, - target_id: @merge_request.id, - target_type: @merge_request.class.name + target_id: merge_request.id, + target_type: merge_request.class.name } expect(Event.where(attributes).count).to eq(1) @@ -69,15 +73,15 @@ describe MergeRequests::CreateService do } end - it { expect(@merge_request.assignee).to eq assignee } + it { expect(merge_request.assignee).to eq assignee } it 'creates a todo for new assignee' do attributes = { project: project, author: user, user: assignee, - target_id: @merge_request.id, - target_type: @merge_request.class.name, + target_id: merge_request.id, + target_type: merge_request.class.name, action: Todo::ASSIGNED, state: :pending } diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb index f02af0c582e..fa652611c6b 100644 --- a/spec/services/merge_requests/reopen_service_spec.rb +++ b/spec/services/merge_requests/reopen_service_spec.rb @@ -47,6 +47,13 @@ describe MergeRequests::ReopenService do end end + it 'refreshes the number of open merge requests for a valid MR' do + service = described_class.new(project, user, {}) + + expect { service.execute(merge_request) } + .to change { project.open_merge_requests_count }.from(0).to(1) + end + context 'current user is not authorized to reopen merge request' do before do perform_enqueued_jobs do diff --git a/spec/services/projects/count_service_spec.rb b/spec/services/projects/count_service_spec.rb new file mode 100644 index 00000000000..79b01e7620e --- /dev/null +++ b/spec/services/projects/count_service_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +describe Projects::CountService do + let(:project) { build(:project, id: 1) } + let(:service) { described_class.new(project) } + + describe '#relation_for_count' do + it 'raises NotImplementedError' do + expect { service.relation_for_count }.to raise_error(NotImplementedError) + end + end + + describe '#count' do + before do + allow(service).to receive(:cache_key_name).and_return('count_service') + end + + it 'returns the number of rows' do + allow(service).to receive(:uncached_count).and_return(1) + + expect(service.count).to eq(1) + end + + it 'caches the number of rows', :use_clean_rails_memory_store_caching do + expect(service).to receive(:uncached_count).once.and_return(1) + + 2.times do + expect(service.count).to eq(1) + end + end + end + + describe '#refresh_cache', :use_clean_rails_memory_store_caching do + before do + allow(service).to receive(:cache_key_name).and_return('count_service') + end + + it 'refreshes the cache' do + expect(service).to receive(:uncached_count).once.and_return(1) + + service.refresh_cache + + expect(service.count).to eq(1) + end + end + + describe '#delete_cache', :use_clean_rails_memory_store_caching do + before do + allow(service).to receive(:cache_key_name).and_return('count_service') + end + + it 'removes the cache' do + expect(service).to receive(:uncached_count).twice.and_return(1) + + service.count + service.delete_cache + service.count + end + end + + describe '#cache_key_name' do + it 'raises NotImplementedError' do + expect { service.cache_key_name }.to raise_error(NotImplementedError) + end + end + + describe '#cache_key' do + it 'returns the cache key as an Array' do + allow(service).to receive(:cache_key_name).and_return('count_service') + expect(service.cache_key).to eq(['projects', 1, 'count_service']) + end + end +end diff --git a/spec/services/projects/forks_count_service_spec.rb b/spec/services/projects/forks_count_service_spec.rb index cf299c5d09b..9f8e7ee18a8 100644 --- a/spec/services/projects/forks_count_service_spec.rb +++ b/spec/services/projects/forks_count_service_spec.rb @@ -1,40 +1,14 @@ require 'spec_helper' describe Projects::ForksCountService do - let(:project) { build(:project, id: 42) } - let(:service) { described_class.new(project) } - describe '#count' do it 'returns the number of forks' do - allow(service).to receive(:uncached_count).and_return(1) - - expect(service.count).to eq(1) - end - - it 'caches the forks count', :use_clean_rails_memory_store_caching do - expect(service).to receive(:uncached_count).once.and_return(1) + project = build(:project, id: 42) + service = described_class.new(project) - 2.times { service.count } - end - end - - describe '#refresh_cache', :use_clean_rails_memory_store_caching do - it 'refreshes the cache' do - expect(service).to receive(:uncached_count).once.and_return(1) - - service.refresh_cache + allow(service).to receive(:uncached_count).and_return(1) expect(service.count).to eq(1) end end - - describe '#delete_cache', :use_clean_rails_memory_store_caching do - it 'removes the cache' do - expect(service).to receive(:uncached_count).twice.and_return(1) - - service.count - service.delete_cache - service.count - end - end end diff --git a/spec/services/projects/open_issues_count_service_spec.rb b/spec/services/projects/open_issues_count_service_spec.rb new file mode 100644 index 00000000000..f964f9972cd --- /dev/null +++ b/spec/services/projects/open_issues_count_service_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Projects::OpenIssuesCountService do + describe '#count' do + it 'returns the number of open issues' do + project = create(:project) + create(:issue, :opened, project: project) + + expect(described_class.new(project).count).to eq(1) + end + + it 'does not include confidential issues in the issue count' do + project = create(:project) + + create(:issue, :opened, project: project) + create(:issue, :opened, confidential: true, project: project) + + expect(described_class.new(project).count).to eq(1) + end + end +end diff --git a/spec/services/projects/open_merge_requests_count_service_spec.rb b/spec/services/projects/open_merge_requests_count_service_spec.rb new file mode 100644 index 00000000000..9f49b9ec6a2 --- /dev/null +++ b/spec/services/projects/open_merge_requests_count_service_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe Projects::OpenMergeRequestsCountService do + describe '#count' do + it 'returns the number of open merge requests' do + project = create(:project) + create(:merge_request, + :opened, + source_project: project, + target_project: project) + + expect(described_class.new(project).count).to eq(1) + end + end +end -- cgit v1.2.1 From 9240d3552a0850dc3a7a661012c51af12c9f6457 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Wed, 23 Aug 2017 13:44:54 +0200 Subject: Properly encode Gitaly RawBlame request params --- lib/gitlab/gitaly_client/commit_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 8fb7341b2dc..57f42bd35ee 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -175,8 +175,8 @@ module Gitlab def raw_blame(revision, path) request = Gitaly::RawBlameRequest.new( repository: @gitaly_repo, - revision: revision, - path: path + revision: GitalyClient.encode(revision), + path: GitalyClient.encode(path) ) response = GitalyClient.call(@repository.storage, :commit_service, :raw_blame, request) -- cgit v1.2.1 From f90659109487b0dd5303e5072feb86f10976ecae Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 13:48:48 +0200 Subject: Fix cycle analytics test data generation and specs --- spec/support/cycle_analytics_helpers.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index 30911e7fa86..39586d37e93 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -78,6 +78,8 @@ module CycleAnalyticsHelpers @dummy_pipeline ||= Ci::Pipeline.new( sha: project.repository.commit('master').sha, + ref: 'master', + source: :push, project: project) end -- cgit v1.2.1 From 72018278a4bf79a3cdfa63258534d4bbc8ac8161 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 11:28:52 +0200 Subject: Invalidate cache before cleaning db in tests after context --- spec/support/db_cleaner.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb index b0f520d08e8..edaee03ea6c 100644 --- a/spec/support/db_cleaner.rb +++ b/spec/support/db_cleaner.rb @@ -4,18 +4,18 @@ RSpec.configure do |config| end config.append_after(:context) do - DatabaseCleaner.clean_with(:truncation) + DatabaseCleaner.clean_with(:truncation, cache_tables: false) end config.before(:each) do DatabaseCleaner.strategy = :transaction end - config.before(:each, js: true) do + config.before(:each, :js) do DatabaseCleaner.strategy = :truncation end - config.before(:each, truncate: true) do + config.before(:each, :truncate) do DatabaseCleaner.strategy = :truncation end -- cgit v1.2.1 From 438e18d8093afc31626408bb76954a7d9e635bbd Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 21 Aug 2017 23:22:17 +0900 Subject: Refurbish spec/features/runners_spec.rb --- app/views/projects/runners/_runner.html.haml | 2 +- spec/features/runners_spec.rb | 199 ++++++++++++--------------- 2 files changed, 92 insertions(+), 109 deletions(-) diff --git a/app/views/projects/runners/_runner.html.haml b/app/views/projects/runners/_runner.html.haml index abc97bcdff5..25d862ab4de 100644 --- a/app/views/projects/runners/_runner.html.haml +++ b/app/views/projects/runners/_runner.html.haml @@ -8,7 +8,7 @@ - if runner.locked? = icon('lock', class: 'has-tooltip', title: 'Locked to current projects') - %small + %small.edit-runner = link_to edit_project_runner_path(@project, runner) do %i.fa.fa-edit.btn - else diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index cac31c34ad1..4f87dbe392d 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -1,149 +1,132 @@ require 'spec_helper' -describe "Runners" do - let(:user) { create(:user) } +feature 'Runners' do + given(:user) { create(:user) } - before do + background do sign_in(user) end - describe "specific runners" do - before do - @project = FactoryGirl.create :project, shared_runners_enabled: false - @project.team << [user, :master] + context 'when a project has enabled shared_runners' do + given(:project) { create(:project) } - @project2 = FactoryGirl.create :project - @project2.team << [user, :master] + context 'when a specific runner is activated on the project' do + given(:specific_runner) { create(:ci_runner, :specific) } - @project3 = FactoryGirl.create :project - @project3.team << [user, :developer] + background do + project.add_master(user) + project.runners << specific_runner + end - @shared_runner = FactoryGirl.create :ci_runner, :shared - @specific_runner = FactoryGirl.create :ci_runner - @specific_runner2 = FactoryGirl.create :ci_runner - @specific_runner3 = FactoryGirl.create :ci_runner - @project.runners << @specific_runner - @project2.runners << @specific_runner2 - @project3.runners << @specific_runner3 + scenario 'user sees the specific runner' do + visit runners_path(project) - visit runners_path(@project) - end + within '.activated-specific-runners' do + expect(page).to have_content(specific_runner.display_name) + end - before do - expect(page).not_to have_content(@specific_runner3.display_name) - expect(page).not_to have_content(@specific_runner3.display_name) - end + click_on specific_runner.short_sha - it "places runners in right places" do - expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name) - expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name) - expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name) - end - - it "enables specific runner for project" do - within ".available-specific-runners" do - click_on "Enable for this project" + expect(page).to have_content(specific_runner.platform) end - expect(page.find(".activated-specific-runners")).to have_content(@specific_runner2.display_name) - end + scenario 'user removes an activated specific runner' do + visit runners_path(project) - it "disables specific runner for project" do - @project2.runners << @specific_runner - visit runners_path(@project) + within '.activated-specific-runners' do + click_on 'Remove Runner' + end - within ".activated-specific-runners" do - click_on "Disable for this project" + expect(page).to have_no_css('.activated-specific-runners') end - expect(page.find(".available-specific-runners")).to have_content(@specific_runner.display_name) - end + context 'when a runner has a tag' do + background do + specific_runner.update_attribute(:tag_list, ['tag']) + end - it "removes specific runner for project if this is last project for that runners" do - within ".activated-specific-runners" do - click_on "Remove Runner" - end + scenario 'user edits runner not to run untagged jobs' do + visit runners_path(project) - expect(Ci::Runner.exists?(id: @specific_runner)).to be_falsey - end - end + within '.activated-specific-runners' do + first('.edit-runner > a').click + end - describe "shared runners" do - before do - @project = FactoryGirl.create :project, shared_runners_enabled: false - @project.team << [user, :master] - visit runners_path(@project) - end + expect(page.find_field('runner[run_untagged]')).to be_checked - it "enables shared runners" do - click_on "Enable shared Runners" - expect(@project.reload.shared_runners_enabled).to be_truthy - end - end + uncheck 'runner_run_untagged' + click_button 'Save changes' - describe "shared runners description" do - let(:shared_runners_text) { 'custom **shared** runners description' } - let(:shared_runners_html) { 'custom shared runners description' } + expect(page).to have_content 'Can run untagged jobs No' + end + end - before do - stub_application_setting(shared_runners_text: shared_runners_text) - project = FactoryGirl.create :project, shared_runners_enabled: false - project.team << [user, :master] - visit runners_path(project) - end + context 'when a specific runner exists in another project' do + given(:another_project) { create(:project) } + given(:specific_runner2) { create(:ci_runner, :specific) } - it "sees shared runners description" do - expect(page.find(".shared-runners-description")).to have_content(shared_runners_html) - end - end + background do + another_project.add_master(user) + another_project.runners << specific_runner2 + end - describe "show page" do - before do - @project = FactoryGirl.create :project - @project.team << [user, :master] - @specific_runner = FactoryGirl.create :ci_runner - @project.runners << @specific_runner - end + scenario 'user enables and disables a specific runner' do + visit runners_path(project) - it "shows runner information" do - visit runners_path(@project) - click_on @specific_runner.short_sha - expect(page).to have_content(@specific_runner.platform) - end - end + within '.available-specific-runners' do + click_on 'Enable for this project' + end - feature 'configuring runners ability to picking untagged jobs' do - given(:project) { create(:project) } - given(:runner) { create(:ci_runner) } + expect(page.find('.activated-specific-runners')).to have_content(specific_runner2.display_name) - background do - project.team << [user, :master] - project.runners << runner - end + within '.activated-specific-runners' do + click_on 'Disable for this project' + end - scenario 'user checks default configuration' do - visit project_runner_path(project, runner) + expect(page.find('.activated-specific-runners')).not_to have_content(specific_runner2.display_name) + end + end + + context 'when a shared runner is activated on the project' do + given!(:shared_runner) { create(:ci_runner, :shared) } - expect(page).to have_content 'Can run untagged jobs Yes' + scenario 'user sees CI/CD setting page' do + visit runners_path(project) + + expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name) + end + end end - context 'when runner has tags' do - before do - runner.update_attribute(:tag_list, ['tag']) + context 'when application settings have shared_runners_text' do + given(:shared_runners_text) { 'custom **shared** runners description' } + given(:shared_runners_html) { 'custom shared runners description' } + + background do + project.add_master(user) + stub_application_setting(shared_runners_text: shared_runners_text) end - scenario 'user wants to prevent runner from running untagged job' do + scenario 'user sees shared runners description' do visit runners_path(project) - page.within('.activated-specific-runners') do - first('small > a').click - end - - uncheck 'runner_run_untagged' - click_button 'Save changes' - expect(page).to have_content 'Can run untagged jobs No' - expect(runner.reload.run_untagged?).to eq false + expect(page.find('.shared-runners-description')).to have_content(shared_runners_html) end end end + + context 'when a project has disabled shared_runners' do + given(:project) { create(:project, shared_runners_enabled: false) } + + background do + project.add_master(user) + end + + scenario 'user enables shared runners' do + visit runners_path(project) + + click_on 'Enable shared Runners' + expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners') + end + end end -- cgit v1.2.1 From 3c2bcf258ce2171617c0b89a2343a96586b750d2 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 14:20:48 +0200 Subject: Fix feature specs for pages deployment --- features/steps/project/pages.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/steps/project/pages.rb b/features/steps/project/pages.rb index 275fb4fc010..bb69c0d6e99 100644 --- a/features/steps/project/pages.rb +++ b/features/steps/project/pages.rb @@ -35,7 +35,10 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps end step 'pages are deployed' do - pipeline = @project.pipelines.create(ref: 'HEAD', sha: @project.commit('HEAD').sha) + pipeline = @project.pipelines.create(ref: 'HEAD', + sha: @project.commit('HEAD').sha, + source: :push) + build = build(:ci_build, project: @project, pipeline: pipeline, @@ -43,6 +46,7 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps artifacts_file: fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip'), artifacts_metadata: fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip.meta') ) + result = ::Projects::UpdatePagesService.new(@project, build).execute expect(result[:status]).to eq(:success) end -- cgit v1.2.1 From 3eba43b62dc825dd8a40f74fe027bb613b8ed2a8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 23 Aug 2017 14:48:26 +0200 Subject: Adjust a range and a size in stages statuses migration --- db/post_migrate/20170711145558_migrate_stages_statuses.rb | 8 ++++---- spec/migrations/migrate_stages_statuses_spec.rb | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb index 5a24fb1307f..7eb577ff3b2 100644 --- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb +++ b/db/post_migrate/20170711145558_migrate_stages_statuses.rb @@ -6,7 +6,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration disable_ddl_transaction! BATCH_SIZE = 10000 - RANGE_SIZE = 1000 + RANGE_SIZE = 500 MIGRATION = 'MigrateStageStatus'.freeze class Stage < ActiveRecord::Base @@ -17,10 +17,10 @@ class MigrateStagesStatuses < ActiveRecord::Migration def up Stage.where(status: nil).each_batch(of: BATCH_SIZE) do |relation, index| relation.each_batch(of: RANGE_SIZE) do |batch| - range = relation.pluck('MIN(id)', 'MAX(id)').first - schedule = index * 5.minutes + range = batch.pluck('MIN(id)', 'MAX(id)').first + delay = index * 5.minutes - BackgroundMigrationWorker.perform_in(schedule, MIGRATION, range) + BackgroundMigrationWorker.perform_in(delay, MIGRATION, range) end end end diff --git a/spec/migrations/migrate_stages_statuses_spec.rb b/spec/migrations/migrate_stages_statuses_spec.rb index 4102d57e368..094c9bc604e 100644 --- a/spec/migrations/migrate_stages_statuses_spec.rb +++ b/spec/migrations/migrate_stages_statuses_spec.rb @@ -12,7 +12,7 @@ describe MigrateStagesStatuses, :migration do before do stub_const("#{described_class.name}::BATCH_SIZE", 2) - stub_const("#{described_class.name}::RANGE_SIZE", 2) + stub_const("#{described_class.name}::RANGE_SIZE", 1) projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1') projects.create!(id: 2, name: 'gitlab2', path: 'gitlab2') @@ -50,9 +50,10 @@ describe MigrateStagesStatuses, :migration do Timecop.freeze do migrate! - expect(described_class::MIGRATION).to be_scheduled_migration(5.minutes, 1, 2) + expect(described_class::MIGRATION).to be_scheduled_migration(5.minutes, 1, 1) + expect(described_class::MIGRATION).to be_scheduled_migration(5.minutes, 2, 2) expect(described_class::MIGRATION).to be_scheduled_migration(10.minutes, 3, 3) - expect(BackgroundMigrationWorker.jobs.size).to eq 2 + expect(BackgroundMigrationWorker.jobs.size).to eq 3 end end end -- cgit v1.2.1 From fab3df77cf72126f4fad95dc558fb5bf46fd20e0 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 23 Aug 2017 21:58:45 +0900 Subject: Fix tests --- spec/features/runners_spec.rb | 61 +++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index 4f87dbe392d..785cfeb34bd 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -10,11 +10,14 @@ feature 'Runners' do context 'when a project has enabled shared_runners' do given(:project) { create(:project) } + background do + project.add_master(user) + end + context 'when a specific runner is activated on the project' do given(:specific_runner) { create(:ci_runner, :specific) } background do - project.add_master(user) project.runners << specific_runner end @@ -30,19 +33,19 @@ feature 'Runners' do expect(page).to have_content(specific_runner.platform) end - scenario 'user removes an activated specific runner' do + scenario 'user removes an activated specific runner if this is last project for that runners' do visit runners_path(project) within '.activated-specific-runners' do click_on 'Remove Runner' end - expect(page).to have_no_css('.activated-specific-runners') + expect(page).not_to have_content(specific_runner.display_name) end context 'when a runner has a tag' do background do - specific_runner.update_attribute(:tag_list, ['tag']) + specific_runner.update(tag_list: ['tag']) end scenario 'user edits runner not to run untagged jobs' do @@ -61,40 +64,40 @@ feature 'Runners' do end end - context 'when a specific runner exists in another project' do - given(:another_project) { create(:project) } - given(:specific_runner2) { create(:ci_runner, :specific) } - - background do - another_project.add_master(user) - another_project.runners << specific_runner2 - end + context 'when a shared runner is activated on the project' do + given!(:shared_runner) { create(:ci_runner, :shared) } - scenario 'user enables and disables a specific runner' do + scenario 'user sees CI/CD setting page' do visit runners_path(project) - within '.available-specific-runners' do - click_on 'Enable for this project' - end - - expect(page.find('.activated-specific-runners')).to have_content(specific_runner2.display_name) + expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name) + end + end + end - within '.activated-specific-runners' do - click_on 'Disable for this project' - end + context 'when a specific runner exists in another project' do + given(:another_project) { create(:project) } + given(:specific_runner) { create(:ci_runner, :specific) } - expect(page.find('.activated-specific-runners')).not_to have_content(specific_runner2.display_name) - end + background do + another_project.add_master(user) + another_project.runners << specific_runner end - context 'when a shared runner is activated on the project' do - given!(:shared_runner) { create(:ci_runner, :shared) } + scenario 'user enables and disables a specific runner' do + visit runners_path(project) - scenario 'user sees CI/CD setting page' do - visit runners_path(project) + within '.available-specific-runners' do + click_on 'Enable for this project' + end - expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name) + expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name) + + within '.activated-specific-runners' do + click_on 'Disable for this project' end + + expect(page.find('.available-specific-runners')).to have_content(specific_runner.display_name) end end @@ -103,7 +106,6 @@ feature 'Runners' do given(:shared_runners_html) { 'custom shared runners description' } background do - project.add_master(user) stub_application_setting(shared_runners_text: shared_runners_text) end @@ -126,6 +128,7 @@ feature 'Runners' do visit runners_path(project) click_on 'Enable shared Runners' + expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners') end end -- cgit v1.2.1 From b47798664d8653acbebfd65ad26fb72b25454e99 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 23 Aug 2017 14:03:49 +0100 Subject: Update licensing query guidelines --- doc/development/licensing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/development/licensing.md b/doc/development/licensing.md index 1f115059fb8..2b16dfe0e7c 100644 --- a/doc/development/licensing.md +++ b/doc/development/licensing.md @@ -66,7 +66,7 @@ Libraries with the following licenses are unacceptable for use: ## Requesting Approval for Licenses -Libraries that are not listed in the [Acceptable Licenses][Acceptable-Licenses] or [Unacceptable Licenses][Unacceptable-Licenses] list can be submitted to the legal team for review. Please create an issue in the [Organization Repository][Org-Repo] and cc `@gl-legal`. After a decision has been made, the original requestor is responsible for updating this document. +Libraries that are not listed in the [Acceptable Licenses][Acceptable-Licenses] or [Unacceptable Licenses][Unacceptable-Licenses] list can be submitted to the legal team for review. Please email `legal@gitlab.com` with the details. After a decision has been made, the original requestor is responsible for updating this document. ## Notes -- cgit v1.2.1 From 9eb28bbf218d8d7bfdfc0db4bc49e59004c847e0 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 23 Aug 2017 14:44:49 +0100 Subject: Added repo_service_spec for commitFlash and corrected repo_commit-Secion api spec --- .../javascripts/repo/services/repo_service.js | 16 ++++--- .../repo/components/repo_commit_section_spec.js | 2 +- .../javascripts/repo/services/repo_service_spec.js | 50 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js index a8a4b419ae8..af83497fa39 100644 --- a/app/assets/javascripts/repo/services/repo_service.js +++ b/app/assets/javascripts/repo/services/repo_service.js @@ -67,13 +67,15 @@ const RepoService = { commitFiles(payload) { return Api.commitMultiple(Store.projectId, payload) - .then((data) => { - if (data.short_id && data.stats) { - Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); - } else { - Flash(data.message); - } - }); + .then(this.commitFlash); + }, + + commitFlash(data) { + if (data.short_id && data.stats) { + window.Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); + } else { + window.Flash(data.message); + } }, }; diff --git a/spec/javascripts/repo/components/repo_commit_section_spec.js b/spec/javascripts/repo/components/repo_commit_section_spec.js index 1cbb4914005..e604dcc152d 100644 --- a/spec/javascripts/repo/components/repo_commit_section_spec.js +++ b/spec/javascripts/repo/components/repo_commit_section_spec.js @@ -3,7 +3,7 @@ import repoCommitSection from '~/repo/components/repo_commit_section.vue'; import RepoStore from '~/repo/stores/repo_store'; import RepoService from '~/repo/services/repo_service'; -fdescribe('RepoCommitSection', () => { +describe('RepoCommitSection', () => { const branch = 'master'; const projectUrl = 'projectUrl'; const changedFiles = [{ diff --git a/spec/javascripts/repo/services/repo_service_spec.js b/spec/javascripts/repo/services/repo_service_spec.js index d74e6a67b1e..6f530770525 100644 --- a/spec/javascripts/repo/services/repo_service_spec.js +++ b/spec/javascripts/repo/services/repo_service_spec.js @@ -1,5 +1,7 @@ import axios from 'axios'; import RepoService from '~/repo/services/repo_service'; +import RepoStore from '~/repo/stores/repo_store'; +import Api from '~/api'; describe('RepoService', () => { it('has default json format param', () => { @@ -118,4 +120,52 @@ describe('RepoService', () => { }).catch(done.fail); }); }); + + describe('commitFiles', () => { + it('calls commitMultiple and .then commitFlash', (done) => { + const projectId = 'projectId'; + const payload = {}; + RepoStore.projectId = projectId; + + spyOn(Api, 'commitMultiple').and.returnValue(Promise.resolve()); + spyOn(RepoService, 'commitFlash'); + + const apiPromise = RepoService.commitFiles(payload); + + expect(Api.commitMultiple).toHaveBeenCalledWith(projectId, payload); + + apiPromise.then(() => { + expect(RepoService.commitFlash).toHaveBeenCalled(); + done(); + }).catch(done.fail); + }); + }); + + describe('commitFlash', () => { + it('calls Flash with data.message', () => { + const data = { + message: 'message', + }; + spyOn(window, 'Flash'); + + RepoService.commitFlash(data); + + expect(window.Flash).toHaveBeenCalledWith(data.message); + }); + + it('calls Flash with success string if short_id and stats', () => { + const data = { + short_id: 'short_id', + stats: { + additions: '4', + deletions: '5', + }, + }; + spyOn(window, 'Flash'); + + RepoService.commitFlash(data); + + expect(window.Flash).toHaveBeenCalledWith(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); + }); + }); }); -- cgit v1.2.1 From c184a135f2a17a4bcf6189ae92e6cedb31855033 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Wed, 23 Aug 2017 23:45:38 +1000 Subject: Update CHANGELOG.md for 9.5.1 [ci skip] --- CHANGELOG.md | 8 ++++++++ changelogs/unreleased/13719-git-gc-timeout.yml | 3 --- changelogs/unreleased/dm-commit-cache-i18n.yml | 5 ----- changelogs/unreleased/fix-broadcast-message-caching.yml | 5 ----- .../fix-gb-fix-head-pipeline-when-pipeline-has-errors.yml | 5 ----- changelogs/unreleased/only-limit-fetch-when-requested.yml | 5 ----- 6 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 changelogs/unreleased/13719-git-gc-timeout.yml delete mode 100644 changelogs/unreleased/dm-commit-cache-i18n.yml delete mode 100644 changelogs/unreleased/fix-broadcast-message-caching.yml delete mode 100644 changelogs/unreleased/fix-gb-fix-head-pipeline-when-pipeline-has-errors.yml delete mode 100644 changelogs/unreleased/only-limit-fetch-when-requested.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d969164cfe..d32b6989388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ documentation](doc/development/changelog.md) for instructions on adding your own entry. +## 9.5.1 (2017-08-23) + +- [FIXED] Fix merge request pipeline status when pipeline has errors. !13664 +- [FIXED] Commit rows would occasionally render with the wrong language. +- [FIXED] Fix caching of future broadcast messages. +- [FIXED] Only require Sidekiq throttling library when enabled, to reduce cache misses. +- Raise Housekeeping timeout to 24 hours. !13719 + ## 9.5.0 (2017-08-22) - [FIXED] Fix timeouts when creating projects in groups with many members. !13508 diff --git a/changelogs/unreleased/13719-git-gc-timeout.yml b/changelogs/unreleased/13719-git-gc-timeout.yml deleted file mode 100644 index 13cf97ec764..00000000000 --- a/changelogs/unreleased/13719-git-gc-timeout.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -title: "Raise Housekeeping timeout to 24 hours" -merge_request: 13719 diff --git a/changelogs/unreleased/dm-commit-cache-i18n.yml b/changelogs/unreleased/dm-commit-cache-i18n.yml deleted file mode 100644 index d47226fd408..00000000000 --- a/changelogs/unreleased/dm-commit-cache-i18n.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Commit rows would occasionally render with the wrong language -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/fix-broadcast-message-caching.yml b/changelogs/unreleased/fix-broadcast-message-caching.yml deleted file mode 100644 index 58ec1766cfd..00000000000 --- a/changelogs/unreleased/fix-broadcast-message-caching.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fix caching of future broadcast messages -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/fix-gb-fix-head-pipeline-when-pipeline-has-errors.yml b/changelogs/unreleased/fix-gb-fix-head-pipeline-when-pipeline-has-errors.yml deleted file mode 100644 index ede8031a501..00000000000 --- a/changelogs/unreleased/fix-gb-fix-head-pipeline-when-pipeline-has-errors.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fix merge request pipeline status when pipeline has errors -merge_request: 13664 -author: -type: fixed diff --git a/changelogs/unreleased/only-limit-fetch-when-requested.yml b/changelogs/unreleased/only-limit-fetch-when-requested.yml deleted file mode 100644 index d9acdf56511..00000000000 --- a/changelogs/unreleased/only-limit-fetch-when-requested.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Only require Sidekiq throttling library when enabled, to reduce cache misses -merge_request: -author: -type: fixed -- cgit v1.2.1 From 0dd71ed4a8901d34dda5b485b75afe595658da53 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Wed, 23 Aug 2017 10:09:22 -0500 Subject: Fix alignment of gpg status --- app/assets/stylesheets/pages/commits.scss | 5 +++-- app/helpers/commits_helper.rb | 2 +- app/views/projects/commits/_commit.html.haml | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/pages/commits.scss b/app/assets/stylesheets/pages/commits.scss index 46fbfe5f91e..d0d11b4d71c 100644 --- a/app/assets/stylesheets/pages/commits.scss +++ b/app/assets/stylesheets/pages/commits.scss @@ -286,6 +286,9 @@ .gpg-status-box { + padding: 2px 10px; + margin-right: $gl-padding; + &:empty { display: none; } @@ -314,7 +317,6 @@ &.valid { svg { border: 1px solid $brand-success; - fill: $brand-success; } } @@ -322,7 +324,6 @@ &.invalid { svg { border: 1px solid $common-gray-light; - fill: $common-gray-light; } } diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 72e26b64e60..9651f9733f9 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -114,7 +114,7 @@ module CommitsHelper end def commit_signature_badge_classes(additional_classes) - %w(btn status-box gpg-status-box) + Array(additional_classes) + %w(btn gpg-status-box) + Array(additional_classes) end protected diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 7e8a5a38086..1214aabe837 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -37,14 +37,14 @@ .commit-actions.hidden-xs - - if commit.status(ref) - = render_commit_status(commit, ref: ref) - - if request.xhr? = render partial: 'projects/commit/signature', object: commit.signature - else = render partial: 'projects/commit/ajax_signature', locals: { commit: commit } + - if commit.status(ref) + = render_commit_status(commit, ref: ref) + = link_to commit.short_id, project_commit_path(project, commit), class: "commit-sha btn btn-transparent" = clipboard_button(text: commit.id, title: _("Copy commit SHA to clipboard")) = link_to_browse_code(project, commit) -- cgit v1.2.1 From 961da7d0a7024628ec87c02c158a147dd64b3317 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 23 Aug 2017 17:23:28 +0200 Subject: Add tests for Committer#== --- spec/lib/gitlab/git/committer_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/lib/gitlab/git/committer_spec.rb diff --git a/spec/lib/gitlab/git/committer_spec.rb b/spec/lib/gitlab/git/committer_spec.rb new file mode 100644 index 00000000000..b0ddbb51449 --- /dev/null +++ b/spec/lib/gitlab/git/committer_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe Gitlab::Git::Committer do + let(:name) { 'Jane Doe' } + let(:email) { 'janedoe@example.com' } + let(:gl_id) { 'user-123' } + + subject { described_class.new(name, email, gl_id) } + + describe '#==' do + def eq_other(name, email, gl_id) + eq(described_class.new(name, email, gl_id)) + end + + it { expect(subject).to eq_other(name, email, gl_id) } + + it { expect(subject).not_to eq_other(nil, nil, nil) } + it { expect(subject).not_to eq_other(name + 'x', email, gl_id) } + it { expect(subject).not_to eq_other(name, email + 'x', gl_id) } + it { expect(subject).not_to eq_other(name, email, gl_id + 'x') } + end +end -- cgit v1.2.1 From 3611b664a94635e950c9d281bbbc8e2360a56fa3 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 23 Aug 2017 09:02:46 +0200 Subject: Fix blank button not resetting project template value The button didn't override a value, so the old value was posted again. --- app/views/projects/_project_templates.html.haml | 2 +- changelogs/unreleased/zj-fix-fe-blank-button.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/zj-fix-fe-blank-button.yml diff --git a/app/views/projects/_project_templates.html.haml b/app/views/projects/_project_templates.html.haml index 97cf13df070..5638b7da1b0 100644 --- a/app/views/projects/_project_templates.html.haml +++ b/app/views/projects/_project_templates.html.haml @@ -1,6 +1,6 @@ .project-templates-buttons.import-buttons{ data: { toggle: "buttons" } } .btn.blank-option.active - %input{ type: "radio", autocomplete: "off", name: "project_templates", id: "blank", checked: "true" } + %input{ type: "radio", autocomplete: "off", name: "project[template_name]", id: "blank", checked: "true", value: "" } = icon('file-o', class: 'btn-template-icon') Blank - Gitlab::ProjectTemplate.all.each do |template| diff --git a/changelogs/unreleased/zj-fix-fe-blank-button.yml b/changelogs/unreleased/zj-fix-fe-blank-button.yml new file mode 100644 index 00000000000..2165d4186c1 --- /dev/null +++ b/changelogs/unreleased/zj-fix-fe-blank-button.yml @@ -0,0 +1,5 @@ +--- +title: Fix new project form not resetting the template value +merge_request: +author: +type: fixed -- cgit v1.2.1 From f5046e5258c9e53b11816490fbdca4134dd5ad0c Mon Sep 17 00:00:00 2001 From: haseeb Date: Wed, 23 Aug 2017 21:43:23 +0530 Subject: [ci skip] changelog entry added for full merge request ref changes --- app/models/merge_request.rb | 1 - .../36262_merge_request_reference_in_merge_commit_global.yml | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/36262_merge_request_reference_in_merge_commit_global.yml diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index de0d541f1c7..a156ef672df 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -682,7 +682,6 @@ class MergeRequest < ActiveRecord::Base if !include_description && closes_issues_references.present? message << "Closes #{closes_issues_references.to_sentence}" end - message << "#{description}" if include_description && description.present? message << "See merge request #{to_reference(full: true)}" diff --git a/changelogs/unreleased/36262_merge_request_reference_in_merge_commit_global.yml b/changelogs/unreleased/36262_merge_request_reference_in_merge_commit_global.yml new file mode 100644 index 00000000000..356857d6e8a --- /dev/null +++ b/changelogs/unreleased/36262_merge_request_reference_in_merge_commit_global.yml @@ -0,0 +1,5 @@ +--- +title: Merge request reference in merge commit changed to full reference +merge_request: 13518 +author: haseebeqx +type: fixed -- cgit v1.2.1 From 502d6464b07154d74eecbeddbf2cd6dba841380f Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 23 Aug 2017 13:01:11 +0100 Subject: Allow v4 API GET requests for groups to be unauthenticated --- lib/api/groups.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 49c3b2278c7..892fd239df4 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -2,7 +2,7 @@ module API class Groups < Grape::API include PaginationParams - before { authenticate! } + before { authenticate_non_get! } helpers do params :optional_params_ce do @@ -48,10 +48,10 @@ module API end get do groups = if params[:owned] - current_user.owned_groups - elsif current_user.admin + current_user ? current_user.owned_groups : Group.none + elsif current_user&.admin? Group.all - elsif params[:all_available] + elsif params[:all_available] || current_user.nil? GroupsFinder.new(current_user).execute else current_user.groups -- cgit v1.2.1 From f67faf6a1626a245ec62f82bd89486ac76953b44 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 23 Aug 2017 19:44:10 +0200 Subject: Update templates to include header in the README --- vendor/project_templates/express.tar.gz | Bin 4572 -> 5645 bytes vendor/project_templates/rails.tar.gz | Bin 23749 -> 24777 bytes vendor/project_templates/spring.tar.gz | Bin 49882 -> 50845 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/vendor/project_templates/express.tar.gz b/vendor/project_templates/express.tar.gz index 6353f6605d5..302a74637b2 100644 Binary files a/vendor/project_templates/express.tar.gz and b/vendor/project_templates/express.tar.gz differ diff --git a/vendor/project_templates/rails.tar.gz b/vendor/project_templates/rails.tar.gz index 0509016f130..0f406705563 100644 Binary files a/vendor/project_templates/rails.tar.gz and b/vendor/project_templates/rails.tar.gz differ diff --git a/vendor/project_templates/spring.tar.gz b/vendor/project_templates/spring.tar.gz index d7c0ab74d01..02006b14406 100644 Binary files a/vendor/project_templates/spring.tar.gz and b/vendor/project_templates/spring.tar.gz differ -- cgit v1.2.1 From e82130bd95d750b231d58287cc4a5d26bbcf3317 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Wed, 23 Aug 2017 14:34:32 -0500 Subject: Hide group title on sidebar collapse; use more generic class for titles --- app/assets/stylesheets/new_sidebar.scss | 5 ++--- app/views/layouts/nav/_new_admin_sidebar.html.haml | 2 +- app/views/layouts/nav/_new_group_sidebar.html.haml | 2 +- app/views/layouts/nav/_new_profile_sidebar.html.haml | 2 +- app/views/layouts/nav/_new_project_sidebar.html.haml | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/new_sidebar.scss b/app/assets/stylesheets/new_sidebar.scss index cee5b22adb9..25c6715899b 100644 --- a/app/assets/stylesheets/new_sidebar.scss +++ b/app/assets/stylesheets/new_sidebar.scss @@ -70,8 +70,7 @@ $new-sidebar-collapsed-width: 50px; background-color: $white-light; } - .project-title, - .group-title { + .sidebar-context-title { overflow: hidden; text-overflow: ellipsis; } @@ -109,7 +108,7 @@ $new-sidebar-collapsed-width: 50px; } .badge, - .project-title { + .sidebar-context-title { display: none; } diff --git a/app/views/layouts/nav/_new_admin_sidebar.html.haml b/app/views/layouts/nav/_new_admin_sidebar.html.haml index 3cbcd841aff..1c3fd4a082c 100644 --- a/app/views/layouts/nav/_new_admin_sidebar.html.haml +++ b/app/views/layouts/nav/_new_admin_sidebar.html.haml @@ -4,7 +4,7 @@ = link_to admin_root_path, title: 'Admin Overview' do .avatar-container.s40.settings-avatar = icon('wrench') - .project-title Admin Area + .sidebar-context-title Admin Area %ul.sidebar-top-level-items = nav_link(controller: %w(dashboard admin projects users groups jobs runners cohorts), html_options: {class: 'home'}) do = link_to admin_root_path, title: 'Overview', class: 'shortcuts-tree' do diff --git a/app/views/layouts/nav/_new_group_sidebar.html.haml b/app/views/layouts/nav/_new_group_sidebar.html.haml index ed5793f09fe..d90aea2e361 100644 --- a/app/views/layouts/nav/_new_group_sidebar.html.haml +++ b/app/views/layouts/nav/_new_group_sidebar.html.haml @@ -4,7 +4,7 @@ = link_to group_path(@group), title: @group.name do .avatar-container.s40.group-avatar = image_tag group_icon(@group), class: "avatar s40 avatar-tile" - .group-title + .sidebar-context-title = @group.name %ul.sidebar-top-level-items = nav_link(path: ['groups#show', 'groups#activity', 'groups#subgroups'], html_options: { class: 'home' }) do diff --git a/app/views/layouts/nav/_new_profile_sidebar.html.haml b/app/views/layouts/nav/_new_profile_sidebar.html.haml index 4234df56d1d..85b2c7630c8 100644 --- a/app/views/layouts/nav/_new_profile_sidebar.html.haml +++ b/app/views/layouts/nav/_new_profile_sidebar.html.haml @@ -4,7 +4,7 @@ = link_to profile_path, title: 'Profile Settings' do .avatar-container.s40.settings-avatar = icon('user') - .project-title User Settings + .sidebar-context-title User Settings %ul.sidebar-top-level-items = nav_link(path: 'profiles#show', html_options: {class: 'home'}) do = link_to profile_path, title: 'Profile Settings' do diff --git a/app/views/layouts/nav/_new_project_sidebar.html.haml b/app/views/layouts/nav/_new_project_sidebar.html.haml index 0ef81375c3a..9c7d9826f56 100644 --- a/app/views/layouts/nav/_new_project_sidebar.html.haml +++ b/app/views/layouts/nav/_new_project_sidebar.html.haml @@ -5,7 +5,7 @@ = link_to project_path(@project), title: @project.name do .avatar-container.s40.project-avatar = project_icon(@project, alt: @project.name, class: 'avatar s40 avatar-tile') - .project-title + .sidebar-context-title = @project.name %ul.sidebar-top-level-items = nav_link(path: ['projects#show', 'projects#activity', 'cycle_analytics#show'], html_options: { class: 'home' }) do -- cgit v1.2.1 From c1cf5f41018dd4cf0523c6a80c8617651d88658c Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 23 Aug 2017 19:18:13 +0200 Subject: Support simple string LDAP attribute specifications, and search for name rather than username attributes --- changelogs/unreleased/dm-ldap-adapter-attributes.yml | 6 ++++++ lib/gitlab/ldap/adapter.rb | 6 +----- lib/gitlab/ldap/person.rb | 9 +++++++++ spec/lib/gitlab/ldap/adapter_spec.rb | 6 +++--- 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/dm-ldap-adapter-attributes.yml diff --git a/changelogs/unreleased/dm-ldap-adapter-attributes.yml b/changelogs/unreleased/dm-ldap-adapter-attributes.yml new file mode 100644 index 00000000000..edd68ef08e7 --- /dev/null +++ b/changelogs/unreleased/dm-ldap-adapter-attributes.yml @@ -0,0 +1,6 @@ +--- +title: Fix signing in using LDAP when attribute mapping uses simple strings instead + of arrays +merge_request: +author: +type: fixed diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 8867a91c244..cd7e4ca7b7e 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -73,7 +73,7 @@ module Gitlab private def user_options(field, value, limit) - options = { attributes: user_attributes } + options = { attributes: Gitlab::LDAP::Person.ldap_attributes(config).compact.uniq } options[:size] = limit if limit if field.to_sym == :dn @@ -99,10 +99,6 @@ module Gitlab filter end end - - def user_attributes - %W(#{config.uid} cn dn) + config.attributes['username'] + config.attributes['email'] - end end end end diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb index e138b466a34..4d6f8ac79de 100644 --- a/lib/gitlab/ldap/person.rb +++ b/lib/gitlab/ldap/person.rb @@ -21,6 +21,15 @@ module Gitlab adapter.dn_matches_filter?(dn, AD_USER_DISABLED) end + def self.ldap_attributes(config) + [ + 'dn', # Used in `dn` + config.uid, # Used in `uid` + *config.attributes['name'], # Used in `name` + *config.attributes['email'] # Used in `email` + ] + end + def initialize(entry, provider) Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } @entry = entry diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index d17d440d833..d9ddb4326be 100644 --- a/spec/lib/gitlab/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/ldap/adapter_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::LDAP::Adapter do expect(adapter).to receive(:ldap_search) do |arg| expect(arg[:filter].to_s).to eq('(uid=johndoe)') expect(arg[:base]).to eq('dc=example,dc=com') - expect(arg[:attributes]).to match(%w{uid cn dn uid userid sAMAccountName mail email userPrincipalName}) + expect(arg[:attributes]).to match(%w{dn uid cn mail email userPrincipalName}) end.and_return({}) adapter.users('uid', 'johndoe') @@ -26,7 +26,7 @@ describe Gitlab::LDAP::Adapter do expect(adapter).to receive(:ldap_search).with( base: 'uid=johndoe,ou=users,dc=example,dc=com', scope: Net::LDAP::SearchScope_BaseObject, - attributes: %w{uid cn dn uid userid sAMAccountName mail email userPrincipalName}, + attributes: %w{dn uid cn mail email userPrincipalName}, filter: nil ).and_return({}) @@ -63,7 +63,7 @@ describe Gitlab::LDAP::Adapter do it 'uses the right uid attribute when non-default' do stub_ldap_config(uid: 'sAMAccountName') expect(adapter).to receive(:ldap_search).with( - hash_including(attributes: %w{sAMAccountName cn dn uid userid sAMAccountName mail email userPrincipalName}) + hash_including(attributes: %w{dn sAMAccountName cn mail email userPrincipalName}) ).and_return({}) adapter.users('sAMAccountName', 'johndoe') -- cgit v1.2.1 From e6c96c6ed6cb51e25974476babae1f01226b4994 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 23 Aug 2017 18:08:04 -0400 Subject: Remove underscore-rails gem We now manage this dependency in Yarn. --- Gemfile | 3 --- Gemfile.lock | 2 -- 2 files changed, 5 deletions(-) diff --git a/Gemfile b/Gemfile index 72fc2de426e..f71cd492387 100644 --- a/Gemfile +++ b/Gemfile @@ -207,9 +207,6 @@ gem 'kubeclient', '~> 2.2.0' # d3 gem 'd3_rails', '~> 3.5.0' -# underscore-rails -gem 'underscore-rails', '~> 1.8.0' - # Sanitize user input gem 'sanitize', '~> 2.0' gem 'babosa', '~> 1.0.2' diff --git a/Gemfile.lock b/Gemfile.lock index 7d3c53ee010..17bf48befac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -899,7 +899,6 @@ GEM uglifier (2.7.2) execjs (>= 0.3.0) json (>= 1.8.0) - underscore-rails (1.8.3) unf (0.1.4) unf_ext unf_ext (0.0.7.2) @@ -1163,7 +1162,6 @@ DEPENDENCIES truncato (~> 0.7.8) u2f (~> 0.2.1) uglifier (~> 2.7.2) - underscore-rails (~> 1.8.0) unf (~> 0.1.4) unicorn (~> 5.1.0) unicorn-worker-killer (~> 0.4.4) -- cgit v1.2.1 From 37904108b965eecabdbe631ca2f3465a3cf18a1e Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 23 Aug 2017 22:06:42 -0700 Subject: Fix inconsistent number of branches when remote branches are present Users of project mirrors would see that the number of branches did not match the number in the branch dropdown because remote branches were counted when Rugged was in use. With Gitaly, only local branches are counted. Closes #36934 --- lib/gitlab/git/repository.rb | 2 +- spec/lib/gitlab/git/repository_spec.rb | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index eb3731ba35a..f5747951d5e 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -153,7 +153,7 @@ module Gitlab if is_enabled gitaly_ref_client.count_branch_names else - rugged.branches.count do |ref| + rugged.branches.each(:local).count do |ref| begin ref.name && ref.target # ensures the branch is valid diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 8ec8dfe6acf..2b70d16a264 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -977,6 +977,36 @@ describe Gitlab::Git::Repository, seed_helper: true do it 'returns the number of branches' do expect(repository.branch_count).to eq(10) end + + context 'with local and remote branches' do + let(:repository) do + Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git')) + end + + before do + create_remote_branch(repository, 'joe', 'remote_branch', 'master') + repository.create_branch('local_branch', 'master') + end + + after do + FileUtils.rm_rf(TEST_MUTABLE_REPO_PATH) + ensure_seeds + end + + it 'returns the count of local branches' do + expect(repository.branch_count).to eq(repository.local_branches.count) + end + + context 'with Gitaly disabled' do + before do + allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false) + end + + it 'returns the count of local branches' do + expect(repository.branch_count).to eq(repository.local_branches.count) + end + end + end end describe "#ls_files" do -- cgit v1.2.1 From 115b598d4094a303c3941255d2bd478483f3daea Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Thu, 24 Aug 2017 14:17:57 +0700 Subject: Document version Group Milestones API introduced --- .../unreleased/docs-document-version-for-group-milestones-api.yml | 5 +++++ doc/api/group_milestones.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 changelogs/unreleased/docs-document-version-for-group-milestones-api.yml diff --git a/changelogs/unreleased/docs-document-version-for-group-milestones-api.yml b/changelogs/unreleased/docs-document-version-for-group-milestones-api.yml new file mode 100644 index 00000000000..d75c46313f4 --- /dev/null +++ b/changelogs/unreleased/docs-document-version-for-group-milestones-api.yml @@ -0,0 +1,5 @@ +--- +title: Document version Group Milestones API introduced +merge_request: +author: +type: changed diff --git a/doc/api/group_milestones.md b/doc/api/group_milestones.md index dbfc7529125..a96fb3124fc 100644 --- a/doc/api/group_milestones.md +++ b/doc/api/group_milestones.md @@ -1,5 +1,8 @@ # Group milestones API +> **Notes:** +> [Introduced][ce-12819] in GitLab 9.5. + ## List group milestones Returns a list of group milestones. @@ -118,3 +121,5 @@ Parameters: - `id` (required) - The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user - `milestone_id` (required) - The ID of a group milestone + +[ce-12819]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12819 -- cgit v1.2.1 From d184f27ed387c1a90a9f06f68eab801ec3bd89e3 Mon Sep 17 00:00:00 2001 From: Mehdi Lahmam Date: Fri, 11 Aug 2017 11:09:07 +0200 Subject: Refactor Admin::ProjectsFinder by extracting finders as private methods --- app/controllers/admin/projects_controller.rb | 6 +-- app/finders/admin/projects_finder.rb | 74 +++++++++++++++++++--------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 0b6cd71e651..50cf2643390 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -3,9 +3,9 @@ class Admin::ProjectsController < Admin::ApplicationController before_action :group, only: [:show, :transfer] def index - finder = Admin::ProjectsFinder.new(params: params, current_user: current_user) - @projects = finder.execute - @sort = finder.sort + params[:sort] ||= 'latest_activity_desc' + @sort = params[:sort] + @projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute respond_to do |format| format.html diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb index 7176bfe22d6..eac35ae0281 100644 --- a/app/finders/admin/projects_finder.rb +++ b/app/finders/admin/projects_finder.rb @@ -1,33 +1,61 @@ class Admin::ProjectsFinder - attr_reader :sort, :namespace_id, :visibility_level, :with_push, - :abandoned, :last_repository_check_failed, :archived, - :personal, :name, :page, :current_user + attr_reader :params, :current_user def initialize(params:, current_user:) + @params = params @current_user = current_user - @sort = params.fetch(:sort) { 'latest_activity_desc' } - @namespace_id = params[:namespace_id] - @visibility_level = params[:visibility_level] - @with_push = params[:with_push] - @abandoned = params[:abandoned] - @last_repository_check_failed = params[:last_repository_check_failed] - @archived = params[:archived] - @personal = params[:personal] - @name = params[:name] - @page = params[:page] end def execute items = Project.without_deleted.with_statistics - items = items.in_namespace(namespace_id) if namespace_id.present? - items = items.where(visibility_level: visibility_level) if visibility_level.present? - items = items.with_push if with_push.present? - items = items.abandoned if abandoned.present? - items = items.where(last_repository_check_failed: true) if last_repository_check_failed.present? - items = items.non_archived unless archived.present? - items = items.personal(current_user) if personal.present? - items = items.search(name) if name.present? - items = items.sort(sort) - items.includes(:namespace).order("namespaces.path, projects.name ASC").page(page) + items = by_namespace_id(items) + items = by_visibilty_level(items) + items = by_with_push(items) + items = by_abandoned(items) + items = by_last_repository_check_failed(items) + items = by_archived(items) + items = by_personal(items) + items = by_name(items) + items = sort(items) + items.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]) + end + + private + + def by_namespace_id(items) + params[:namespace_id].present? ? items.in_namespace(params[:namespace_id]) : items + end + + def by_visibilty_level(items) + params[:visibility_level].present? ? items.where(visibility_level: params[:visibility_level]) : items + end + + def by_with_push(items) + params[:with_push].present? ? items.with_push : items + end + + def by_abandoned(items) + params[:abandoned].present? ? items.abandoned : items + end + + def by_last_repository_check_failed(items) + params[:last_repository_check_failed].present? ? items.where(last_repository_check_failed: true) : items + end + + def by_archived(items) + items.non_archived unless params[:archived].present? + end + + def by_personal(items) + params[:personal].present? ? items.personal(current_user) : items + end + + def by_name(items) + params[:name].present? ? items.search(params[:name]) : items + end + + def sort(items) + sort = params.fetch(:sort) { 'latest_activity_desc' } + items.sort(sort) end end -- cgit v1.2.1 From 55f4ddad2b765f3b7466af5b43ef319a330c9fcd Mon Sep 17 00:00:00 2001 From: Mehdi Lahmam Date: Fri, 11 Aug 2017 11:09:17 +0200 Subject: Add an option to list only archived projects Closes #35994 --- app/finders/admin/projects_finder.rb | 8 +++++++- app/finders/projects_finder.rb | 17 +++++++++++++---- app/models/project.rb | 1 + app/views/shared/projects/_dropdown.html.haml | 5 ++++- changelogs/unreleased/35994-archived-projects-only.yml | 5 +++++ spec/features/admin/admin_projects_spec.rb | 8 ++++++++ spec/features/dashboard/archived_projects_spec.rb | 7 +++++++ spec/finders/admin/projects_finder_spec.rb | 6 ++++++ spec/finders/projects_finder_spec.rb | 6 ++++++ 9 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/35994-archived-projects-only.yml diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb index eac35ae0281..d6bcd939522 100644 --- a/app/finders/admin/projects_finder.rb +++ b/app/finders/admin/projects_finder.rb @@ -43,7 +43,13 @@ class Admin::ProjectsFinder end def by_archived(items) - items.non_archived unless params[:archived].present? + if params[:archived] == 'only' + items.archived + elsif params[:archived].blank? + items.non_archived + else + items + end end def by_personal(items) diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index aa80dfc3f37..fa6fea2588a 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -125,9 +125,18 @@ class ProjectsFinder < UnionFinder end def by_archived(projects) - # Back-compatibility with the places where `params[:archived]` can be set explicitly to `false` - params[:non_archived] = !Gitlab::Utils.to_boolean(params[:archived]) if params.key?(:archived) - - params[:non_archived] ? projects.non_archived : projects + if params[:non_archived] + projects.non_archived + elsif params.key?(:archived) # Back-compatibility with the places where `params[:archived]` can be set explicitly to `false` + if params[:archived] == 'only' + projects.archived + elsif Gitlab::Utils.to_boolean(params[:archived]) + projects + else + projects.non_archived + end + else + projects + end end end diff --git a/app/models/project.rb b/app/models/project.rb index 3118a480f7b..9d5a56db026 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -247,6 +247,7 @@ class Project < ActiveRecord::Base scope :joined, ->(user) { where('namespace_id != ?', user.namespace_id) } scope :starred_by, ->(user) { joins(:users_star_projects).where('users_star_projects.user_id': user.id) } scope :visible_to_user, ->(user) { where(id: user.authorized_projects.select(:id).reorder(nil)) } + scope :archived, -> { where(archived: true) } scope :non_archived, -> { where(archived: false) } scope :for_milestones, ->(ids) { joins(:milestones).where('milestones.id' => ids).distinct } scope :with_push, -> { joins(:events).where('events.action = ?', Event::PUSHED) } diff --git a/app/views/shared/projects/_dropdown.html.haml b/app/views/shared/projects/_dropdown.html.haml index 8939aeb6c3a..80432a73e4e 100644 --- a/app/views/shared/projects/_dropdown.html.haml +++ b/app/views/shared/projects/_dropdown.html.haml @@ -15,8 +15,11 @@ = link_to filter_projects_path(archived: nil), class: ("is-active" unless params[:archived].present?) do Hide archived projects %li - = link_to filter_projects_path(archived: true), class: ("is-active" if params[:archived].present?) do + = link_to filter_projects_path(archived: true), class: ("is-active" if Gitlab::Utils.to_boolean(params[:archived])) do Show archived projects + %li + = link_to filter_projects_path(archived: 'only'), class: ("is-active" if params[:archived] == 'only') do + Show archived projects only - if current_user %li.divider %li diff --git a/changelogs/unreleased/35994-archived-projects-only.yml b/changelogs/unreleased/35994-archived-projects-only.yml new file mode 100644 index 00000000000..ce565b177d0 --- /dev/null +++ b/changelogs/unreleased/35994-archived-projects-only.yml @@ -0,0 +1,5 @@ +--- +title: Add an option to list only archived projects +merge_request: 13492 +author: Mehdi Lahmam (@mehlah) +type: added diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 77710f80036..f4f2505d436 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -36,6 +36,14 @@ describe "Admin::Projects" do expect(page).to have_content(archived_project.name) expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived') end + + it 'renders only archived projects', js: true do + find(:css, '#sort-projects-dropdown').click + click_link 'Show archived projects only' + + expect(page).to have_content(archived_project.name) + expect(page).not_to have_content(project.name) + end end describe "GET /admin/projects/:namespace_id/:id" do diff --git a/spec/features/dashboard/archived_projects_spec.rb b/spec/features/dashboard/archived_projects_spec.rb index 814ec0e59c7..e8d699ff5e0 100644 --- a/spec/features/dashboard/archived_projects_spec.rb +++ b/spec/features/dashboard/archived_projects_spec.rb @@ -26,6 +26,13 @@ RSpec.describe 'Dashboard Archived Project' do expect(page).to have_link(archived_project.name) end + it 'renders only archived projects' do + click_link 'Show archived projects only' + + expect(page).to have_content(archived_project.name) + expect(page).not_to have_content(project.name) + end + it 'searchs archived projects', :js do click_button 'Last updated' click_link 'Show archived projects' diff --git a/spec/finders/admin/projects_finder_spec.rb b/spec/finders/admin/projects_finder_spec.rb index 28e36330029..4b67203a0df 100644 --- a/spec/finders/admin/projects_finder_spec.rb +++ b/spec/finders/admin/projects_finder_spec.rb @@ -118,6 +118,12 @@ describe Admin::ProjectsFinder do it { is_expected.to match_array([archived_project, shared_project, public_project, internal_project, private_project]) } end + + context 'archived=only' do + let(:params) { { archived: 'only' } } + + it { is_expected.to eq([archived_project]) } + end end context 'filter by personal' do diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index a5de586e869..0dfe6ba9c32 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -123,6 +123,12 @@ describe ProjectsFinder do it { is_expected.to match_array([public_project, internal_project, archived_project]) } end + describe 'filter by archived only' do + let(:params) { { archived: 'only' } } + + it { is_expected.to eq([archived_project]) } + end + describe 'filter by archived for backward compatibility' do let(:params) { { archived: false } } -- cgit v1.2.1 From a8efe4c469b13519b600e5ef0f5b1629cd42b01c Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 24 Aug 2017 09:19:49 +0200 Subject: Reword job to pipeline on the chart view This got changed for i18n in !12480, however, I forgot to understand that the meaning of the graphs changed in !12378. This corrects the behaviour. --- .../projects/pipelines/charts/_pipelines.haml | 6 +++--- .../zj-reword-job-to-pipeline-chart-view.yml | 5 +++++ features/steps/project/graph.rb | 6 +++--- locale/gitlab.pot | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 changelogs/unreleased/zj-reword-job-to-pipeline-chart-view.yml diff --git a/app/views/projects/pipelines/charts/_pipelines.haml b/app/views/projects/pipelines/charts/_pipelines.haml index 02f1ef4b6da..7a100843f5e 100644 --- a/app/views/projects/pipelines/charts/_pipelines.haml +++ b/app/views/projects/pipelines/charts/_pipelines.haml @@ -14,19 +14,19 @@ .prepend-top-default %p.light - = _("Jobs for last week") + = _("Pipelines for last week") (#{date_from_to(Date.today - 7.days, Date.today)}) %canvas#weekChart{ height: 200 } .prepend-top-default %p.light - = _("Jobs for last month") + = _("Pipelines for last month") (#{date_from_to(Date.today - 30.days, Date.today)}) %canvas#monthChart{ height: 200 } .prepend-top-default %p.light - = _("Jobs for last year") + = _("Pipelines for last year") %canvas#yearChart.padded{ height: 250 } %script#pipelinesChartsData{ type: "application/json" } diff --git a/changelogs/unreleased/zj-reword-job-to-pipeline-chart-view.yml b/changelogs/unreleased/zj-reword-job-to-pipeline-chart-view.yml new file mode 100644 index 00000000000..474392a8cdd --- /dev/null +++ b/changelogs/unreleased/zj-reword-job-to-pipeline-chart-view.yml @@ -0,0 +1,5 @@ +--- +title: Reword job to pipeline to reflect what the graphs are really about +merge_request: +author: +type: fixed diff --git a/features/steps/project/graph.rb b/features/steps/project/graph.rb index e78e25318a6..b9cddf4041d 100644 --- a/features/steps/project/graph.rb +++ b/features/steps/project/graph.rb @@ -38,9 +38,9 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps step 'page should have CI graphs' do expect(page).to have_content 'Overall' - expect(page).to have_content 'Jobs for last week' - expect(page).to have_content 'Jobs for last month' - expect(page).to have_content 'Jobs for last year' + expect(page).to have_content 'Pipelines for last week' + expect(page).to have_content 'Pipelines for last month' + expect(page).to have_content 'Pipelines for last year' expect(page).to have_content 'Commit duration in minutes for last 30 commits' end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index a4a3ef6c42c..5a1db208d5a 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-08-18 14:15+0530\n" -"PO-Revision-Date: 2017-08-18 14:15+0530\n" +"POT-Creation-Date: 2017-08-24 09:29+0200\n" +"PO-Revision-Date: 2017-08-24 09:29+0200\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -517,15 +517,6 @@ msgstr "" msgid "Issue events" msgstr "" -msgid "Jobs for last month" -msgstr "" - -msgid "Jobs for last week" -msgstr "" - -msgid "Jobs for last year" -msgstr "" - msgid "LFSStatus|Disabled" msgstr "" @@ -766,6 +757,15 @@ msgstr "" msgid "Pipelines charts" msgstr "" +msgid "Pipelines for last month" +msgstr "" + +msgid "Pipelines for last week" +msgstr "" + +msgid "Pipelines for last year" +msgstr "" + msgid "Pipeline|all" msgstr "" -- cgit v1.2.1 From fb49c94e49149a2043b774ba33daa3fe79febdd4 Mon Sep 17 00:00:00 2001 From: Andrew Newdigate Date: Thu, 24 Aug 2017 09:20:04 +0000 Subject: Delegate Repository::branch_exists? and ref_exists? to Gitlab::Git --- app/models/repository.rb | 13 ++++++++++--- lib/gitlab/git/repository.rb | 23 +++++++++++++++++++++++ lib/gitlab/gitaly_client/ref_service.rb | 2 +- spec/features/calendar_spec.rb | 2 +- spec/features/dashboard/activity_spec.rb | 2 +- spec/lib/gitlab/git/repository_spec.rb | 28 ++++++++++++++++++++++++++++ spec/models/user_spec.rb | 2 +- 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index c1e4fcf94a4..cb2cf658084 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -206,12 +206,18 @@ class Repository end def branch_exists?(branch_name) - branch_names.include?(branch_name) + return false unless raw_repository + + @branch_exists_memo ||= Hash.new do |hash, key| + hash[key] = raw_repository.branch_exists?(key) + end + + @branch_exists_memo[branch_name] end def ref_exists?(ref) - rugged.references.exist?(ref) - rescue Rugged::ReferenceError + !!raw_repository&.ref_exists?(ref) + rescue ArgumentError false end @@ -266,6 +272,7 @@ class Repository def expire_branches_cache expire_method_caches(%i(branch_names branch_count)) @local_branches = nil + @branch_exists_memo = nil end def expire_statistics_caches diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index f5747951d5e..860ed01c05d 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -201,6 +201,19 @@ module Gitlab end end + # Returns true if the given ref name exists + # + # Ref names must start with `refs/`. + def ref_exists?(ref_name) + gitaly_migrate(:ref_exists) do |is_enabled| + if is_enabled + gitaly_ref_exists?(ref_name) + else + rugged_ref_exists?(ref_name) + end + end + end + # Returns true if the given tag exists # # name - The name of the tag as a String. @@ -989,6 +1002,16 @@ module Gitlab raw_output.compact end + # Returns true if the given ref name exists + # + # Ref names must start with `refs/`. + def rugged_ref_exists?(ref_name) + raise ArgumentError, 'invalid refname' unless ref_name.start_with?('refs/') + rugged.references.exist?(ref_name) + rescue Rugged::ReferenceError + false + end + # Returns true if the given ref name exists # # Ref names must start with `refs/`. diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb index cdcfed36740..8c0008c6971 100644 --- a/lib/gitlab/gitaly_client/ref_service.rb +++ b/lib/gitlab/gitaly_client/ref_service.rb @@ -71,7 +71,7 @@ module Gitlab end def ref_exists?(ref_name) - request = Gitaly::RefExistsRequest.new(repository: @gitaly_repo, ref: ref_name) + request = Gitaly::RefExistsRequest.new(repository: @gitaly_repo, ref: GitalyClient.encode(ref_name)) response = GitalyClient.call(@storage, :ref_service, :ref_exists, request) response.value rescue GRPC::InvalidArgument => e diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb index 9a597a2d690..4fc6956d111 100644 --- a/spec/features/calendar_spec.rb +++ b/spec/features/calendar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Contributions Calendar', :js do let(:user) { create(:user) } - let(:contributed_project) { create(:project, :public) } + let(:contributed_project) { create(:project, :public, :repository) } let(:issue_note) { create(:note, project: contributed_project) } # Ex/ Sunday Jan 1, 2016 diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb index 582868bac1e..bd115785646 100644 --- a/spec/features/dashboard/activity_spec.rb +++ b/spec/features/dashboard/activity_spec.rb @@ -17,7 +17,7 @@ feature 'Dashboard > Activity' do end context 'event filters', :js do - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } let(:merge_request) do create(:merge_request, author: user, source_project: project, target_project: project) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 2b70d16a264..62da733170c 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1110,6 +1110,34 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#ref_exists?' do + shared_examples 'checks the existence of refs' do + it 'returns true for an existing tag' do + expect(repository.ref_exists?('refs/heads/master')).to eq(true) + end + + it 'returns false for a non-existing tag' do + expect(repository.ref_exists?('refs/tags/THIS_TAG_DOES_NOT_EXIST')).to eq(false) + end + + it 'raises an ArgumentError for an empty string' do + expect { repository.ref_exists?('') }.to raise_error(ArgumentError) + end + + it 'raises an ArgumentError for an invalid ref' do + expect { repository.ref_exists?('INVALID') }.to raise_error(ArgumentError) + end + end + + context 'when Gitaly ref_exists feature is enabled' do + it_behaves_like 'checks the existence of refs' + end + + context 'when Gitaly ref_exists feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'checks the existence of refs' + end + end + describe '#tag_exists?' do shared_examples 'checks the existence of tags' do it 'returns true for an existing tag' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9a9e255f874..8e04eea56a7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1356,7 +1356,7 @@ describe User do end it "excludes push event if branch has been deleted" do - allow_any_instance_of(Repository).to receive(:branch_names).and_return(['foo']) + allow_any_instance_of(Repository).to receive(:branch_exists?).with('master').and_return(false) expect(subject.recent_push).to eq(nil) end -- cgit v1.2.1 From e8525e107da9234d743caf8a0c7db1f46af60e89 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 22 Aug 2017 16:27:09 +0100 Subject: Show un-highlighted diffs when blobs are the same For some old merge requests, we don't have enough information to figure out the old blob and the new blob for the file. This means that we can't highlight the diff correctly, but we can still display it without highlighting. --- changelogs/unreleased/fix-old-mr-diffs.yml | 6 ++++ lib/gitlab/diff/file.rb | 9 +++++- spec/lib/gitlab/diff/file_spec.rb | 44 +++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 changelogs/unreleased/fix-old-mr-diffs.yml diff --git a/changelogs/unreleased/fix-old-mr-diffs.yml b/changelogs/unreleased/fix-old-mr-diffs.yml new file mode 100644 index 00000000000..b0a011cf354 --- /dev/null +++ b/changelogs/unreleased/fix-old-mr-diffs.yml @@ -0,0 +1,6 @@ +--- +title: Show un-highlighted text diffs when we do not have references to the correct + blobs +merge_request: +author: +type: fixed diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index 17a9ec01637..1dabd4ebdd0 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -186,7 +186,10 @@ module Gitlab end def content_changed? - old_blob && new_blob && old_blob.id != new_blob.id + return blobs_changed? if diff_refs + return false if new_file? || deleted_file? || renamed_file? + + text? && diff_lines.any? end def different_type? @@ -225,6 +228,10 @@ module Gitlab private + def blobs_changed? + old_blob && new_blob && old_blob.id != new_blob.id + end + def simple_viewer_class return DiffViewer::NotDiffable unless diffable? diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index ab60d62d88e..c91895cedc3 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -15,6 +15,17 @@ describe Gitlab::Diff::File do it { expect(diff_lines.first).to be_kind_of(Gitlab::Diff::Line) } end + describe '#highlighted_diff_lines' do + it 'highlights the diff and memoises the result' do + expect(Gitlab::Diff::Highlight).to receive(:new) + .with(diff_file, repository: project.repository) + .once + .and_call_original + + diff_file.highlighted_diff_lines + end + end + describe '#mode_changed?' do it { expect(diff_file.mode_changed?).to be_falsey } end @@ -122,8 +133,20 @@ describe Gitlab::Diff::File do let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') } let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') } - it 'returns true' do - expect(diff_file.content_changed?).to be_truthy + context 'when the blobs are different' do + it 'returns true' do + expect(diff_file.content_changed?).to be_truthy + end + end + + context 'when there are no diff refs' do + before do + allow(diff_file).to receive(:diff_refs).and_return(nil) + end + + it 'returns false' do + expect(diff_file.content_changed?).to be_falsey + end end end @@ -131,8 +154,20 @@ describe Gitlab::Diff::File do let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') } let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') } - it 'returns true' do - expect(diff_file.content_changed?).to be_truthy + context 'when the blobs are different' do + it 'returns true' do + expect(diff_file.content_changed?).to be_truthy + end + end + + context 'when there are no diff refs' do + before do + allow(diff_file).to receive(:diff_refs).and_return(nil) + end + + it 'returns true' do + expect(diff_file.content_changed?).to be_truthy + end end end end @@ -278,6 +313,7 @@ describe Gitlab::Diff::File do allow(diff_file).to receive(:deleted_file?).and_return(false) allow(diff_file).to receive(:renamed_file?).and_return(false) allow(diff_file).to receive(:mode_changed?).and_return(false) + allow(diff_file).to receive(:raw_text?).and_return(false) end it 'returns a No Preview viewer' do -- cgit v1.2.1 From 061472864ceaa4dc837eebcaa583f7b81d4e7e54 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 22 Aug 2017 16:10:49 +0100 Subject: Fix group and project search for anonymous users --- app/assets/javascripts/api.js | 15 ++++++++----- app/views/search/_form.html.haml | 2 +- ...roup-and-project-search-for-anonymous-users.yml | 5 +++++ doc/api/groups.md | 9 +++++--- spec/features/search_spec.rb | 26 ++++++++++++++++++++++ spec/javascripts/api_spec.js | 26 ++++++++++++++++++++-- spec/javascripts/project_title_spec.js | 6 +++-- spec/requests/api/groups_spec.rb | 21 +++++++++++++++-- 8 files changed, 95 insertions(+), 15 deletions(-) create mode 100644 changelogs/unreleased/31409-fix-group-and-project-search-for-anonymous-users.yml diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 56f91e95bb9..3d0ba65fd36 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -55,13 +55,18 @@ const Api = { // Return projects list. Filtered by query projects(query, options, callback) { const url = Api.buildUrl(Api.projectsPath); + const defaults = { + search: query, + per_page: 20, + }; + + if (gon.current_user_id) { + defaults.membership = true; + } + return $.ajax({ url, - data: Object.assign({ - search: query, - per_page: 20, - membership: true, - }, options), + data: Object.assign(defaults, options), dataType: 'json', }) .done(projects => callback(projects)); diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml index 3139be1cd37..a4a5cec1314 100644 --- a/app/views/search/_form.html.haml +++ b/app/views/search/_form.html.haml @@ -11,5 +11,5 @@ %span.sr-only Clear search - unless params[:snippets].eql? 'true' - = render 'filter' if current_user + = render 'filter' = button_tag "Search", class: "btn btn-success btn-search" diff --git a/changelogs/unreleased/31409-fix-group-and-project-search-for-anonymous-users.yml b/changelogs/unreleased/31409-fix-group-and-project-search-for-anonymous-users.yml new file mode 100644 index 00000000000..06e8180db64 --- /dev/null +++ b/changelogs/unreleased/31409-fix-group-and-project-search-for-anonymous-users.yml @@ -0,0 +1,5 @@ +--- +title: Fix group and project search for anonymous users +merge_request: 13745 +author: +type: fixed diff --git a/doc/api/groups.md b/doc/api/groups.md index 2b3d8e125c8..c2daa8bc029 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -2,7 +2,8 @@ ## List groups -Get a list of groups. (As user: my groups or all available, as admin: all groups). +Get a list of visible groups for the authenticated user. When accessed without +authentication, only public groups are returned. Parameters: @@ -43,7 +44,8 @@ You can search for groups by name or path, see below. ## List a group's projects -Get a list of projects in this group. +Get a list of projects in this group. When accessed without authentication, only +public projects are returned. ``` GET /groups/:id/projects @@ -109,7 +111,8 @@ Example response: ## Details of a group -Get all details of a group. +Get all details of a group. This endpoint can be accessed without authentication +if the group is publicly accessible. ``` GET /groups/:id diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 6742d77937f..31d509455ba 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -281,4 +281,30 @@ describe "Search" do expect(page).to have_selector('.commit-row-description', count: 9) end end + + context 'anonymous user' do + let(:project) { create(:project, :public) } + + before do + sign_out(user) + end + + it 'preserves the group being searched in' do + visit search_path(group_id: project.namespace.id) + + fill_in 'search', with: 'foo' + click_button 'Search' + + expect(find('#group_id').value).to eq(project.namespace.id.to_s) + end + + it 'preserves the project being searched in' do + visit search_path(project_id: project.id) + + fill_in 'search', with: 'foo' + click_button 'Search' + + expect(find('#project_id').value).to eq(project.id.to_s) + end + end end diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index 867322ce8ae..8c68ceff914 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -17,7 +17,7 @@ describe('Api', () => { beforeEach(() => { originalGon = window.gon; - window.gon = dummyGon; + window.gon = Object.assign({}, dummyGon); }); afterEach(() => { @@ -98,10 +98,11 @@ describe('Api', () => { }); describe('projects', () => { - it('fetches projects', (done) => { + it('fetches projects with membership when logged in', (done) => { const query = 'dummy query'; const options = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects.json?simple=true`; + window.gon.current_user_id = 1; const expectedData = Object.assign({ search: query, per_page: 20, @@ -119,6 +120,27 @@ describe('Api', () => { done(); }); }); + + it('fetches projects without membership when not logged in', (done) => { + const query = 'dummy query'; + const options = { unused: 'option' }; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects.json?simple=true`; + const expectedData = Object.assign({ + search: query, + per_page: 20, + }, options); + spyOn(jQuery, 'ajax').and.callFake((request) => { + expect(request.url).toEqual(expectedUrl); + expect(request.dataType).toEqual('json'); + expect(request.data).toEqual(expectedData); + return sendDummyResponse(); + }); + + Api.projects(query, options, (response) => { + expect(response).toBe(dummyResponse); + done(); + }); + }); }); describe('newLabel', () => { diff --git a/spec/javascripts/project_title_spec.js b/spec/javascripts/project_title_spec.js index cc336180ff7..3d36bb3e4d4 100644 --- a/spec/javascripts/project_title_spec.js +++ b/spec/javascripts/project_title_spec.js @@ -7,6 +7,7 @@ import '~/project_select'; import '~/project'; describe('Project Title', () => { + const dummyApiVersion = 'v3000'; preloadFixtures('issues/open-issue.html.raw'); loadJSONFixtures('projects.json'); @@ -14,7 +15,7 @@ describe('Project Title', () => { loadFixtures('issues/open-issue.html.raw'); window.gon = {}; - window.gon.api_version = 'v3'; + window.gon.api_version = dummyApiVersion; // eslint-disable-next-line no-new new Project(); @@ -37,9 +38,10 @@ describe('Project Title', () => { it('toggles dropdown', () => { const $menu = $('.js-dropdown-menu-projects'); + window.gon.current_user_id = 1; $('.js-projects-dropdown-toggle').click(); expect($menu).toHaveClass('open'); - expect(reqUrl).toBe('/api/v3/projects.json?simple=true'); + expect(reqUrl).toBe(`/api/${dummyApiVersion}/projects.json?simple=true`); expect(reqData).toEqual({ search: '', order_by: 'last_activity_at', diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 313c38cd29c..a7557c7fb22 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -20,10 +20,15 @@ describe API::Groups do describe "GET /groups" do context "when unauthenticated" do - it "returns authentication error" do + it "returns public groups" do get api("/groups") - expect(response).to have_http_status(401) + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response) + .to satisfy_one { |group| group['name'] == group1.name } end end @@ -165,6 +170,18 @@ describe API::Groups do end describe "GET /groups/:id" do + context 'when unauthenticated' do + it 'returns 404 for a private group' do + get api("/groups/#{group2.id}") + expect(response).to have_http_status(404) + end + + it 'returns 200 for a public group' do + get api("/groups/#{group1.id}") + expect(response).to have_http_status(200) + end + end + context "when authenticated as user" do it "returns one of user1's groups" do project = create(:project, namespace: group2, path: 'Foo') -- cgit v1.2.1 From 2adff699cea2cf1e60180d7eae73dfe5e8a09235 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 24 Aug 2017 11:33:06 +0100 Subject: Refactor complicated API group finding rules into GroupsFinder --- app/finders/groups_finder.rb | 36 ++++++++++++++++++++++++++++++------ lib/api/groups.rb | 12 ++---------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb index e6fb112e7f2..88d71b0a87b 100644 --- a/app/finders/groups_finder.rb +++ b/app/finders/groups_finder.rb @@ -1,3 +1,19 @@ +# GroupsFinder +# +# Used to filter Groups by a set of params +# +# Arguments: +# current_user - which user is requesting groups +# params: +# owned: boolean +# parent: Group +# all_available: boolean (defaults to true) +# +# Users with full private access can see all groups. The `owned` and `parent` +# params can be used to restrict the groups that are returned. +# +# Anonymous users will never return any `owned` groups. They will return all +# public groups instead, even if `all_available` is set to false. class GroupsFinder < UnionFinder def initialize(current_user = nil, params = {}) @current_user = current_user @@ -16,13 +32,13 @@ class GroupsFinder < UnionFinder attr_reader :current_user, :params def all_groups - groups = [] - - if current_user - groups << Gitlab::GroupHierarchy.new(groups_for_ancestors, groups_for_descendants).all_groups - end - groups << Group.unscoped.public_to_user(current_user) + return [owned_groups] if params[:owned] + return [Group.all] if current_user&.full_private_access? + groups = [] + groups << Gitlab::GroupHierarchy.new(groups_for_ancestors, groups_for_descendants).all_groups if current_user + groups << Group.unscoped.public_to_user(current_user) if include_public_groups? + groups << Group.none if groups.empty? groups end @@ -39,4 +55,12 @@ class GroupsFinder < UnionFinder groups.where(parent: params[:parent]) end + + def owned_groups + current_user&.groups || Group.none + end + + def include_public_groups? + current_user.nil? || params.fetch(:all_available, true) + end end diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 892fd239df4..e56427304a6 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -47,16 +47,8 @@ module API use :pagination end get do - groups = if params[:owned] - current_user ? current_user.owned_groups : Group.none - elsif current_user&.admin? - Group.all - elsif params[:all_available] || current_user.nil? - GroupsFinder.new(current_user).execute - else - current_user.groups - end - + find_params = { all_available: params[:all_available], owned: params[:owned] } + groups = GroupsFinder.new(current_user, find_params).execute groups = groups.search(params[:search]) if params[:search].present? groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present? groups = groups.reorder(params[:order_by] => params[:sort]) -- cgit v1.2.1 From 80f657c05e8cd2f87abb4525695af19181607f04 Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Thu, 24 Aug 2017 17:43:11 +0700 Subject: Disable GitLab Project Import Button if source disabled --- app/views/projects/new.html.haml | 7 ++++--- ...882-disable-gitlab-project-import-button-if-source-disabled.yml | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/36882-disable-gitlab-project-import-button-if-source-disabled.yml diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 647e0a772b1..5698bb281b4 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -68,9 +68,10 @@ - if git_import_enabled? %button.btn.js-toggle-button.import_git{ type: "button" } = icon('git', text: 'Repo by URL') - .import_gitlab_project.has-tooltip{ data: { container: 'body' } } - = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do - = icon('gitlab', text: 'GitLab export') + - if gitlab_project_import_enabled? + .import_gitlab_project.has-tooltip{ data: { container: 'body' } } + = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit' do + = icon('gitlab', text: 'GitLab export') .row .col-lg-12 diff --git a/changelogs/unreleased/36882-disable-gitlab-project-import-button-if-source-disabled.yml b/changelogs/unreleased/36882-disable-gitlab-project-import-button-if-source-disabled.yml new file mode 100644 index 00000000000..a06c84c30e6 --- /dev/null +++ b/changelogs/unreleased/36882-disable-gitlab-project-import-button-if-source-disabled.yml @@ -0,0 +1,5 @@ +--- +title: Disable GitLab Project Import Button if source disabled +merge_request: +author: +type: fixed -- cgit v1.2.1 From a1a914994f6376b03d95e9d4b05dea422e8610f9 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 24 Aug 2017 14:05:24 +0200 Subject: Avoid committer = lines --- app/models/repository.rb | 27 +++++++++------------------ app/services/git_operation_service.rb | 5 ++--- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index 062f532233f..59f913c7fb4 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -164,8 +164,7 @@ class Repository return false unless newrev - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).add_branch(branch_name, newrev) + GitOperationService.new(user, self).add_branch(branch_name, newrev) after_create_branch find_branch(branch_name) @@ -177,8 +176,7 @@ class Repository return false unless newrev - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).add_tag(tag_name, newrev, options) + GitOperationService.new(user, self).add_tag(tag_name, newrev, options) find_tag(tag_name) end @@ -187,8 +185,7 @@ class Repository before_remove_branch branch = find_branch(branch_name) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).rm_branch(branch) + GitOperationService.new(user, self).rm_branch(branch) after_remove_branch true @@ -198,8 +195,7 @@ class Repository before_remove_tag tag = find_tag(tag_name) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).rm_tag(tag) + GitOperationService.new(user, self).rm_tag(tag) after_remove_tag true @@ -767,8 +763,7 @@ class Repository author_email: nil, author_name: nil, start_branch_name: nil, start_project: project) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).with_branch( + GitOperationService.new(user, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -824,8 +819,7 @@ class Repository end def merge(user, source, merge_request, options = {}) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).with_branch( + GitOperationService.new(user, self).with_branch( merge_request.target_branch) do |start_commit| our_commit = start_commit.sha their_commit = source @@ -852,8 +846,7 @@ class Repository def revert( user, commit, branch_name, start_branch_name: nil, start_project: project) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).with_branch( + GitOperationService.new(user, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -876,8 +869,7 @@ class Repository def cherry_pick( user, commit, branch_name, start_branch_name: nil, start_project: project) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).with_branch( + GitOperationService.new(user, self).with_branch( branch_name, start_branch_name: start_branch_name, start_project: start_project) do |start_commit| @@ -902,8 +894,7 @@ class Repository end def resolve_conflicts(user, branch_name, params) - committer = Gitlab::Git::Committer.from_user(user) - GitOperationService.new(committer, self).with_branch(branch_name) do + GitOperationService.new(user, self).with_branch(branch_name) do committer = user_to_committer(user) create_commit(params.merge(author: committer, committer: committer)) diff --git a/app/services/git_operation_service.rb b/app/services/git_operation_service.rb index 6a983566526..6b7a56e6922 100644 --- a/app/services/git_operation_service.rb +++ b/app/services/git_operation_service.rb @@ -2,10 +2,9 @@ class GitOperationService attr_reader :committer, :repository def initialize(committer, new_repository) - if committer && !committer.is_a?(Gitlab::Git::Committer) - raise "expected Gitlab::Git::Committer, got #{committer.inspect}" - end + committer = Gitlab::Git::Committer.from_user(committer) if committer.is_a?(User) @committer = committer + @repository = new_repository end -- cgit v1.2.1 From 1971ae18f670775d48dd78e844b784d432ddaaca Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 24 Aug 2017 14:59:06 +0200 Subject: Use gitaly-proto 0.31.0 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 72fc2de426e..32539842dbb 100644 --- a/Gemfile +++ b/Gemfile @@ -401,7 +401,7 @@ group :ed25519 do end # Gitaly GRPC client -gem 'gitaly', '~> 0.30.0' +gem 'gitaly-proto', '~> 0.31.0', require: 'gitaly' gem 'toml-rb', '~> 0.3.15', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 7d3c53ee010..780939df03a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -275,7 +275,7 @@ GEM po_to_json (>= 1.0.0) rails (>= 3.2.0) gherkin-ruby (0.3.2) - gitaly (0.30.0) + gitaly-proto (0.31.0) google-protobuf (~> 3.1) grpc (~> 1.0) github-linguist (4.7.6) @@ -1019,7 +1019,7 @@ DEPENDENCIES gettext (~> 3.2.2) gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails_js (~> 1.2.0) - gitaly (~> 0.30.0) + gitaly-proto (~> 0.31.0) github-linguist (~> 4.7.0) gitlab-flowdock-git-hook (~> 1.0.1) gitlab-markup (~> 1.5.1) -- cgit v1.2.1 From 82c002ebce10395332485f56abc895defe656197 Mon Sep 17 00:00:00 2001 From: Dimitrie Hoekstra Date: Thu, 24 Aug 2017 14:13:24 +0000 Subject: Changed all font-weight values to 400 and 600 --- app/assets/stylesheets/framework/avatar.scss | 2 +- app/assets/stylesheets/framework/badges.scss | 2 +- app/assets/stylesheets/framework/blocks.scss | 4 +-- app/assets/stylesheets/framework/buttons.scss | 2 +- app/assets/stylesheets/framework/calendar.scss | 6 ++-- app/assets/stylesheets/framework/common.scss | 16 +++++----- app/assets/stylesheets/framework/dropdowns.scss | 12 ++++---- app/assets/stylesheets/framework/filters.scss | 4 +-- app/assets/stylesheets/framework/flash.scss | 2 +- app/assets/stylesheets/framework/forms.scss | 6 ++-- app/assets/stylesheets/framework/header.scss | 6 ++-- app/assets/stylesheets/framework/lists.scss | 4 +-- app/assets/stylesheets/framework/mixins.scss | 2 +- app/assets/stylesheets/framework/modal.scss | 2 +- app/assets/stylesheets/framework/nav.scss | 4 +-- app/assets/stylesheets/framework/page-header.scss | 2 +- app/assets/stylesheets/framework/selects.scss | 10 +++---- app/assets/stylesheets/framework/snippets.scss | 2 +- app/assets/stylesheets/framework/tables.scss | 2 +- app/assets/stylesheets/framework/tw_bootstrap.scss | 4 +-- app/assets/stylesheets/framework/typography.scss | 12 ++++---- app/assets/stylesheets/framework/variables.scss | 2 ++ app/assets/stylesheets/framework/wells.scss | 2 +- app/assets/stylesheets/highlight/dark.scss | 8 ++--- app/assets/stylesheets/highlight/monokai.scss | 2 +- .../stylesheets/highlight/solarized_dark.scss | 2 +- .../stylesheets/highlight/solarized_light.scss | 2 +- app/assets/stylesheets/highlight/white.scss | 32 ++++++++++---------- .../mailers/highlighted_diff_email.scss | 32 ++++++++++---------- app/assets/stylesheets/new_nav.scss | 10 +++---- app/assets/stylesheets/new_sidebar.scss | 8 ++--- app/assets/stylesheets/pages/boards.scss | 2 +- app/assets/stylesheets/pages/builds.scss | 4 +-- app/assets/stylesheets/pages/ci_projects.scss | 2 +- app/assets/stylesheets/pages/commits.scss | 4 +-- app/assets/stylesheets/pages/convdev_index.scss | 6 ++-- app/assets/stylesheets/pages/cycle_analytics.scss | 10 +++---- app/assets/stylesheets/pages/diff.scss | 6 ++-- app/assets/stylesheets/pages/environments.scss | 6 ++-- app/assets/stylesheets/pages/events.scss | 2 +- app/assets/stylesheets/pages/issuable.scss | 6 ++-- app/assets/stylesheets/pages/issues.scss | 4 +-- app/assets/stylesheets/pages/login.scss | 8 ++--- app/assets/stylesheets/pages/members.scss | 4 +-- app/assets/stylesheets/pages/merge_requests.scss | 16 +++++----- app/assets/stylesheets/pages/milestone.scss | 4 +-- app/assets/stylesheets/pages/note_form.scss | 2 +- .../stylesheets/pages/pipeline_schedules.scss | 2 +- app/assets/stylesheets/pages/pipelines.scss | 12 ++++---- app/assets/stylesheets/pages/profile.scss | 4 +-- app/assets/stylesheets/pages/projects.scss | 16 +++++----- app/assets/stylesheets/pages/repo.scss | 2 +- app/assets/stylesheets/pages/runners.scss | 2 +- app/assets/stylesheets/pages/search.scss | 2 +- app/assets/stylesheets/pages/sherlock.scss | 2 +- app/assets/stylesheets/pages/todos.scss | 6 ++-- app/assets/stylesheets/pages/tree.scss | 2 +- app/assets/stylesheets/pages/ui_dev_kit.scss | 2 +- app/assets/stylesheets/pages/wiki.scss | 4 +-- app/assets/stylesheets/pages/xterm.scss | 2 +- app/assets/stylesheets/print.scss | 2 +- app/views/layouts/errors.html.haml | 4 +-- app/views/layouts/oauth_error.html.haml | 2 +- changelogs/unreleased/font-weight-adjusted.yml | 5 ++++ public/404.html | 6 ++-- public/422.html | 6 ++-- public/500.html | 6 ++-- public/502.html | 6 ++-- public/503.html | 6 ++-- public/deploy.html | 6 ++-- spec/fixtures/emails/ios_default.eml | 12 ++++---- spec/fixtures/emails/on_wrote.eml | 6 ++-- vendor/assets/stylesheets/katex.scss | 34 +++++++++++----------- vendor/assets/stylesheets/xterm/xterm.css | 2 +- 74 files changed, 230 insertions(+), 223 deletions(-) create mode 100644 changelogs/unreleased/font-weight-adjusted.yml diff --git a/app/assets/stylesheets/framework/avatar.scss b/app/assets/stylesheets/framework/avatar.scss index 486d88efbc5..bdcbd4021b3 100644 --- a/app/assets/stylesheets/framework/avatar.scss +++ b/app/assets/stylesheets/framework/avatar.scss @@ -78,7 +78,7 @@ &.s60 { font-size: 32px; line-height: 58px; } &.s70 { font-size: 34px; line-height: 70px; } &.s90 { font-size: 36px; line-height: 88px; } - &.s110 { font-size: 40px; line-height: 108px; font-weight: 300; } + &.s110 { font-size: 40px; line-height: 108px; font-weight: $gl-font-weight-normal; } &.s140 { font-size: 72px; line-height: 138px; } &.s160 { font-size: 96px; line-height: 158px; } } diff --git a/app/assets/stylesheets/framework/badges.scss b/app/assets/stylesheets/framework/badges.scss index 47a8f44c709..6bbe32df772 100644 --- a/app/assets/stylesheets/framework/badges.scss +++ b/app/assets/stylesheets/framework/badges.scss @@ -1,5 +1,5 @@ .badge { - font-weight: normal; + font-weight: $gl-font-weight-normal; background-color: $badge-bg; color: $badge-color; vertical-align: baseline; diff --git a/app/assets/stylesheets/framework/blocks.scss b/app/assets/stylesheets/framework/blocks.scss index 95a08c960ea..b575ec9de18 100644 --- a/app/assets/stylesheets/framework/blocks.scss +++ b/app/assets/stylesheets/framework/blocks.scss @@ -8,7 +8,7 @@ text-align: center; padding: 20px; color: $gl-text-color; - font-weight: normal; + font-weight: $gl-font-weight-normal; font-size: 14px; line-height: 36px; @@ -213,7 +213,7 @@ h1 { display: inline; - font-weight: normal; + font-weight: $gl-font-weight-normal; font-size: 24px; color: $gl-text-color; } diff --git a/app/assets/stylesheets/framework/buttons.scss b/app/assets/stylesheets/framework/buttons.scss index 6eabdc63d9e..b4a6b214e98 100644 --- a/app/assets/stylesheets/framework/buttons.scss +++ b/app/assets/stylesheets/framework/buttons.scss @@ -1,7 +1,7 @@ @mixin btn-default { border-radius: 3px; font-size: $gl-font-size; - font-weight: 400; + font-weight: $gl-font-weight-normal; padding: $gl-vert-padding $gl-btn-padding; &:focus, diff --git a/app/assets/stylesheets/framework/calendar.scss b/app/assets/stylesheets/framework/calendar.scss index 0ded4a3b423..4ce767e4cc4 100644 --- a/app/assets/stylesheets/framework/calendar.scss +++ b/app/assets/stylesheets/framework/calendar.scss @@ -52,13 +52,13 @@ .pika-label { color: $gl-text-color-secondary; font-size: 14px; - font-weight: normal; + font-weight: $gl-font-weight-normal; } th { padding: 2px 0; color: $note-disabled-comment-color; - font-weight: normal; + font-weight: $gl-font-weight-normal; text-transform: lowercase; border-top: 1px solid $calendar-border-color; } @@ -88,7 +88,7 @@ .is-today { .pika-day { color: inherit; - font-weight: normal; + font-weight: $gl-font-weight-normal; } } diff --git a/app/assets/stylesheets/framework/common.scss b/app/assets/stylesheets/framework/common.scss index 293aa194528..e16fbbf43b5 100644 --- a/app/assets/stylesheets/framework/common.scss +++ b/app/assets/stylesheets/framework/common.scss @@ -36,12 +36,12 @@ color: $common-gray; font-size: 14px; margin-bottom: 12px; - font-weight: normal; + font-weight: $gl-font-weight-normal; line-height: 24px; } .bold { - font-weight: 600; + font-weight: $gl-font-weight-bold; } .tab-content { @@ -89,7 +89,7 @@ hr { } } -.item-title { font-weight: 600; } +.item-title { font-weight: $gl-font-weight-bold; } /** FLASH message **/ .author_link, @@ -118,18 +118,18 @@ table a code { span.update-author { display: block; color: $update-author-color; - font-weight: normal; + font-weight: $gl-font-weight-normal; font-style: italic; strong { - font-weight: bold; + font-weight: $gl-font-weight-bold; font-style: normal; } } .user-mention { color: $user-mention-color; - font-weight: bold; + font-weight: $gl-font-weight-bold; } .field_with_errors { @@ -222,7 +222,7 @@ li.note { text-align: center; background: $error-bg; color: $white-light; - font-weight: bold; + font-weight: $gl-font-weight-bold; a { color: $white-light; @@ -339,7 +339,7 @@ table { .header-with-avatar { h3 { margin: 0; - font-weight: bold; + font-weight: $gl-font-weight-bold; } .username { diff --git a/app/assets/stylesheets/framework/dropdowns.scss b/app/assets/stylesheets/framework/dropdowns.scss index 5f270e288ae..a45d5a6dca0 100644 --- a/app/assets/stylesheets/framework/dropdowns.scss +++ b/app/assets/stylesheets/framework/dropdowns.scss @@ -195,7 +195,7 @@ margin-top: 2px; margin-bottom: 0; font-size: 14px; - font-weight: normal; + font-weight: $gl-font-weight-normal; padding: 8px 0; background-color: $white-light; border: 1px solid $dropdown-border-color; @@ -268,7 +268,7 @@ } .dropdown-bold-header { - font-weight: 600; + font-weight: $gl-font-weight-bold; line-height: 22px; padding: 0 16px; } @@ -432,7 +432,7 @@ .dropdown-menu-user-full-name { display: block; - font-weight: 500; + font-weight: $gl-font-weight-normal; line-height: 16px; text-overflow: ellipsis; overflow: hidden; @@ -468,7 +468,7 @@ &.is-indeterminate, &.is-active { - font-weight: 600; + font-weight: $gl-font-weight-bold; color: $gl-text-color; &::before { @@ -502,7 +502,7 @@ position: relative; padding: 2px 25px 10px; margin: 0 10px 10px; - font-weight: 600; + font-weight: $gl-font-weight-bold; line-height: 1; text-align: center; text-overflow: ellipsis; @@ -685,7 +685,7 @@ .dropdown-menu-inner-title { display: block; color: $gl-text-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; } .dropdown-menu-inner-content { diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss index 8dcaa879b3f..a5d33d410fb 100644 --- a/app/assets/stylesheets/framework/filters.scss +++ b/app/assets/stylesheets/framework/filters.scss @@ -371,7 +371,7 @@ } > .value { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -452,7 +452,7 @@ .dropdown-light-content { font-size: 14px; - font-weight: 400; + font-weight: $gl-font-weight-normal; } .dropdown-user { diff --git a/app/assets/stylesheets/framework/flash.scss b/app/assets/stylesheets/framework/flash.scss index 38d884bc7eb..e1b086ebb2b 100644 --- a/app/assets/stylesheets/framework/flash.scss +++ b/app/assets/stylesheets/framework/flash.scss @@ -25,7 +25,7 @@ a.flash-action { margin-left: 5px; text-decoration: none; - font-weight: normal; + font-weight: $gl-font-weight-normal; border-bottom: 1px solid; &:hover { diff --git a/app/assets/stylesheets/framework/forms.scss b/app/assets/stylesheets/framework/forms.scss index 61e3897f369..be96c8ee964 100644 --- a/app/assets/stylesheets/framework/forms.scss +++ b/app/assets/stylesheets/framework/forms.scss @@ -32,7 +32,7 @@ label { } &.label-light { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -73,7 +73,7 @@ label { margin-right: 0; .control-label { - font-weight: bold; + font-weight: $gl-font-weight-bold; padding-top: 4px; } @@ -157,7 +157,7 @@ label { .form-group .control-label, .form-group .control-label-full-width { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .form-control::-webkit-input-placeholder { diff --git a/app/assets/stylesheets/framework/header.scss b/app/assets/stylesheets/framework/header.scss index b677882eba4..35bd97980e2 100644 --- a/app/assets/stylesheets/framework/header.scss +++ b/app/assets/stylesheets/framework/header.scss @@ -160,7 +160,7 @@ header { li { &.active a { - font-weight: bold; + font-weight: $gl-font-weight-bold; } } } @@ -250,7 +250,7 @@ header { font-size: 18px; line-height: 22px; display: inline-block; - font-weight: normal; + font-weight: $gl-font-weight-normal; color: $gl-text-color; vertical-align: top; white-space: nowrap; @@ -326,7 +326,7 @@ header { .badge { position: inherit; top: -8px; - font-weight: normal; + font-weight: $gl-font-weight-normal; margin-left: -11px; font-size: 11px; color: $white-light; diff --git a/app/assets/stylesheets/framework/lists.scss b/app/assets/stylesheets/framework/lists.scss index df2bf561194..0fb19344510 100644 --- a/app/assets/stylesheets/framework/lists.scss +++ b/app/assets/stylesheets/framework/lists.scss @@ -113,7 +113,7 @@ ul.content-list { } .title { - font-weight: 600; + font-weight: $gl-font-weight-bold; } a { @@ -212,7 +212,7 @@ ul.content-list { } .row-title { - font-weight: 600; + font-weight: $gl-font-weight-bold; } .row-second-line { diff --git a/app/assets/stylesheets/framework/mixins.scss b/app/assets/stylesheets/framework/mixins.scss index 6f91d11b369..d40b65bb2cc 100644 --- a/app/assets/stylesheets/framework/mixins.scss +++ b/app/assets/stylesheets/framework/mixins.scss @@ -43,7 +43,7 @@ background: $gray-light; a { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } diff --git a/app/assets/stylesheets/framework/modal.scss b/app/assets/stylesheets/framework/modal.scss index a28f54936be..d1f00d3ee2c 100644 --- a/app/assets/stylesheets/framework/modal.scss +++ b/app/assets/stylesheets/framework/modal.scss @@ -8,7 +8,7 @@ } .text-danger { - font-weight: bold; + font-weight: $gl-font-weight-bold; } } diff --git a/app/assets/stylesheets/framework/nav.scss b/app/assets/stylesheets/framework/nav.scss index 071f20fc457..e20108b171b 100644 --- a/app/assets/stylesheets/framework/nav.scss +++ b/app/assets/stylesheets/framework/nav.scss @@ -70,7 +70,7 @@ &.active a { border-bottom: 2px solid $link-underline-blue; color: $black; - font-weight: 600; + font-weight: $gl-font-weight-bold; .badge { color: $black; @@ -352,7 +352,7 @@ z-index: 300; li.active { - font-weight: bold; + font-weight: $gl-font-weight-bold; } } } diff --git a/app/assets/stylesheets/framework/page-header.scss b/app/assets/stylesheets/framework/page-header.scss index f1ecd050a0a..0c879f40930 100644 --- a/app/assets/stylesheets/framework/page-header.scss +++ b/app/assets/stylesheets/framework/page-header.scss @@ -43,7 +43,7 @@ .commit-committer-link, .commit-author-link { color: $gl-text-color; - font-weight: bold; + font-weight: $gl-font-weight-bold; } .commit-info { diff --git a/app/assets/stylesheets/framework/selects.scss b/app/assets/stylesheets/framework/selects.scss index f7a0b355bf1..d93722e2174 100644 --- a/app/assets/stylesheets/framework/selects.scss +++ b/app/assets/stylesheets/framework/selects.scss @@ -76,7 +76,7 @@ } .select2-results li.select2-result-with-children > .select2-result-label { - font-weight: 600; + font-weight: $gl-font-weight-bold; color: $gl-text-color; } @@ -227,7 +227,7 @@ } .group-name { - font-weight: bold; + font-weight: $gl-font-weight-bold; } .group-path { @@ -252,12 +252,12 @@ .namespace-result { .namespace-kind { color: $namespace-kind-color; - font-weight: normal; + font-weight: $gl-font-weight-normal; } .namespace-path { margin-left: 10px; - font-weight: bolder; + font-weight: $gl-font-weight-bold; } } @@ -283,7 +283,7 @@ padding: 0 1px; .select2-match { - font-weight: bold; + font-weight: $gl-font-weight-bold; text-decoration: none; } diff --git a/app/assets/stylesheets/framework/snippets.scss b/app/assets/stylesheets/framework/snippets.scss index 5f7e1b17cc7..30c15c231d5 100644 --- a/app/assets/stylesheets/framework/snippets.scss +++ b/app/assets/stylesheets/framework/snippets.scss @@ -30,7 +30,7 @@ .snippet-title { font-size: 24px; - font-weight: 600; + font-weight: $gl-font-weight-bold; } .snippet-edited-ago { diff --git a/app/assets/stylesheets/framework/tables.scss b/app/assets/stylesheets/framework/tables.scss index 6d9fa74a030..4dd31bf28cd 100644 --- a/app/assets/stylesheets/framework/tables.scss +++ b/app/assets/stylesheets/framework/tables.scss @@ -32,7 +32,7 @@ table { th { background-color: $gray-light; - font-weight: normal; + font-weight: $gl-font-weight-normal; border-bottom: none; &.wide { diff --git a/app/assets/stylesheets/framework/tw_bootstrap.scss b/app/assets/stylesheets/framework/tw_bootstrap.scss index e54cc2866a7..d5c6ddbb4a5 100644 --- a/app/assets/stylesheets/framework/tw_bootstrap.scss +++ b/app/assets/stylesheets/framework/tw_bootstrap.scss @@ -103,7 +103,7 @@ summary { padding: 4px 5px; font-size: 12px; font-style: normal; - font-weight: normal; + font-weight: $gl-font-weight-normal; display: inline-block; &.label-gray { @@ -165,7 +165,7 @@ summary { .panel-heading { padding: 6px 15px; font-size: 13px; - font-weight: normal; + font-weight: $gl-font-weight-normal; a { color: $panel-heading-link-color; diff --git a/app/assets/stylesheets/framework/typography.scss b/app/assets/stylesheets/framework/typography.scss index d13f9996518..71eec0e1a5e 100644 --- a/app/assets/stylesheets/framework/typography.scss +++ b/app/assets/stylesheets/framework/typography.scss @@ -74,7 +74,7 @@ h1 { font-size: 1.75em; - font-weight: 600; + font-weight: $gl-font-weight-bold; margin: 24px 0 16px; padding-bottom: 0.3em; border-bottom: 1px solid $white-dark; @@ -87,7 +87,7 @@ h2 { font-size: 1.5em; - font-weight: 600; + font-weight: $gl-font-weight-bold; margin: 24px 0 16px; padding-bottom: 0.3em; border-bottom: 1px solid $white-dark; @@ -280,7 +280,7 @@ body { margin-top: $gl-padding; line-height: 1.3; font-size: 1.25em; - font-weight: 600; + font-weight: $gl-font-weight-bold; &:last-child { margin-bottom: 0; @@ -291,7 +291,7 @@ body { margin-top: 0; line-height: 1.3; font-size: 1.25em; - font-weight: 600; + font-weight: $gl-font-weight-bold; margin: 12px 7px; } @@ -302,11 +302,11 @@ h4, h5, h6 { color: $gl-text-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; } .light-header { - font-weight: 600; + font-weight: $gl-font-weight-bold; } /** CODE **/ diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 225d116e9c7..8a2e64f7bf5 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -111,6 +111,8 @@ $well-light-text-color: #5b6169; * Text */ $gl-font-size: 14px; +$gl-font-weight-normal: 400; +$gl-font-weight-bold: 600; $gl-text-color: #2e2e2e; $gl-text-color-secondary: #707070; $gl-text-color-tertiary: #949494; diff --git a/app/assets/stylesheets/framework/wells.scss b/app/assets/stylesheets/framework/wells.scss index b1ff2659131..5f9756bf58a 100644 --- a/app/assets/stylesheets/framework/wells.scss +++ b/app/assets/stylesheets/framework/wells.scss @@ -69,7 +69,7 @@ .well-centered { h1 { - font-weight: normal; + font-weight: $gl-font-weight-normal; text-align: center; font-size: 48px; } diff --git a/app/assets/stylesheets/highlight/dark.scss b/app/assets/stylesheets/highlight/dark.scss index 6e3829d994f..f0ac9b46f91 100644 --- a/app/assets/stylesheets/highlight/dark.scss +++ b/app/assets/stylesheets/highlight/dark.scss @@ -204,11 +204,11 @@ $dark-il: #de935f; .cs { color: $dark-cs; } /* Comment.Special */ .gd { color: $dark-gd; } /* Generic.Deleted */ .ge { font-style: italic; } /* Generic.Emph */ - .gh { color: $dark-gh; font-weight: bold; } /* Generic.Heading */ + .gh { color: $dark-gh; font-weight: $gl-font-weight-bold; } /* Generic.Heading */ .gi { color: $dark-gi; } /* Generic.Inserted */ - .gp { color: $dark-gp; font-weight: bold; } /* Generic.Prompt */ - .gs { font-weight: bold; } /* Generic.Strong */ - .gu { color: $dark-gu; font-weight: bold; } /* Generic.Subheading */ + .gp { color: $dark-gp; font-weight: $gl-font-weight-bold; } /* Generic.Prompt */ + .gs { font-weight: $gl-font-weight-bold; } /* Generic.Strong */ + .gu { color: $dark-gu; font-weight: $gl-font-weight-bold; } /* Generic.Subheading */ .kc { color: $dark-kc; } /* Keyword.Constant */ .kd { color: $dark-kd; } /* Keyword.Declaration */ .kn { color: $dark-kn; } /* Keyword.Namespace */ diff --git a/app/assets/stylesheets/highlight/monokai.scss b/app/assets/stylesheets/highlight/monokai.scss index 68eb0c7720f..eba7919ada9 100644 --- a/app/assets/stylesheets/highlight/monokai.scss +++ b/app/assets/stylesheets/highlight/monokai.scss @@ -203,7 +203,7 @@ $monokai-gi: #a6e22e; .c1 { color: $monokai-c1; } /* Comment.Single */ .cs { color: $monokai-cs; } /* Comment.Special */ .ge { font-style: italic; } /* Generic.Emph */ - .gs { font-weight: bold; } /* Generic.Strong */ + .gs { font-weight: $gl-font-weight-bold; } /* Generic.Strong */ .kc { color: $monokai-kc; } /* Keyword.Constant */ .kd { color: $monokai-kd; } /* Keyword.Declaration */ .kn { color: $monokai-kn; } /* Keyword.Namespace */ diff --git a/app/assets/stylesheets/highlight/solarized_dark.scss b/app/assets/stylesheets/highlight/solarized_dark.scss index 2cc968c32f2..ba53ef0352b 100644 --- a/app/assets/stylesheets/highlight/solarized_dark.scss +++ b/app/assets/stylesheets/highlight/solarized_dark.scss @@ -231,7 +231,7 @@ $solarized-dark-il: #2aa198; .gi { color: $solarized-dark-gi; } /* Generic.Inserted */ .go { color: $solarized-dark-go; } /* Generic.Output */ .gp { color: $solarized-dark-gp; } /* Generic.Prompt */ - .gs { color: $solarized-dark-gs; font-weight: bold; } /* Generic.Strong */ + .gs { color: $solarized-dark-gs; font-weight: $gl-font-weight-bold; } /* Generic.Strong */ .gu { color: $solarized-dark-gu; } /* Generic.Subheading */ .gt { color: $solarized-dark-gt; } /* Generic.Traceback */ .kc { color: $solarized-dark-kc; } /* Keyword.Constant */ diff --git a/app/assets/stylesheets/highlight/solarized_light.scss b/app/assets/stylesheets/highlight/solarized_light.scss index b61b85a2cd1..e9fccf1b58a 100644 --- a/app/assets/stylesheets/highlight/solarized_light.scss +++ b/app/assets/stylesheets/highlight/solarized_light.scss @@ -239,7 +239,7 @@ $solarized-light-il: #2aa198; .gi { color: $solarized-light-gi; } /* Generic.Inserted */ .go { color: $solarized-light-go; } /* Generic.Output */ .gp { color: $solarized-light-gp; } /* Generic.Prompt */ - .gs { color: $solarized-light-gs; font-weight: bold; } /* Generic.Strong */ + .gs { color: $solarized-light-gs; font-weight: $gl-font-weight-bold; } /* Generic.Strong */ .gu { color: $solarized-light-gu; } /* Generic.Subheading */ .gt { color: $solarized-light-gt; } /* Generic.Traceback */ .kc { color: $solarized-light-kc; } /* Keyword.Constant */ diff --git a/app/assets/stylesheets/highlight/white.scss b/app/assets/stylesheets/highlight/white.scss index 578f1902cce..65b140cd7f8 100644 --- a/app/assets/stylesheets/highlight/white.scss +++ b/app/assets/stylesheets/highlight/white.scss @@ -211,12 +211,12 @@ $white-gc-bg: #eaf2f5; .hll { background-color: $white-hll-bg; } .c { color: $white-c; font-style: italic; } .err { color: $white-err; background-color: $white-err-bg; } - .k { font-weight: bold; } - .o { font-weight: bold; } + .k { font-weight: $gl-font-weight-bold; } + .o { font-weight: $gl-font-weight-bold; } .cm { color: $white-cm; font-style: italic; } - .cp { color: $white-cp; font-weight: bold; } + .cp { color: $white-cp; font-weight: $gl-font-weight-bold; } .c1 { color: $white-c1; font-style: italic; } - .cs { color: $white-cs; font-weight: bold; font-style: italic; } + .cs { color: $white-cs; font-weight: $gl-font-weight-bold; font-style: italic; } .gd { color: $white-gd; background-color: $white-gd-bg; } .gd .x { color: $white-gd-x; background-color: $white-gd-x-bg; } .ge { font-style: italic; } @@ -226,29 +226,29 @@ $white-gc-bg: #eaf2f5; .gi .x { color: $white-gi-x; background-color: $white-gi-x-bg; } .go { color: $white-go; } .gp { color: $white-gp; } - .gs { font-weight: bold; } - .gu { color: $white-gu; font-weight: bold; } + .gs { font-weight: $gl-font-weight-bold; } + .gu { color: $white-gu; font-weight: $gl-font-weight-bold; } .gt { color: $white-gt; } - .kc { font-weight: bold; } - .kd { font-weight: bold; } - .kn { font-weight: bold; } - .kp { font-weight: bold; } - .kr { font-weight: bold; } - .kt { color: $white-kt; font-weight: bold; } + .kc { font-weight: $gl-font-weight-bold; } + .kd { font-weight: $gl-font-weight-bold; } + .kn { font-weight: $gl-font-weight-bold; } + .kp { font-weight: $gl-font-weight-bold; } + .kr { font-weight: $gl-font-weight-bold; } + .kt { color: $white-kt; font-weight: $gl-font-weight-bold; } .m { color: $white-m; } .s { color: $white-s; } .n { color: $white-n; } .na { color: $white-na; } .nb { color: $white-nb; } - .nc { color: $white-nc; font-weight: bold; } + .nc { color: $white-nc; font-weight: $gl-font-weight-bold; } .no { color: $white-no; } .ni { color: $white-ni; } - .ne { color: $white-ne; font-weight: bold; } - .nf { color: $white-nf; font-weight: bold; } + .ne { color: $white-ne; font-weight: $gl-font-weight-bold; } + .nf { color: $white-nf; font-weight: $gl-font-weight-bold; } .nn { color: $white-nn; } .nt { color: $white-nt; } .nv { color: $white-nv; } - .ow { font-weight: bold; } + .ow { font-weight: $gl-font-weight-bold; } .w { color: $white-w; } .mf { color: $white-mf; } .mh { color: $white-mh; } diff --git a/app/assets/stylesheets/mailers/highlighted_diff_email.scss b/app/assets/stylesheets/mailers/highlighted_diff_email.scss index ea40f449134..fbe538ad1d7 100644 --- a/app/assets/stylesheets/mailers/highlighted_diff_email.scss +++ b/app/assets/stylesheets/mailers/highlighted_diff_email.scss @@ -152,12 +152,12 @@ span.highlight_word { .hll { background-color: $highlighted-hll-bg; } .c { color: $highlighted-c; font-style: italic; } .err { color: $highlighted-err; background-color: $highlighted-err-bg; } -.k { font-weight: bold; } -.o { font-weight: bold; } +.k { font-weight: $gl-font-weight-bold; } +.o { font-weight: $gl-font-weight-bold; } .cm { color: $highlighted-cm; font-style: italic; } -.cp { color: $highlighted-cp; font-weight: bold; } +.cp { color: $highlighted-cp; font-weight: $gl-font-weight-bold; } .c1 { color: $highlighted-c1; font-style: italic; } -.cs { color: $highlighted-cs; font-weight: bold; font-style: italic; } +.cs { color: $highlighted-cs; font-weight: $gl-font-weight-bold; font-style: italic; } .gd { color: $highlighted-gd; background-color: $highlighted-gd-bg; } .gd .x { color: $highlighted-gd; background-color: $highlighted-gd-x-bg; } .ge { font-style: italic; } @@ -167,29 +167,29 @@ span.highlight_word { .gi .x { color: $highlighted-gi; background-color: $highlighted-gi-x-bg; } .go { color: $highlighted-go; } .gp { color: $highlighted-gp; } -.gs { font-weight: bold; } -.gu { color: $highlighted-gu; font-weight: bold; } +.gs { font-weight: $gl-font-weight-bold; } +.gu { color: $highlighted-gu; font-weight: $gl-font-weight-bold; } .gt { color: $highlighted-gt; } -.kc { font-weight: bold; } -.kd { font-weight: bold; } -.kn { font-weight: bold; } -.kp { font-weight: bold; } -.kr { font-weight: bold; } -.kt { color: $highlighted-kt; font-weight: bold; } +.kc { font-weight: $gl-font-weight-bold; } +.kd { font-weight: $gl-font-weight-bold; } +.kn { font-weight: $gl-font-weight-bold; } +.kp { font-weight: $gl-font-weight-bold; } +.kr { font-weight: $gl-font-weight-bold; } +.kt { color: $highlighted-kt; font-weight: $gl-font-weight-bold; } .m { color: $highlighted-m; } .s { color: $highlighted-s; } .n { color: $highlighted-n; } .na { color: $highlighted-na; } .nb { color: $highlighted-nb; } -.nc { color: $highlighted-nc; font-weight: bold; } +.nc { color: $highlighted-nc; font-weight: $gl-font-weight-bold; } .no { color: $highlighted-no; } .ni { color: $highlighted-ni; } -.ne { color: $highlighted-ne; font-weight: bold; } -.nf { color: $highlighted-nf; font-weight: bold; } +.ne { color: $highlighted-ne; font-weight: $gl-font-weight-bold; } +.nf { color: $highlighted-nf; font-weight: $gl-font-weight-bold; } .nn { color: $highlighted-nn; } .nt { color: $highlighted-nt; } .nv { color: $highlighted-nv; } -.ow { font-weight: bold; } +.ow { font-weight: $gl-font-weight-bold; } .w { color: $highlighted-w; } .mf { color: $highlighted-mf; } .mh { color: $highlighted-mh; } diff --git a/app/assets/stylesheets/new_nav.scss b/app/assets/stylesheets/new_nav.scss index 3e2f23e6b2a..54fa4109f8b 100644 --- a/app/assets/stylesheets/new_nav.scss +++ b/app/assets/stylesheets/new_nav.scss @@ -134,7 +134,7 @@ header.navbar-gitlab-new { li { .badge { box-shadow: none; - font-weight: 600; + font-weight: $gl-font-weight-bold; } } } @@ -193,7 +193,7 @@ header.navbar-gitlab-new { &.active > a { box-shadow: inset 0 -3px 0 $indigo-500; color: $white-light; - font-weight: 700; + font-weight: $gl-font-weight-bold; } > a { @@ -371,7 +371,7 @@ header.navbar-gitlab-new { > a { &:last-of-type:not(:first-child) { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } } @@ -411,7 +411,7 @@ header.navbar-gitlab-new { .breadcrumbs-sub-title { margin: 2px 0; font-size: 16px; - font-weight: normal; + font-weight: $gl-font-weight-normal; line-height: 1; ul { @@ -430,7 +430,7 @@ header.navbar-gitlab-new { } &:last-child a { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } diff --git a/app/assets/stylesheets/new_sidebar.scss b/app/assets/stylesheets/new_sidebar.scss index cee5b22adb9..a74d53b4f68 100644 --- a/app/assets/stylesheets/new_sidebar.scss +++ b/app/assets/stylesheets/new_sidebar.scss @@ -46,7 +46,7 @@ $new-sidebar-collapsed-width: 50px; a { border-bottom: 1px solid $border-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; display: flex; align-items: center; padding: 10px 16px 10px 10px; @@ -160,7 +160,7 @@ $new-sidebar-collapsed-width: 50px; > a { color: $active-color; - font-weight: 700; + font-weight: $gl-font-weight-bold; } svg { @@ -308,7 +308,7 @@ $new-sidebar-collapsed-width: 50px; .badge { color: $active-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; } .sidebar-sub-level-items { @@ -474,6 +474,6 @@ $new-sidebar-collapsed-width: 50px; border-bottom-color: $active-border; .badge { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } diff --git a/app/assets/stylesheets/pages/boards.scss b/app/assets/stylesheets/pages/boards.scss index e5b467a2691..0f3074076ce 100644 --- a/app/assets/stylesheets/pages/boards.scss +++ b/app/assets/stylesheets/pages/boards.scss @@ -471,7 +471,7 @@ padding-right: 35px; > strong { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } } diff --git a/app/assets/stylesheets/pages/builds.scss b/app/assets/stylesheets/pages/builds.scss index 486424fb729..3d04df8d820 100644 --- a/app/assets/stylesheets/pages/builds.scss +++ b/app/assets/stylesheets/pages/builds.scss @@ -277,7 +277,7 @@ } .trigger-build-variable { - font-weight: normal; + font-weight: $gl-font-weight-normal; color: $code-color; } @@ -378,7 +378,7 @@ } &.active { - font-weight: bold; + font-weight: $gl-font-weight-bold; .fa-arrow-right { display: block; diff --git a/app/assets/stylesheets/pages/ci_projects.scss b/app/assets/stylesheets/pages/ci_projects.scss index 7b4eb689f1b..bf6a48889bf 100644 --- a/app/assets/stylesheets/pages/ci_projects.scss +++ b/app/assets/stylesheets/pages/ci_projects.scss @@ -22,7 +22,7 @@ vertical-align: middle !important; a { - font-weight: normal; + font-weight: $gl-font-weight-normal; text-decoration: none; } } diff --git a/app/assets/stylesheets/pages/commits.scss b/app/assets/stylesheets/pages/commits.scss index d0d11b4d71c..c051d37aad6 100644 --- a/app/assets/stylesheets/pages/commits.scss +++ b/app/assets/stylesheets/pages/commits.scss @@ -213,7 +213,7 @@ .commit-sha { font-size: 14px; - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -306,7 +306,7 @@ .gpg-popover-status { display: flex; align-items: center; - font-weight: normal; + font-weight: $gl-font-weight-normal; line-height: 1.5; } diff --git a/app/assets/stylesheets/pages/convdev_index.scss b/app/assets/stylesheets/pages/convdev_index.scss index 0413114c279..16702442f50 100644 --- a/app/assets/stylesheets/pages/convdev_index.scss +++ b/app/assets/stylesheets/pages/convdev_index.scss @@ -23,7 +23,7 @@ $space-between-cards: 8px; line-height: 1; color: $gl-text-color-secondary; margin-left: 8px; - font-weight: 500; + font-weight: $gl-font-weight-normal; a { font-size: 18px; @@ -139,7 +139,7 @@ $space-between-cards: 8px; .card-score-value { font-size: 16px; color: $gl-text-color; - font-weight: 500; + font-weight: $gl-font-weight-normal; } .card-score-big { @@ -147,7 +147,7 @@ $space-between-cards: 8px; border-bottom: 1px solid $border-color; font-size: 22px; padding: 10px 0; - font-weight: 500; + font-weight: $gl-font-weight-normal; } .card-buttons { diff --git a/app/assets/stylesheets/pages/cycle_analytics.scss b/app/assets/stylesheets/pages/cycle_analytics.scss index 6753eb08285..2a92673d9fa 100644 --- a/app/assets/stylesheets/pages/cycle_analytics.scss +++ b/app/assets/stylesheets/pages/cycle_analytics.scss @@ -68,7 +68,7 @@ } .stage-name { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -93,7 +93,7 @@ .header { font-size: 30px; line-height: 38px; - font-weight: normal; + font-weight: $gl-font-weight-normal; margin: 0; } @@ -130,7 +130,7 @@ &.title { line-height: 19px; font-size: 14px; - font-weight: 600; + font-weight: $gl-font-weight-bold; color: $gl-text-color; } @@ -211,7 +211,7 @@ box-shadow: inset 2px 0 0 0 $active-item-blue; .stage-name { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -404,7 +404,7 @@ color: $gl-link-color; line-height: 1.3; vertical-align: top; - font-weight: normal; + font-weight: $gl-font-weight-normal; } .fa { diff --git a/app/assets/stylesheets/pages/diff.scss b/app/assets/stylesheets/pages/diff.scss index 913a1a95dca..8cbf0ec6180 100644 --- a/app/assets/stylesheets/pages/diff.scss +++ b/app/assets/stylesheets/pages/diff.scss @@ -40,7 +40,7 @@ // "Changes suppressed. Click to show." link .show-suppressed-diff { font-size: 110%; - font-weight: bold; + font-weight: $gl-font-weight-bold; } } @@ -104,7 +104,7 @@ a { float: left; width: 35px; - font-weight: normal; + font-weight: $gl-font-weight-normal; &[disabled] { cursor: default; @@ -395,7 +395,7 @@ background-color: transparent; border: 0; color: $gl-link-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; &:hover, &:focus { diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 00ebf4e26ac..a8d2ae0af28 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -6,7 +6,7 @@ } .environments-folder-name { - font-weight: normal; + font-weight: $gl-font-weight-normal; padding-top: 20px; } @@ -246,13 +246,13 @@ } .text-metric-bold { - font-weight: 600; + font-weight: $gl-font-weight-bold; } .label-axis-text, .text-metric-usage { fill: $black; - font-weight: 500; + font-weight: $gl-font-weight-normal; font-size: 12px; } diff --git a/app/assets/stylesheets/pages/events.scss b/app/assets/stylesheets/pages/events.scss index 4c3fa1fb8d4..1723d716805 100644 --- a/app/assets/stylesheets/pages/events.scss +++ b/app/assets/stylesheets/pages/events.scss @@ -57,7 +57,7 @@ .event-title { @include str-truncated(calc(100% - 174px)); - font-weight: 600; + font-weight: $gl-font-weight-bold; color: $list-text-color; } diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 49839a9b528..ab5a901da71 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -271,7 +271,7 @@ } .light { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .no-value { @@ -306,7 +306,7 @@ display: block; margin-top: 4px; font-size: 13px; - font-weight: normal; + font-weight: $gl-font-weight-normal; } .hide-expanded { @@ -689,7 +689,7 @@ .issuable-info, .task-status, .issuable-updated-at { - font-weight: normal; + font-weight: $gl-font-weight-normal; color: $gl-text-color-secondary; a { diff --git a/app/assets/stylesheets/pages/issues.scss b/app/assets/stylesheets/pages/issues.scss index 8cdb3f34ae5..e2177f96aee 100644 --- a/app/assets/stylesheets/pages/issues.scss +++ b/app/assets/stylesheets/pages/issues.scss @@ -75,7 +75,7 @@ ul.related-merge-requests > li { .merge-requests-title, .related-branches-title { font-size: 16px; - font-weight: 600; + font-weight: $gl-font-weight-bold; } .merge-request-id { @@ -244,7 +244,7 @@ ul.related-merge-requests > li { strong { display: block; - font-weight: 600; + font-weight: $gl-font-weight-bold; } } } diff --git a/app/assets/stylesheets/pages/login.scss b/app/assets/stylesheets/pages/login.scss index 3cbe8dededb..d4dc43035eb 100644 --- a/app/assets/stylesheets/pages/login.scss +++ b/app/assets/stylesheets/pages/login.scss @@ -22,7 +22,7 @@ } h1:first-child { - font-weight: normal; + font-weight: $gl-font-weight-normal; margin-bottom: 0.68em; margin-top: 0; font-size: 34px; @@ -38,7 +38,7 @@ } a { - font-weight: bold; + font-weight: $gl-font-weight-bold; } } @@ -54,7 +54,7 @@ padding: 15px; .login-heading h3 { - font-weight: 300; + font-weight: $gl-font-weight-normal; line-height: 1.5; margin: 0 0 10px; } @@ -186,7 +186,7 @@ } label { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .submit-container { diff --git a/app/assets/stylesheets/pages/members.scss b/app/assets/stylesheets/pages/members.scss index e7c07ef67f0..a385eb359e1 100644 --- a/app/assets/stylesheets/pages/members.scss +++ b/app/assets/stylesheets/pages/members.scss @@ -46,7 +46,7 @@ } strong { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -221,7 +221,7 @@ } .member { - font-weight: bold; + font-weight: $gl-font-weight-bold; overflow-wrap: break-word; word-break: break-all; } diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index 6bb013cca85..d1678a17aaf 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -197,7 +197,7 @@ @extend .ref-name; color: $gl-text-color; - font-weight: 600; + font-weight: $gl-font-weight-bold; overflow: hidden; word-break: break-all; @@ -228,7 +228,7 @@ .mr-widget-body { h4 { float: left; - font-weight: 600; + font-weight: $gl-font-weight-bold; font-size: 14px; line-height: inherit; margin-top: 0; @@ -239,7 +239,7 @@ } time { - font-weight: normal; + font-weight: $gl-font-weight-normal; } } @@ -249,7 +249,7 @@ } label { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .spacing { @@ -257,12 +257,12 @@ } .bold { - font-weight: 600; + font-weight: $gl-font-weight-bold; color: $gl-gray-light; } .state-label { - font-weight: 600; + font-weight: $gl-font-weight-bold; padding-right: 10px; } @@ -336,7 +336,7 @@ .text { span { - font-weight: 600; + font-weight: $gl-font-weight-bold; } p { @@ -505,7 +505,7 @@ .panel-new-merge-request { .panel-heading { padding: 5px 10px; - font-weight: 600; + font-weight: $gl-font-weight-bold; line-height: 25px; } diff --git a/app/assets/stylesheets/pages/milestone.scss b/app/assets/stylesheets/pages/milestone.scss index 55e0ee1936e..32039936be7 100644 --- a/app/assets/stylesheets/pages/milestone.scss +++ b/app/assets/stylesheets/pages/milestone.scss @@ -7,7 +7,7 @@ padding: 10px 16px; h4 { - font-weight: bold; + font-weight: $gl-font-weight-bold; } .progress { @@ -81,7 +81,7 @@ } .remaining-days strong { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .milestone-stat { diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index b4468d6d0a2..9558924bbcb 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -188,7 +188,7 @@ .close { color: $white-light; opacity: 0.85; - font-weight: normal; + font-weight: $gl-font-weight-normal; &:hover { opacity: 1; diff --git a/app/assets/stylesheets/pages/pipeline_schedules.scss b/app/assets/stylesheets/pages/pipeline_schedules.scss index dc1654e006e..7e2297c283f 100644 --- a/app/assets/stylesheets/pages/pipeline_schedules.scss +++ b/app/assets/stylesheets/pages/pipeline_schedules.scss @@ -12,7 +12,7 @@ .interval-pattern-form-group { label { margin-right: 10px; - font-weight: normal; + font-weight: $gl-font-weight-normal; &[for='custom'] { margin-right: 0; diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss index 85d1905ad40..a408bde37d6 100644 --- a/app/assets/stylesheets/pages/pipelines.scss +++ b/app/assets/stylesheets/pages/pipelines.scss @@ -128,7 +128,7 @@ .branch-commit { .ref-name { - font-weight: bold; + font-weight: $gl-font-weight-bold; max-width: 120px; overflow: hidden; display: inline-block; @@ -272,7 +272,7 @@ .build-name { float: right; - font-weight: 500; + font-weight: $gl-font-weight-normal; } .ci-status-icon-failed svg { @@ -281,7 +281,7 @@ .stage { color: $gl-text-color-secondary; - font-weight: 500; + font-weight: $gl-font-weight-normal; vertical-align: middle; } } @@ -420,7 +420,7 @@ .stage-name { margin: 0 0 15px 10px; - font-weight: bold; + font-weight: $gl-font-weight-bold; width: 176px; white-space: nowrap; overflow: hidden; @@ -580,7 +580,7 @@ vertical-align: bottom; display: inline-block; position: relative; - font-weight: normal; + font-weight: $gl-font-weight-normal; } @mixin mini-pipeline-graph-color($color-light, $color-main, $color-dark) { @@ -724,7 +724,7 @@ button.mini-pipeline-graph-dropdown-toggle { .mini-pipeline-graph-dropdown-item { padding: 3px 7px 4px; clear: both; - font-weight: normal; + font-weight: $gl-font-weight-normal; line-height: 1.428571429; white-space: nowrap; margin: 0 5px; diff --git a/app/assets/stylesheets/pages/profile.scss b/app/assets/stylesheets/pages/profile.scss index 14ad06b0ac2..c5d6ff66dd6 100644 --- a/app/assets/stylesheets/pages/profile.scss +++ b/app/assets/stylesheets/pages/profile.scss @@ -83,7 +83,7 @@ &::after { content: "\00B7"; // Middle Dot padding: 0 6px; - font-weight: bold; + font-weight: $gl-font-weight-bold; } &:last-child { @@ -277,7 +277,7 @@ table.u2f-registrations { .oauth-application-show { .scope-name { - font-weight: 600; + font-weight: $gl-font-weight-bold; } .scopes-list { diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index d01326637ea..39c4264e496 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -2,7 +2,7 @@ margin: -16px; .alert-link { - font-weight: normal; + font-weight: $gl-font-weight-normal; } } @@ -114,7 +114,7 @@ margin-top: 10px; margin-bottom: 10px; font-size: 24px; - font-weight: 400; + font-weight: $gl-font-weight-normal; line-height: 1; word-wrap: break-word; @@ -259,7 +259,7 @@ border-width: 1px; border-style: solid; font-size: 13px; - font-weight: 600; + font-weight: $gl-font-weight-bold; line-height: 13px; letter-spacing: .4px; padding: 6px 14px; @@ -309,7 +309,7 @@ } .option-title { - font-weight: normal; + font-weight: $gl-font-weight-normal; display: inline-block; color: $gl-text-color; } @@ -575,7 +575,7 @@ a.deploy-project-label { color: $gl-text-color-tertiary; transform: translateY(-50%); font-size: 12px; - font-weight: bold; + font-weight: $gl-font-weight-bold; line-height: 20px; // Mobile @@ -826,7 +826,7 @@ pre.light-well { .new-protected-tag { label { margin-top: 6px; - font-weight: normal; + font-weight: $gl-font-weight-normal; } } @@ -853,7 +853,7 @@ pre.light-well { } &.is-active { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } @@ -952,7 +952,7 @@ pre.light-well { &::before { font-family: FontAwesome; - font-weight: normal; + font-weight: $gl-font-weight-normal; font-style: normal; } } diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 1f4d4698199..37971d6bd3a 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -267,7 +267,7 @@ display: inline-block; font-size: 10px; text-transform: uppercase; - font-weight: bold; + font-weight: $gl-font-weight-bold; color: $gray-darkest; white-space: nowrap; overflow: hidden; diff --git a/app/assets/stylesheets/pages/runners.scss b/app/assets/stylesheets/pages/runners.scss index 57c73295d1e..6cac37a4e28 100644 --- a/app/assets/stylesheets/pages/runners.scss +++ b/app/assets/stylesheets/pages/runners.scss @@ -30,7 +30,7 @@ } h4 { - font-weight: normal; + font-weight: $gl-font-weight-normal; } } diff --git a/app/assets/stylesheets/pages/search.scss b/app/assets/stylesheets/pages/search.scss index b9818ffcf42..8d73246223d 100644 --- a/app/assets/stylesheets/pages/search.scss +++ b/app/assets/stylesheets/pages/search.scss @@ -94,7 +94,7 @@ input[type="checkbox"]:hover { &::before { font-family: FontAwesome; - font-weight: normal; + font-weight: $gl-font-weight-normal; font-style: normal; } } diff --git a/app/assets/stylesheets/pages/sherlock.scss b/app/assets/stylesheets/pages/sherlock.scss index 23a9c2ada80..bfe065dbbaf 100644 --- a/app/assets/stylesheets/pages/sherlock.scss +++ b/app/assets/stylesheets/pages/sherlock.scss @@ -29,5 +29,5 @@ table .sherlock-code { .sherlock-line-samples-table .slow { color: $red-500; - font-weight: bold; + font-weight: $gl-font-weight-bold; } diff --git a/app/assets/stylesheets/pages/todos.scss b/app/assets/stylesheets/pages/todos.scss index d7a9dda3770..5b9fafe31bd 100644 --- a/app/assets/stylesheets/pages/todos.scss +++ b/app/assets/stylesheets/pages/todos.scss @@ -108,14 +108,14 @@ margin: 0; float: none; display: inline-block; - font-weight: normal; + font-weight: $gl-font-weight-normal; padding: 0 5px; line-height: inherit; font-size: 14px; } .action-name { - font-weight: normal; + font-weight: $gl-font-weight-normal; } .todo-body { @@ -262,6 +262,6 @@ } a { - font-weight: 600; + font-weight: $gl-font-weight-bold; } } diff --git a/app/assets/stylesheets/pages/tree.scss b/app/assets/stylesheets/pages/tree.scss index 0028e207f3e..224eee90a3f 100644 --- a/app/assets/stylesheets/pages/tree.scss +++ b/app/assets/stylesheets/pages/tree.scss @@ -231,7 +231,7 @@ } .upload-link { - font-weight: normal; + font-weight: $gl-font-weight-normal; color: $md-link-color; } diff --git a/app/assets/stylesheets/pages/ui_dev_kit.scss b/app/assets/stylesheets/pages/ui_dev_kit.scss index 798e060a261..48ac5b21db8 100644 --- a/app/assets/stylesheets/pages/ui_dev_kit.scss +++ b/app/assets/stylesheets/pages/ui_dev_kit.scss @@ -1,7 +1,7 @@ .gitlab-ui-dev-kit { > h2 { margin: 35px 0 20px; - font-weight: bold; + font-weight: $gl-font-weight-bold; } .example { diff --git a/app/assets/stylesheets/pages/wiki.scss b/app/assets/stylesheets/pages/wiki.scss index fa6bdd297eb..b7d4e7bf582 100644 --- a/app/assets/stylesheets/pages/wiki.scss +++ b/app/assets/stylesheets/pages/wiki.scss @@ -37,7 +37,7 @@ } .light { - font-weight: normal; + font-weight: $gl-font-weight-normal; color: $gl-text-color-secondary; } @@ -89,7 +89,7 @@ h3 { font-size: 19px; - font-weight: normal; + font-weight: $gl-font-weight-normal; margin: $gl-padding 0; } } diff --git a/app/assets/stylesheets/pages/xterm.scss b/app/assets/stylesheets/pages/xterm.scss index b085c56390d..c7297a34ad8 100644 --- a/app/assets/stylesheets/pages/xterm.scss +++ b/app/assets/stylesheets/pages/xterm.scss @@ -281,7 +281,7 @@ $xterm-fg-255: #eee; .term-bold { - font-weight: bold; + font-weight: $gl-font-weight-bold; } .term-italic { diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 113e6e86bb5..b07a5ae22cd 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -17,7 +17,7 @@ .wiki h3 { font-size: 18px; - font-weight: bold; + font-weight: 600; } header, diff --git a/app/views/layouts/errors.html.haml b/app/views/layouts/errors.html.haml index 6d9ec043590..9382ee8715e 100644 --- a/app/views/layouts/errors.html.haml +++ b/app/views/layouts/errors.html.haml @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } diff --git a/app/views/layouts/oauth_error.html.haml b/app/views/layouts/oauth_error.html.haml index 34bcd2a8b3a..03b387f8181 100644 --- a/app/views/layouts/oauth_error.html.haml +++ b/app/views/layouts/oauth_error.html.haml @@ -19,7 +19,7 @@ h3 { color: #456; font-size: 22px; - font-weight: bold; + font-weight: 600; margin-bottom: 6px; } diff --git a/changelogs/unreleased/font-weight-adjusted.yml b/changelogs/unreleased/font-weight-adjusted.yml new file mode 100644 index 00000000000..827f3485099 --- /dev/null +++ b/changelogs/unreleased/font-weight-adjusted.yml @@ -0,0 +1,5 @@ +--- +title: Changed all font-weight values to 400 and 600 and introduced 2 variables to + manage them +merge_request: !12896 +author: diff --git a/public/404.html b/public/404.html index 03e98e81862..4db72be6f8c 100644 --- a/public/404.html +++ b/public/404.html @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -48,7 +48,7 @@ a { line-height: 100px; - font-weight: normal; + font-weight: 400; color: #4A8BEE; font-size: 18px; text-decoration: none; diff --git a/public/422.html b/public/422.html index 49ebbe40f39..a67dcd02200 100644 --- a/public/422.html +++ b/public/422.html @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -48,7 +48,7 @@ a { line-height: 100px; - font-weight: normal; + font-weight: 400; color: #4A8BEE; font-size: 18px; text-decoration: none; diff --git a/public/500.html b/public/500.html index 516920f7471..7091d14dfc4 100644 --- a/public/500.html +++ b/public/500.html @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -48,7 +48,7 @@ a { line-height: 100px; - font-weight: normal; + font-weight: 400; color: #4A8BEE; font-size: 18px; text-decoration: none; diff --git a/public/502.html b/public/502.html index 189458c9816..82afd273248 100644 --- a/public/502.html +++ b/public/502.html @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -48,7 +48,7 @@ a { line-height: 100px; - font-weight: normal; + font-weight: 400; color: #4A8BEE; font-size: 18px; text-decoration: none; diff --git a/public/503.html b/public/503.html index b09b0e2a67e..f1486bc3e84 100644 --- a/public/503.html +++ b/public/503.html @@ -15,7 +15,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -28,7 +28,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -48,7 +48,7 @@ a { line-height: 100px; - font-weight: normal; + font-weight: 400; color: #4A8BEE; font-size: 18px; text-decoration: none; diff --git a/public/deploy.html b/public/deploy.html index 49ec4ac5ce1..e463b62520c 100644 --- a/public/deploy.html +++ b/public/deploy.html @@ -20,7 +20,7 @@ h1 { font-size: 56px; line-height: 100px; - font-weight: normal; + font-weight: 400; color: #456; } @@ -33,7 +33,7 @@ h3 { color: #456; font-size: 20px; - font-weight: normal; + font-weight: 400; line-height: 28px; } @@ -66,4 +66,4 @@

Please contact your GitLab administrator if this problem persists.

- \ No newline at end of file + diff --git a/spec/fixtures/emails/ios_default.eml b/spec/fixtures/emails/ios_default.eml index 8d4d58feb16..fa19475104a 100644 --- a/spec/fixtures/emails/ios_default.eml +++ b/spec/fixtures/emails/ios_default.eml @@ -76,7 +76,7 @@ Content-Transfer-Encoding: 7bit - techAPJ
+ techAPJ
November 28 @@ -94,7 +94,7 @@ Content-Transfer-Encoding: 7bit
-

To respond, reply to this email or visit https://meta.discourse.org/t/testing-default-email-replies/22638/3 in your browser.

+

To respond, reply to this email or visit https://meta.discourse.org/t/testing-default-email-replies/22638/3 in your browser.


Previous Replies

@@ -106,7 +106,7 @@ Content-Transfer-Encoding: 7bit - codinghorror
+ codinghorror
November 28 @@ -114,7 +114,7 @@ Content-Transfer-Encoding: 7bit

We're testing the latest GitHub email processing library which we are integrating now.

-

https://github.com/github/email_reply_parser

+

https://github.com/github/email_reply_parser

Go ahead and reply to this topic and I'll reply from various email clients for testing.

@@ -126,10 +126,10 @@ Content-Transfer-Encoding: 7bit
-

To respond, reply to this email or visit https://meta.discourse.org/t/testing-default-email-replies/22638/3 in your browser.

+

To respond, reply to this email or visit https://meta.discourse.org/t/testing-default-email-replies/22638/3 in your browser.

-

To unsubscribe from these emails, visit your user preferences.

+

To unsubscribe from these emails, visit your user preferences.

diff --git a/spec/fixtures/emails/on_wrote.eml b/spec/fixtures/emails/on_wrote.eml index feb59bd27bb..af6a4e50a49 100644 --- a/spec/fixtures/emails/on_wrote.eml +++ b/spec/fixtures/emails/on_wrote.eml @@ -53,7 +53,7 @@ y > display: inline-block; > font-family: FontAwesome; > font-style: normal; -> font-weight: normal; +> font-weight: 400; > line-height: 1; > -webkit-font-smoothing: antialiased; > -moz-osx-font-smoothing: grayscale; @@ -227,7 +227,7 @@ ding:5px">.fa { display: inline-block; font-family: FontAwesome; font-style: normal; - font-weight: normal; + font-weight: 400; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; @@ -274,4 +274,4 @@ ight:bold;color:#006699" target=3D"_blank">user preferences.


---001a11c34c389e728f0502aa26a0-- \ No newline at end of file +--001a11c34c389e728f0502aa26a0-- diff --git a/vendor/assets/stylesheets/katex.scss b/vendor/assets/stylesheets/katex.scss index 9dd8a30bf51..b45836716f2 100644 --- a/vendor/assets/stylesheets/katex.scss +++ b/vendor/assets/stylesheets/katex.scss @@ -45,112 +45,112 @@ SOFTWARE. font-family: 'KaTeX_AMS'; src: url(font-path('KaTeX_AMS-Regular.eot')); src: url(font-path('KaTeX_AMS-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_AMS-Regular.woff2')) format('woff2'), url(font-path('KaTeX_AMS-Regular.woff')) format('woff'), url(font-path('KaTeX_AMS-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; src: url(font-path('KaTeX_Caligraphic-Bold.eot')); src: url(font-path('KaTeX_Caligraphic-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Caligraphic-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Caligraphic-Bold.woff')) format('woff'), url(font-path('KaTeX_Caligraphic-Bold.ttf')) format('truetype'); - font-weight: bold; + font-weight: 600; font-style: normal; } @font-face { font-family: 'KaTeX_Caligraphic'; src: url(font-path('KaTeX_Caligraphic-Regular.eot')); src: url(font-path('KaTeX_Caligraphic-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Caligraphic-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Caligraphic-Regular.woff')) format('woff'), url(font-path('KaTeX_Caligraphic-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; src: url(font-path('KaTeX_Fraktur-Bold.eot')); src: url(font-path('KaTeX_Fraktur-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Fraktur-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Fraktur-Bold.woff')) format('woff'), url(font-path('KaTeX_Fraktur-Bold.ttf')) format('truetype'); - font-weight: bold; + font-weight: 600; font-style: normal; } @font-face { font-family: 'KaTeX_Fraktur'; src: url(font-path('KaTeX_Fraktur-Regular.eot')); src: url(font-path('KaTeX_Fraktur-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Fraktur-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Fraktur-Regular.woff')) format('woff'), url(font-path('KaTeX_Fraktur-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Bold.eot')); src: url(font-path('KaTeX_Main-Bold.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Bold.woff2')) format('woff2'), url(font-path('KaTeX_Main-Bold.woff')) format('woff'), url(font-path('KaTeX_Main-Bold.ttf')) format('truetype'); - font-weight: bold; + font-weight: 600; font-style: normal; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Italic.eot')); src: url(font-path('KaTeX_Main-Italic.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Italic.woff2')) format('woff2'), url(font-path('KaTeX_Main-Italic.woff')) format('woff'), url(font-path('KaTeX_Main-Italic.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: italic; } @font-face { font-family: 'KaTeX_Main'; src: url(font-path('KaTeX_Main-Regular.eot')); src: url(font-path('KaTeX_Main-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Main-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Main-Regular.woff')) format('woff'), url(font-path('KaTeX_Main-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Math'; src: url(font-path('KaTeX_Math-Italic.eot')); src: url(font-path('KaTeX_Math-Italic.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Math-Italic.woff2')) format('woff2'), url(font-path('KaTeX_Math-Italic.woff')) format('woff'), url(font-path('KaTeX_Math-Italic.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: italic; } @font-face { font-family: 'KaTeX_SansSerif'; src: url(font-path('KaTeX_SansSerif-Regular.eot')); src: url(font-path('KaTeX_SansSerif-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_SansSerif-Regular.woff2')) format('woff2'), url(font-path('KaTeX_SansSerif-Regular.woff')) format('woff'), url(font-path('KaTeX_SansSerif-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Script'; src: url(font-path('KaTeX_Script-Regular.eot')); src: url(font-path('KaTeX_Script-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Script-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Script-Regular.woff')) format('woff'), url(font-path('KaTeX_Script-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Size1'; src: url(font-path('KaTeX_Size1-Regular.eot')); src: url(font-path('KaTeX_Size1-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size1-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size1-Regular.woff')) format('woff'), url(font-path('KaTeX_Size1-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Size2'; src: url(font-path('KaTeX_Size2-Regular.eot')); src: url(font-path('KaTeX_Size2-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size2-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size2-Regular.woff')) format('woff'), url(font-path('KaTeX_Size2-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Size3'; src: url(font-path('KaTeX_Size3-Regular.eot')); src: url(font-path('KaTeX_Size3-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size3-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size3-Regular.woff')) format('woff'), url(font-path('KaTeX_Size3-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Size4'; src: url(font-path('KaTeX_Size4-Regular.eot')); src: url(font-path('KaTeX_Size4-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Size4-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Size4-Regular.woff')) format('woff'), url(font-path('KaTeX_Size4-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } @font-face { font-family: 'KaTeX_Typewriter'; src: url(font-path('KaTeX_Typewriter-Regular.eot')); src: url(font-path('KaTeX_Typewriter-Regular.eot#iefix')) format('embedded-opentype'), url(font-path('KaTeX_Typewriter-Regular.woff2')) format('woff2'), url(font-path('KaTeX_Typewriter-Regular.woff')) format('woff'), url(font-path('KaTeX_Typewriter-Regular.ttf')) format('truetype'); - font-weight: normal; + font-weight: 400; font-style: normal; } .katex-display { @@ -192,7 +192,7 @@ SOFTWARE. } .katex .mathbf { font-family: KaTeX_Main; - font-weight: bold; + font-weight: 600; } .katex .amsrm { font-family: KaTeX_AMS; diff --git a/vendor/assets/stylesheets/xterm/xterm.css b/vendor/assets/stylesheets/xterm/xterm.css index b30d7b493f1..fabc51b0e3d 100644 --- a/vendor/assets/stylesheets/xterm/xterm.css +++ b/vendor/assets/stylesheets/xterm/xterm.css @@ -142,7 +142,7 @@ * Determine default colors for xterm.js */ .terminal .xterm-bold { - font-weight: bold; + font-weight: 600; } .terminal .xterm-underline { -- cgit v1.2.1 From a919188ccf90a923c12992c4070c6f680627fb48 Mon Sep 17 00:00:00 2001 From: Fabio Busatto Date: Thu, 24 Aug 2017 14:40:38 +0000 Subject: Update README.md --- doc/ci/variables/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index e55a92dbb71..234dc530db0 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -86,6 +86,11 @@ To follow conventions of naming across GitLab, and to futher move away from the `build` term and toward `job` CI variables have been renamed for the 9.0 release. +>**Note:** +Starting with GitLab 9.0, we have deprecated the `$CI_BUILD_*` variables. **You are +strongly advised to use the new variables as we will remove the old ones in +future GitLab releases.** + | 8.x name | 9.0+ name | | --------------------- |------------------------ | | `CI_BUILD_ID` | `CI_JOB_ID` | -- cgit v1.2.1 From f8865e9c1303be7302306bea9dd1057bf3b3f608 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 26 Jul 2017 11:57:05 +0200 Subject: Define ldap methods at runtime This avoids loading the `OmniAuthCallbacksController` at boot time so it doesn't mess up the `before_action`-chain --- app/controllers/omniauth_callbacks_controller.rb | 8 ++++++++ app/controllers/sessions_controller.rb | 8 -------- config/initializers/omniauth.rb | 6 ------ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 7444826a5d1..9612b8d8514 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -10,6 +10,14 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end end + if Gitlab::LDAP::Config.enabled? + Gitlab::LDAP::Config.available_servers.each do |server| + define_method server['provider_name'] do + ldap + end + end + end + # Extend the standard message generation to accept our custom exception def failure_message exception = env["omniauth.error"] diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 9e743685d60..be6491d042c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -5,14 +5,6 @@ class SessionsController < Devise::SessionsController skip_before_action :check_two_factor_requirement, only: [:destroy] - # Explicitly call protect from forgery before anything else. Otherwise the - # CSFR-token might be cleared before authentication is done. This was the case - # when LDAP was enabled and the `OmniauthCallbacksController` is loaded - # - # *Note:* `prepend: true` is the default for rails4, but this will be changed - # to `prepend: false` in rails5. - protect_from_forgery prepend: true, with: :exception - prepend_before_action :check_initial_setup, only: [:new] prepend_before_action :authenticate_with_two_factor, if: :two_factor_enabled?, only: [:create] diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 56c279ffcf4..fddb018e948 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -6,12 +6,6 @@ if Gitlab::LDAP::Config.enabled? const_set(server['provider_class'], Class.new(LDAP)) end end - - OmniauthCallbacksController.class_eval do - Gitlab::LDAP::Config.available_servers.each do |server| - alias_method server['provider_name'], :ldap - end - end end OmniAuth.config.full_host = Settings.gitlab['base_url'] -- cgit v1.2.1 From 8ecd9b574f82ffb04aa789d2ab1979a0af5dd6f4 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Thu, 24 Aug 2017 18:07:45 +0200 Subject: Remove leftover API helper for removed CI API --- spec/support/api_helpers.rb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index ac0aaa524b7..01aca74274c 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -45,18 +45,4 @@ module ApiHelpers oauth_access_token: oauth_access_token ) end - - def ci_api(path, user = nil) - "/ci/api/v1/#{path}" + - - # Normalize query string - (path.index('?') ? '' : '?') + - - # Append private_token if given a User object - if user.respond_to?(:private_token) - "&private_token=#{user.private_token}" - else - '' - end - end end -- cgit v1.2.1 From 5af797d4a935faf0c772b9ce5c8c24b736beedd7 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 24 Aug 2017 18:32:49 +0200 Subject: Re-allow appearances.description_html to be NULL This column isn't always set (e.g. when upgrading from older instances) and technically it could be NULL (e.g. when flushing the cache). Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36919 --- .../revert-appearances-description-html-not-null.yml | 5 +++++ .../20170809142252_cleanup_appearances_schema.rb | 2 +- ...24162758_allow_appearances_description_html_null.rb | 18 ++++++++++++++++++ db/schema.rb | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/revert-appearances-description-html-not-null.yml create mode 100644 db/migrate/20170824162758_allow_appearances_description_html_null.rb diff --git a/changelogs/unreleased/revert-appearances-description-html-not-null.yml b/changelogs/unreleased/revert-appearances-description-html-not-null.yml new file mode 100644 index 00000000000..4e3c39cb5fd --- /dev/null +++ b/changelogs/unreleased/revert-appearances-description-html-not-null.yml @@ -0,0 +1,5 @@ +--- +title: Re-allow appearances.description_html to be NULL +merge_request: +author: +type: fixed diff --git a/db/migrate/20170809142252_cleanup_appearances_schema.rb b/db/migrate/20170809142252_cleanup_appearances_schema.rb index 90d12925ba2..acf45060114 100644 --- a/db/migrate/20170809142252_cleanup_appearances_schema.rb +++ b/db/migrate/20170809142252_cleanup_appearances_schema.rb @@ -7,7 +7,7 @@ class CleanupAppearancesSchema < ActiveRecord::Migration # Set this constant to true if this migration requires downtime. DOWNTIME = false - NOT_NULL_COLUMNS = %i[title description description_html created_at updated_at] + NOT_NULL_COLUMNS = %i[title description created_at updated_at] TIME_COLUMNS = %i[created_at updated_at] diff --git a/db/migrate/20170824162758_allow_appearances_description_html_null.rb b/db/migrate/20170824162758_allow_appearances_description_html_null.rb new file mode 100644 index 00000000000..d7f481ee894 --- /dev/null +++ b/db/migrate/20170824162758_allow_appearances_description_html_null.rb @@ -0,0 +1,18 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AllowAppearancesDescriptionHtmlNull < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + def up + change_column_null :appearances, :description_html, true + end + + def down + # This column should not have a `NOT NULL` class, so we don't want to revert + # back to re-adding it. + end +end diff --git a/db/schema.rb b/db/schema.rb index cd488630237..0f4b0c0c3b3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170820100558) do +ActiveRecord::Schema.define(version: 20170824162758) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -34,7 +34,7 @@ ActiveRecord::Schema.define(version: 20170820100558) do t.string "logo" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.text "description_html", null: false + t.text "description_html" t.integer "cached_markdown_version" end -- cgit v1.2.1 From 5904fea900c3ea6255b2c7aed7beb00ba91a6e28 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 24 Aug 2017 13:05:16 -0400 Subject: Add `:nested_groups` metadata to `Groups::NestedCreateService` specs --- spec/services/groups/nested_create_service_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/services/groups/nested_create_service_spec.rb b/spec/services/groups/nested_create_service_spec.rb index c1526456bac..6d11edb5842 100644 --- a/spec/services/groups/nested_create_service_spec.rb +++ b/spec/services/groups/nested_create_service_spec.rb @@ -14,14 +14,14 @@ describe Groups::NestedCreateService do expect(service.execute).to eq(child) end - it 'reuses a parent if it already existed' do + it 'reuses a parent if it already existed', :nested_groups do parent = create(:group, path: 'a-group') parent.add_owner(user) expect(service.execute.parent).to eq(parent) end - it 'creates group and subgroup in the database' do + it 'creates group and subgroup in the database', :nested_groups do service.execute parent = Group.find_by_full_path('a-group') -- cgit v1.2.1 From 9f7f78570f4dba345a71b6d14a08d0430fad8304 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Thu, 24 Aug 2017 11:45:37 -0700 Subject: Reenable MySQL tests on all branches To protect master from surprise failures, as long as we continue to support MySQL. --- .gitlab-ci.yml | 15 --------------- doc/development/testing.md | 5 +---- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f356a07576..ab9627d4ab7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,19 +68,6 @@ stages: - mysql:latest - redis:alpine -.only-if-want-mysql: &only-if-want-mysql - only: - - /mysql/ - - /-stable/ - - master@gitlab-org/gitlab-ce - - master@gitlab-org/gitlab-ee - - master@gitlab/gitlabhq - - master@gitlab/gitlab-ee - - tags@gitlab-org/gitlab-ce - - tags@gitlab-org/gitlab-ee - - tags@gitlab/gitlabhq - - tags@gitlab/gitlab-ee - # Skip all jobs except the ones that begin with 'docs/'. # Used for commits including ONLY documentation changes. # https://docs.gitlab.com/ce/development/writing_documentation.html#testing @@ -124,7 +111,6 @@ stages: .rspec-metadata-mysql: &rspec-metadata-mysql <<: *rspec-metadata <<: *use-mysql - <<: *only-if-want-mysql <<: *except-docs .spinach-metadata: &spinach-metadata @@ -156,7 +142,6 @@ stages: .spinach-metadata-mysql: &spinach-metadata-mysql <<: *spinach-metadata <<: *use-mysql - <<: *only-if-want-mysql <<: *except-docs .only-canonical-masters: &only-canonical-masters diff --git a/doc/development/testing.md b/doc/development/testing.md index efd56484b12..83269303005 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -529,10 +529,7 @@ slowest test files and try to improve them. ## CI setup -- On CE, the test suite only runs against PostgreSQL by default. We additionally - run the suite against MySQL for tags, `master`, and any branch that includes - `mysql` in the name. -- On EE, the test suite always runs both PostgreSQL and MySQL. +- On CE and EE, the test suite runs both PostgreSQL and MySQL. - Rails logging to `log/test.log` is disabled by default in CI [for performance reasons][logging]. To override this setting, provide the `RAILS_ENABLE_TEST_LOG` environment variable. -- cgit v1.2.1 From 38bb92197dcb67df917bb9793be5a1a48611c047 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 24 Aug 2017 12:24:58 -0700 Subject: Enable 5 lines of Sidekiq backtrace lines to aid in debugging Customers often have Sidekiq jobs that failed without much context. Without Sentry, there's no way to tell where these exceptions were hit. Adding in additional lines adds a bit more Redis storage overhead. This commit adds in backtrace logging for workers that delete groups/projects and import/export projects. Closes #27626 --- app/workers/concerns/exception_backtrace.rb | 8 ++++++++ app/workers/group_destroy_worker.rb | 1 + app/workers/namespaceless_project_destroy_worker.rb | 1 + app/workers/project_destroy_worker.rb | 1 + app/workers/project_export_worker.rb | 1 + app/workers/repository_import_worker.rb | 1 + 6 files changed, 13 insertions(+) create mode 100644 app/workers/concerns/exception_backtrace.rb diff --git a/app/workers/concerns/exception_backtrace.rb b/app/workers/concerns/exception_backtrace.rb new file mode 100644 index 00000000000..e3ecdfe2502 --- /dev/null +++ b/app/workers/concerns/exception_backtrace.rb @@ -0,0 +1,8 @@ +# Concern for enabling a few lines of exception backtraces in Sidekiq +module BuildQueue + extend ActiveSupport::Concern + + included do + sidekiq_options backtrace: 5 + end +end diff --git a/app/workers/group_destroy_worker.rb b/app/workers/group_destroy_worker.rb index 07e82767b06..bd8e212e928 100644 --- a/app/workers/group_destroy_worker.rb +++ b/app/workers/group_destroy_worker.rb @@ -1,6 +1,7 @@ class GroupDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def perform(group_id, user_id) begin diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb index 1cfb0be759e..f1cd1769421 100644 --- a/app/workers/namespaceless_project_destroy_worker.rb +++ b/app/workers/namespaceless_project_destroy_worker.rb @@ -7,6 +7,7 @@ class NamespacelessProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def self.bulk_perform_async(args_list) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list) diff --git a/app/workers/project_destroy_worker.rb b/app/workers/project_destroy_worker.rb index a9188b78460..3be7e686609 100644 --- a/app/workers/project_destroy_worker.rb +++ b/app/workers/project_destroy_worker.rb @@ -1,6 +1,7 @@ class ProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def perform(project_id, user_id, params) project = Project.find(project_id) diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb index 6009aa1b191..f13ac9e5db2 100644 --- a/app/workers/project_export_worker.rb +++ b/app/workers/project_export_worker.rb @@ -1,6 +1,7 @@ class ProjectExportWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace sidekiq_options retry: 3 diff --git a/app/workers/repository_import_worker.rb b/app/workers/repository_import_worker.rb index 2c2d1e8b91f..00a021abbdc 100644 --- a/app/workers/repository_import_worker.rb +++ b/app/workers/repository_import_worker.rb @@ -3,6 +3,7 @@ class RepositoryImportWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace sidekiq_options status_expiration: StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION -- cgit v1.2.1 From 5167a76f065cda793df6d188fe472da8db0ac4ae Mon Sep 17 00:00:00 2001 From: Jacopo Date: Sun, 20 Aug 2017 11:12:23 +0200 Subject: Authorizations regarding OAuth - style confirmation Changed the styling of OAuth authorization page in order to follow the styling structure described in #28849. --- app/assets/stylesheets/framework/modal.scss | 8 +++ app/views/doorkeeper/authorizations/new.html.haml | 78 ++++++++++++---------- .../unreleased/35721-auth-style-confirmation.yml | 5 ++ 3 files changed, 54 insertions(+), 37 deletions(-) create mode 100644 changelogs/unreleased/35721-auth-style-confirmation.yml diff --git a/app/assets/stylesheets/framework/modal.scss b/app/assets/stylesheets/framework/modal.scss index a28f54936be..2a16b6317fa 100644 --- a/app/assets/stylesheets/framework/modal.scss +++ b/app/assets/stylesheets/framework/modal.scss @@ -16,6 +16,14 @@ body.modal-open { overflow: hidden; } +.modal-no-backdrop { + @extend .modal-dialog; + + .modal-content { + box-shadow: none; + } +} + @media (min-width: $screen-md-min) { .modal-dialog { width: 860px; diff --git a/app/views/doorkeeper/authorizations/new.html.haml b/app/views/doorkeeper/authorizations/new.html.haml index 82aa51f9778..8ba88906714 100644 --- a/app/views/doorkeeper/authorizations/new.html.haml +++ b/app/views/doorkeeper/authorizations/new.html.haml @@ -1,39 +1,43 @@ -%h3.page-title Authorization required %main{ :role => "main" } - %p.h4 - Authorize - %strong.text-info= @pre_auth.client.name - to use your account? + .modal-no-backdrop + .modal-content + .modal-header + %h3.page-title + Authorize + = link_to @pre_auth.client.name, @pre_auth.redirect_uri, target: '_blank', rel: 'noopener noreferrer' + to use your account? - - if current_user.admin? - .text-warning.prepend-top-20 - %p - = icon("exclamation-triangle fw") - You are an admin, which means granting access to - %strong= @pre_auth.client.name - will allow them to interact with GitLab as an admin as well. Proceed with caution. - - - if @pre_auth.scopes - #oauth-permissions - %p This application will be able to: - %ul.text-info - - @pre_auth.scopes.each do |scope| - %li= t scope, scope: [:doorkeeper, :scopes] - %hr/ - .actions - = form_tag oauth_authorization_path, method: :post do - = hidden_field_tag :client_id, @pre_auth.client.uid - = hidden_field_tag :redirect_uri, @pre_auth.redirect_uri - = hidden_field_tag :state, @pre_auth.state - = hidden_field_tag :response_type, @pre_auth.response_type - = hidden_field_tag :scope, @pre_auth.scope - = hidden_field_tag :nonce, @pre_auth.nonce - = submit_tag "Authorize", class: "btn btn-success wide pull-left" - = form_tag oauth_authorization_path, method: :delete do - = hidden_field_tag :client_id, @pre_auth.client.uid - = hidden_field_tag :redirect_uri, @pre_auth.redirect_uri - = hidden_field_tag :state, @pre_auth.state - = hidden_field_tag :response_type, @pre_auth.response_type - = hidden_field_tag :scope, @pre_auth.scope - = hidden_field_tag :nonce, @pre_auth.nonce - = submit_tag "Deny", class: "btn btn-danger prepend-left-10" + .modal-body + - if current_user.admin? + .text-warning + %p + = icon("exclamation-triangle fw") + You are an admin, which means granting access to + %strong= @pre_auth.client.name + will allow them to interact with GitLab as an admin as well. Proceed with caution. + %p + You are about to authorize + = link_to @pre_auth.client.name, @pre_auth.redirect_uri, target: '_blank', rel: 'noopener noreferrer' + to use your account. + - if @pre_auth.scopes + This application will be able to: + %ul + - @pre_auth.scopes.each do |scope| + %li= t scope, scope: [:doorkeeper, :scopes] + .form-actions.text-right + = form_tag oauth_authorization_path, method: :delete, class: 'inline' do + = hidden_field_tag :client_id, @pre_auth.client.uid + = hidden_field_tag :redirect_uri, @pre_auth.redirect_uri + = hidden_field_tag :state, @pre_auth.state + = hidden_field_tag :response_type, @pre_auth.response_type + = hidden_field_tag :scope, @pre_auth.scope + = hidden_field_tag :nonce, @pre_auth.nonce + = submit_tag "Deny", class: "btn btn-danger" + = form_tag oauth_authorization_path, method: :post, class: 'inline' do + = hidden_field_tag :client_id, @pre_auth.client.uid + = hidden_field_tag :redirect_uri, @pre_auth.redirect_uri + = hidden_field_tag :state, @pre_auth.state + = hidden_field_tag :response_type, @pre_auth.response_type + = hidden_field_tag :scope, @pre_auth.scope + = hidden_field_tag :nonce, @pre_auth.nonce + = submit_tag "Authorize", class: "btn btn-success prepend-left-10" diff --git a/changelogs/unreleased/35721-auth-style-confirmation.yml b/changelogs/unreleased/35721-auth-style-confirmation.yml new file mode 100644 index 00000000000..9963f76e845 --- /dev/null +++ b/changelogs/unreleased/35721-auth-style-confirmation.yml @@ -0,0 +1,5 @@ +--- +title: restyling of OAuth authorization confirmation +merge_request: +author: Jacopo Beschi @jacopo-beschi +type: changed -- cgit v1.2.1 From 986b80d0d13f3e95ed02fd721631bebcd94648c1 Mon Sep 17 00:00:00 2001 From: Marcia Ramos Date: Thu, 24 Aug 2017 21:31:39 +0000 Subject: New doc: how to install GitLab on Azure --- doc/articles/index.md | 3 +- doc/install/README.md | 10 +- .../azure/img/azure-add-inbound-sec-rule-http.png | Bin 0 -> 16927 bytes .../azure/img/azure-add-inbound-sec-rule-ssh.png | Bin 0 -> 16817 bytes ...zure-create-virtual-machine-basics-password.png | Bin 0 -> 24862 bytes .../img/azure-create-virtual-machine-basics.png | Bin 0 -> 22925 bytes .../azure-create-virtual-machine-deployment.png | Bin 0 -> 23707 bytes .../img/azure-create-virtual-machine-purchase.png | Bin 0 -> 43698 bytes .../img/azure-create-virtual-machine-settings.png | Bin 0 -> 25686 bytes .../img/azure-create-virtual-machine-size.png | Bin 0 -> 33322 bytes .../azure/img/azure-dashboard-highlight-nsg.png | Bin 0 -> 34248 bytes .../img/azure-dashboard-running-resources.png | Bin 0 -> 34306 bytes doc/install/azure/img/azure-dashboard.png | Bin 0 -> 36396 bytes .../azure/img/azure-inbound-sec-rules-list.png | Bin 0 -> 24592 bytes doc/install/azure/img/azure-new-gitlab-ce.png | Bin 0 -> 22701 bytes doc/install/azure/img/azure-new-search-gitlab.png | Bin 0 -> 19034 bytes .../azure-nsg-inbound-sec-rules-add-highlight.png | Bin 0 -> 22583 bytes .../img/azure-nsg-inbound-sec-rules-highlight.png | Bin 0 -> 31485 bytes doc/install/azure/img/azure-vm-domain-name.png | Bin 0 -> 23802 bytes .../azure/img/azure-vm-management-public-ip.png | Bin 0 -> 34991 bytes ...e-vm-management-settings-network-interfaces.png | Bin 0 -> 35849 bytes doc/install/azure/img/azure-vm-management.png | Bin 0 -> 35363 bytes doc/install/azure/img/gitlab-admin-area-9.4.0.png | Bin 0 -> 35249 bytes doc/install/azure/img/gitlab-admin-area.png | Bin 0 -> 29333 bytes doc/install/azure/img/gitlab-change-password.png | Bin 0 -> 24404 bytes doc/install/azure/img/gitlab-home.png | Bin 0 -> 26302 bytes doc/install/azure/img/gitlab-login.png | Bin 0 -> 24656 bytes doc/install/azure/img/gitlab-new-project.png | Bin 0 -> 34164 bytes .../azure/img/gitlab-project-home-empty.png | Bin 0 -> 28375 bytes .../azure/img/gitlab-project-home-instructions.png | Bin 0 -> 31738 bytes .../azure/img/gitlab-ssh-update-in-progress.png | Bin 0 -> 32799 bytes doc/install/azure/index.md | 439 +++++++++++++++++++++ 32 files changed, 450 insertions(+), 2 deletions(-) create mode 100644 doc/install/azure/img/azure-add-inbound-sec-rule-http.png create mode 100644 doc/install/azure/img/azure-add-inbound-sec-rule-ssh.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-basics-password.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-basics.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-deployment.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-purchase.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-settings.png create mode 100644 doc/install/azure/img/azure-create-virtual-machine-size.png create mode 100644 doc/install/azure/img/azure-dashboard-highlight-nsg.png create mode 100644 doc/install/azure/img/azure-dashboard-running-resources.png create mode 100644 doc/install/azure/img/azure-dashboard.png create mode 100644 doc/install/azure/img/azure-inbound-sec-rules-list.png create mode 100644 doc/install/azure/img/azure-new-gitlab-ce.png create mode 100644 doc/install/azure/img/azure-new-search-gitlab.png create mode 100644 doc/install/azure/img/azure-nsg-inbound-sec-rules-add-highlight.png create mode 100644 doc/install/azure/img/azure-nsg-inbound-sec-rules-highlight.png create mode 100644 doc/install/azure/img/azure-vm-domain-name.png create mode 100644 doc/install/azure/img/azure-vm-management-public-ip.png create mode 100644 doc/install/azure/img/azure-vm-management-settings-network-interfaces.png create mode 100644 doc/install/azure/img/azure-vm-management.png create mode 100644 doc/install/azure/img/gitlab-admin-area-9.4.0.png create mode 100644 doc/install/azure/img/gitlab-admin-area.png create mode 100644 doc/install/azure/img/gitlab-change-password.png create mode 100644 doc/install/azure/img/gitlab-home.png create mode 100644 doc/install/azure/img/gitlab-login.png create mode 100644 doc/install/azure/img/gitlab-new-project.png create mode 100644 doc/install/azure/img/gitlab-project-home-empty.png create mode 100644 doc/install/azure/img/gitlab-project-home-instructions.png create mode 100644 doc/install/azure/img/gitlab-ssh-update-in-progress.png create mode 100644 doc/install/azure/index.md diff --git a/doc/articles/index.md b/doc/articles/index.md index 1aa65504852..4b0c85b9272 100644 --- a/doc/articles/index.md +++ b/doc/articles/index.md @@ -76,7 +76,8 @@ Learn how to deploy a static website with [GitLab Pages](../user/project/pages/i ## Install and maintain GitLab -Install, upgrade, integrate, migrate to GitLab: +[Admin](../README.md#administrator-documentation), [install](../install/README.md), +upgrade, integrate, migrate to GitLab: | Article title | Category | Publishing date | | :------------ | :------: | --------------: | diff --git a/doc/install/README.md b/doc/install/README.md index bc831a37735..1d510cb29c3 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -18,9 +18,17 @@ the hardware requirements. Useful for unsupported systems like *BSD. For an overview of the directory structure, read the [structure documentation](structure.md). - [Docker](https://docs.gitlab.com/omnibus/docker/) - Install GitLab using Docker. + +## Install GitLab on cloud providers + - [Installing in Kubernetes](kubernetes/index.md) - Install GitLab into a Kubernetes Cluster using our official Helm Chart Repository. -- Testing only! [DigitalOcean and Docker Machine](digitaloceandocker.md) - +- [Install GitLab on OpenShift](../articles/openshift_and_gitlab/index.md) +- [Install GitLab on DC/OS](https://mesosphere.com/blog/gitlab-dcos/) via [GitLab-Mesosphere integration](https://about.gitlab.com/2016/09/16/announcing-gitlab-and-mesosphere/) +- [Install GitLab on Azure](azure/index.md) +- [Install GitLab on Google Cloud Platform](google_cloud_platform/index.md) +- [Install on AWS](https://about.gitlab.com/aws/) +- _Testing only!_ [DigitalOcean and Docker Machine](digitaloceandocker.md) - Quickly test any version of GitLab on DigitalOcean using Docker Machine. ## Database diff --git a/doc/install/azure/img/azure-add-inbound-sec-rule-http.png b/doc/install/azure/img/azure-add-inbound-sec-rule-http.png new file mode 100644 index 00000000000..abf500cb63a Binary files /dev/null and b/doc/install/azure/img/azure-add-inbound-sec-rule-http.png differ diff --git a/doc/install/azure/img/azure-add-inbound-sec-rule-ssh.png b/doc/install/azure/img/azure-add-inbound-sec-rule-ssh.png new file mode 100644 index 00000000000..f7a8a04dfa7 Binary files /dev/null and b/doc/install/azure/img/azure-add-inbound-sec-rule-ssh.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-basics-password.png b/doc/install/azure/img/azure-create-virtual-machine-basics-password.png new file mode 100644 index 00000000000..80bf39ecb48 Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-basics-password.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-basics.png b/doc/install/azure/img/azure-create-virtual-machine-basics.png new file mode 100644 index 00000000000..229c073fe17 Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-basics.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-deployment.png b/doc/install/azure/img/azure-create-virtual-machine-deployment.png new file mode 100644 index 00000000000..5cfdd973a58 Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-deployment.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-purchase.png b/doc/install/azure/img/azure-create-virtual-machine-purchase.png new file mode 100644 index 00000000000..f4de62299f1 Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-purchase.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-settings.png b/doc/install/azure/img/azure-create-virtual-machine-settings.png new file mode 100644 index 00000000000..20097921660 Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-settings.png differ diff --git a/doc/install/azure/img/azure-create-virtual-machine-size.png b/doc/install/azure/img/azure-create-virtual-machine-size.png new file mode 100644 index 00000000000..a408394151f Binary files /dev/null and b/doc/install/azure/img/azure-create-virtual-machine-size.png differ diff --git a/doc/install/azure/img/azure-dashboard-highlight-nsg.png b/doc/install/azure/img/azure-dashboard-highlight-nsg.png new file mode 100644 index 00000000000..025efd33977 Binary files /dev/null and b/doc/install/azure/img/azure-dashboard-highlight-nsg.png differ diff --git a/doc/install/azure/img/azure-dashboard-running-resources.png b/doc/install/azure/img/azure-dashboard-running-resources.png new file mode 100644 index 00000000000..7e661a6aa65 Binary files /dev/null and b/doc/install/azure/img/azure-dashboard-running-resources.png differ diff --git a/doc/install/azure/img/azure-dashboard.png b/doc/install/azure/img/azure-dashboard.png new file mode 100644 index 00000000000..375ec8622b8 Binary files /dev/null and b/doc/install/azure/img/azure-dashboard.png differ diff --git a/doc/install/azure/img/azure-inbound-sec-rules-list.png b/doc/install/azure/img/azure-inbound-sec-rules-list.png new file mode 100644 index 00000000000..1667671b21d Binary files /dev/null and b/doc/install/azure/img/azure-inbound-sec-rules-list.png differ diff --git a/doc/install/azure/img/azure-new-gitlab-ce.png b/doc/install/azure/img/azure-new-gitlab-ce.png new file mode 100644 index 00000000000..88949f69a94 Binary files /dev/null and b/doc/install/azure/img/azure-new-gitlab-ce.png differ diff --git a/doc/install/azure/img/azure-new-search-gitlab.png b/doc/install/azure/img/azure-new-search-gitlab.png new file mode 100644 index 00000000000..f96ed577d62 Binary files /dev/null and b/doc/install/azure/img/azure-new-search-gitlab.png differ diff --git a/doc/install/azure/img/azure-nsg-inbound-sec-rules-add-highlight.png b/doc/install/azure/img/azure-nsg-inbound-sec-rules-add-highlight.png new file mode 100644 index 00000000000..c9a08b87ce6 Binary files /dev/null and b/doc/install/azure/img/azure-nsg-inbound-sec-rules-add-highlight.png differ diff --git a/doc/install/azure/img/azure-nsg-inbound-sec-rules-highlight.png b/doc/install/azure/img/azure-nsg-inbound-sec-rules-highlight.png new file mode 100644 index 00000000000..6423625ca8b Binary files /dev/null and b/doc/install/azure/img/azure-nsg-inbound-sec-rules-highlight.png differ diff --git a/doc/install/azure/img/azure-vm-domain-name.png b/doc/install/azure/img/azure-vm-domain-name.png new file mode 100644 index 00000000000..01c03004b24 Binary files /dev/null and b/doc/install/azure/img/azure-vm-domain-name.png differ diff --git a/doc/install/azure/img/azure-vm-management-public-ip.png b/doc/install/azure/img/azure-vm-management-public-ip.png new file mode 100644 index 00000000000..ef313641db8 Binary files /dev/null and b/doc/install/azure/img/azure-vm-management-public-ip.png differ diff --git a/doc/install/azure/img/azure-vm-management-settings-network-interfaces.png b/doc/install/azure/img/azure-vm-management-settings-network-interfaces.png new file mode 100644 index 00000000000..4ff10718059 Binary files /dev/null and b/doc/install/azure/img/azure-vm-management-settings-network-interfaces.png differ diff --git a/doc/install/azure/img/azure-vm-management.png b/doc/install/azure/img/azure-vm-management.png new file mode 100644 index 00000000000..a0e0067258c Binary files /dev/null and b/doc/install/azure/img/azure-vm-management.png differ diff --git a/doc/install/azure/img/gitlab-admin-area-9.4.0.png b/doc/install/azure/img/gitlab-admin-area-9.4.0.png new file mode 100644 index 00000000000..b7ee4598731 Binary files /dev/null and b/doc/install/azure/img/gitlab-admin-area-9.4.0.png differ diff --git a/doc/install/azure/img/gitlab-admin-area.png b/doc/install/azure/img/gitlab-admin-area.png new file mode 100644 index 00000000000..028f0b0a0eb Binary files /dev/null and b/doc/install/azure/img/gitlab-admin-area.png differ diff --git a/doc/install/azure/img/gitlab-change-password.png b/doc/install/azure/img/gitlab-change-password.png new file mode 100644 index 00000000000..7350d604d56 Binary files /dev/null and b/doc/install/azure/img/gitlab-change-password.png differ diff --git a/doc/install/azure/img/gitlab-home.png b/doc/install/azure/img/gitlab-home.png new file mode 100644 index 00000000000..7c935805ea2 Binary files /dev/null and b/doc/install/azure/img/gitlab-home.png differ diff --git a/doc/install/azure/img/gitlab-login.png b/doc/install/azure/img/gitlab-login.png new file mode 100644 index 00000000000..95fe5aec1e0 Binary files /dev/null and b/doc/install/azure/img/gitlab-login.png differ diff --git a/doc/install/azure/img/gitlab-new-project.png b/doc/install/azure/img/gitlab-new-project.png new file mode 100644 index 00000000000..3b6b9a81682 Binary files /dev/null and b/doc/install/azure/img/gitlab-new-project.png differ diff --git a/doc/install/azure/img/gitlab-project-home-empty.png b/doc/install/azure/img/gitlab-project-home-empty.png new file mode 100644 index 00000000000..54d0b36a251 Binary files /dev/null and b/doc/install/azure/img/gitlab-project-home-empty.png differ diff --git a/doc/install/azure/img/gitlab-project-home-instructions.png b/doc/install/azure/img/gitlab-project-home-instructions.png new file mode 100644 index 00000000000..fd040d33e95 Binary files /dev/null and b/doc/install/azure/img/gitlab-project-home-instructions.png differ diff --git a/doc/install/azure/img/gitlab-ssh-update-in-progress.png b/doc/install/azure/img/gitlab-ssh-update-in-progress.png new file mode 100644 index 00000000000..8a686ebde26 Binary files /dev/null and b/doc/install/azure/img/gitlab-ssh-update-in-progress.png differ diff --git a/doc/install/azure/index.md b/doc/install/azure/index.md new file mode 100644 index 00000000000..9842d99ed02 --- /dev/null +++ b/doc/install/azure/index.md @@ -0,0 +1,439 @@ +# Install GitLab on Microsoft Azure + +> _This article was originally written by Dave Wentzel and [published on the GitLab Blog][Original-Blog-Post]._ +> +> _Ported to the GitLab documentation and updated on 2017-08-24 by [Ian Scorer](https://gitlab.com/iscorer)._ + +Azure is Microsoft's business cloud and GitLab is a pre-configured offering on the Azure Marketplace. +Hopefully, you aren't surprised to hear that Microsoft and Azure have embraced open source software +like Ubuntu, Red Hat Enterprise Linux, and of course - GitLab! This means that you can spin up a +pre-configured GitLab VM and have your very own private GitLab up and running in around 30 minutes. +Let's get started. + +### Getting started + +First, you'll need an account on Azure. There are three ways to do this: + +- If your company (or you) already has an account, then you are ready to go! +- You can also open your own Azure account for free. _At time of writing_, you get $200 +of credit to spend on Azure services for 30 days. You can use this credit to try out paid Azure +services, exploring Microsoft's cloud for free. Even after the first 30 days, you never have to pay +anything unless you decide to transition to paid services with a Pay-As-You-Go Azure subscription. +This is a great way to try out Azure and cloud computing, and you can +[read more in their comprehensive FAQ][Azure-Free-Account-FAQ]. +- If you have an MSDN subscription, you can activate your Azure subscriber benefits. Your MSDN +subscription gives you recurring Azure credits every month, so why not put those credits to use and +try out GitLab right now? + +### Working with Azure + +Once you have an Azure account, you can get started. Login to Azure using +[portal.azure.com](https://portal.azure.com) and the first thing you will see is the Dashboard: + +![Azure Dashboard](img/azure-dashboard.png) + +The Dashboard gives you a quick overview of Azure resources, and from here you you can build VMs, +create SQL Databases, author websites, and perform lots of other cloud tasks. + +### Create New VM + +The [Azure Marketplace][Azure-Marketplace] is an online store for pre-configured applications and +services which have been optimized for the cloud by software vendors like GitLab, and both +the [Community Edition ("CE")][CE] and the [Enterprise Edition ("EE")][EE] versions of GitLab are +available on the Azure Marketplace as pre-configured solutions. + +To begin creating a new GitLab VM, click on the **+ New** icon, type "GitLab" into the search +box, and then click the **"GitLab Community Edition"** search result: + +![Azure - New - Search for 'GitLab'](img/azure-new-search-gitlab.png) + +A new "blade" window will pop-out, where you can read more about the **"GitLab Community Edition"** +offering which is freely available under the MIT Expat License: + +![Azure - New - Select 'GitLab Community Edition'](img/azure-new-gitlab-ce.png) + +Click **"Create"** and you will be presented with the "Create virtual machine" blade: + +![Azure - Create Virtual Machine - Basics](img/azure-create-virtual-machine-basics.png) + +### Basics + +The first items we need to configure are the basic settings of the underlying virtual machine: + +1. Enter a `Name` for the VM - e.g. **"GitLab-CE"** +1. Select a `VM disk type` - either **HDD** _(slower, lower cost)_ or **SSD** _(faster, higher cost)_ +1. Enter a `User name` - e.g. **"gitlab-admin"** +1. Select an `Authentication type`, either **SSH public key** or **Password**: + + >**Note:** if you're unsure which authentication type to use, select **Password** + + 1. If you chose **SSH public key** - enter your `SSH public key` into the field provided + _(read the [SSH documentation][GitLab-Docs-SSH] to learn more about how to setup SSH + public keys)_ + 1. If you chose **Password** - enter the password you wish to use _(this is the password that you + will use later in this tutorial to [SSH] into the VM, so make sure it's a strong password/passphrase)_ +1. Choose the appropriate `Subscription` tier for your Azure account +1. Choose an existing `Resource Group` or create a new one - e.g. **"GitLab-CE-Azure"** +>**Note:** a "Resource group" is a way to group related resources together for easier administration. +We chose "GitLab-CE-Azure", but your resource group can have the same name as your VM. +1. Choose a `Location` - if you're unsure, select the default location + +Here are the settings we've used: + +![Azure - Create Virtual Machine - Basics Completed](img/azure-create-virtual-machine-basics-password.png) + +Check the settings you have entered, and then click **"OK"** when you're ready to proceed. + +### Size + +Next, you need to choose the size of your VM - selecting features such as the number of CPU cores, +the amount of RAM, the size of storage (and its speed), etc. + +>**Note:** in common with other cloud vendors, Azure operates a resource/usage pricing model, i.e. +the more resources your VM consumes the more it will cost you to run, so make your selection +carefully. You'll see that Azure provides an _estimated_ monthly cost beneath each VM Size to help +guide your selection. + +The default size - the lowest cost **"DS1_V2 Standard"** VM - meets the minimum system requirements +to run a small GitLab environment for testing and evaluation purposes, and so we're going to go +ahead and select this one, but please choose the size which best meets your own requirements: + +![Azure - Create Virtual Machine - Size](img/azure-create-virtual-machine-size.png) + +>**Note:** be aware that whilst your VM is active (known as "allocated"), it will incur +"compute charges" which, ultimately, you will be billed for. So, even if you're using the +free trial credits, you'll likely want to learn +[how to properly shutdown an Azure VM to save money][Azure-Properly-Shutdown-VM]. + +Go ahead and click your chosen size, then click **"Select"** when you're ready to proceed to the +next step. + +### Settings + +On the next blade, you're asked to configure the Storage, Network and Extension settings. +We've gone with the default settings as they're sufficient for test-driving GitLab, but please +choose the settings which best meet your own requirements: + +![Azure - Create Virtual Machine - Settings](img/azure-create-virtual-machine-settings.png) + +Review the settings and then click **"OK"** when you're ready to proceed to the last step. + +### Purchase + +The Purchase page is the last step and here you will be presented with the price per hour for your +new VM. You'll be billed only for the VM itself (e.g. "Standard DS1 v2") because the +**"GitLab Community Edition"** marketplace solution is free to use at 0 USD/hr: + +![Azure - Create Virtual Machine - Purchase](img/azure-create-virtual-machine-purchase.png) + +>**Note:** at this stage, you can review and modify the any of the settings you have made during all +previous steps, just click on any of the four steps to re-open them. + +When you have read and agreed to the terms of use and are ready to proceed, click **"Purchase"**. + +### Deployment + +At this point, Azure will begin deploying your new VM. The deployment process will take a few +minutes to complete, with progress displayed on the **"Deployment"** blade: + +![Azure - Create Virtual Machine - Deployment](img/azure-create-virtual-machine-deployment.png) + +Once the deployment process is complete, the new VM and its associated resources will be displayed +on the Azure Dashboard (you may need to refresh the page): + +![Azure - Dashboard - All resources](img/azure-dashboard-running-resources.png) + +The new VM can also be accessed by clicking the `All resources` or `Virtual machines` icons in the +Azure Portal sidebar navigation menu. + +### Setup a domain name + +The VM will have a public IP address (static by default), but Azure allows us to assign a friendly +DNS name to the VM, so let's go ahead and do that. + +From the Dashboard, click on the **"GitLab-CE"** tile to open the management blade for the new VM. +The public IP address that the VM uses is shown in the 'Essentials' section: + +![Azure - VM - Management - Public IP Address](img/azure-vm-management-public-ip.png) + +Click on the public IP address - which should open the **"Public IP address - Configuration"** blade, +then click on **"Configuration"** (under "Settings"). Now enter a friendly DNS name for your instance +in the `DNS name label` field: + +![Azure - VM - Domain Name](img/azure-vm-domain-name.png) + +In the screenshot above, you'll see that we've set the `DNS name label` to **"gitlab-ce-test"**. +This will make our VM accessible at `gitlab-ce-test.centralus.cloudapp.azure.com` +_(the full domain name of your own VM will be different, of course)_. + +Click **"Save"** for the changes to take effect. + +>**Note:** if you want to use your own domain name, you will need to add a DNS `A` record at your +domain registrar which points to the public IP address of your Azure VM. If you do this, you'll need +to make sure your VM is configured to use a _static_ public IP address (i.e. not a _dynamic_ one) +or you will have to reconfigure the DNS `A` record each time Azure reassigns your VM a new public IP +address. Read [IP address types and allocation methods in Azure][Azure-IP-Address-Types] to learn more. + +### Let's open some ports! + +At this stage you should have a running and fully operational VM. However, none of the services on +your VM (e.g. GitLab) will be publicly accessible via the internet until you have opened up the +neccessary ports to enable access to those services. + +Ports are opened by adding _security rules_ to the **"Network security group"** (NSG) which our VM +has been assigned to. If you followed the process above, then Azure will have automatically created +an NSG named `GitLab-CE-nsg` and assigned the `GitLab-CE` VM to it. + +>**Note:** if you gave your VM a different name then the NSG automatically created by Azure will +also have a different name - the name you have your VM, with `-nsg` appended to it. + +You can navigate to the NSG settings via many different routes in the Azure Portal, but one of the +simplest ways is to go to the Azure Dashboard, and then click on the Network Security Group listed +in the **"All resources"** tile: + +![Azure - Dashboard - All resources - Network security group](img/azure-dashboard-highlight-nsg.png) + +With the **"Network security group"** blade open, click on **"Inbound security rules"** under +**"Settings"**: + +![Azure - Network security group - Inbound security rules](img/azure-nsg-inbound-sec-rules-highlight.png) + +Next, click **"Add"**: + +![Azure - Network security group - Inbound security rules - Add](img/azure-nsg-inbound-sec-rules-add-highlight.png) + +#### Which ports to open? + +Like all servers, our VM will be running many services. However, we want to open up the correct +ports to enable public internet access to two services in particular: + +1. **HTTP** (port 80) - opening port 80 will enable our VM to respond to HTTP requests, allowing +public access to the instance of GitLab running on our VM. +1. **SSH** (port 22) - opening port 22 will enable our VM to respond to SSH connection requests, +allowing public access (with authentication) to remote terminal sessions +_(you'll see why we need [SSH] access to our VM [later on in this tutorial](#maintaining-your-gitlab-instance))_ + +#### Open HTTP on Port 80 + +In the **"Add inbound security rule"** blade, let's open port 80 so that our VM will accept HTTP +connections: + +![Azure - Add inbound security rules - HTTP](img/azure-add-inbound-sec-rule-http.png) + +1. Enter **"HTTP"** in the `Name` field +1. Select **HTTP** from the options in the `Service` drop-down +1. Make sure the `Action` is set to **Allow** +1. Click **"OK"** + +#### Open SSH on Port 22 + +Repeat the above process, adding a second Inbound security rule to open port 22, enabling our VM to +accept [SSH] connections: + +![Azure - Add inbound security rules - SSH](img/azure-add-inbound-sec-rule-ssh.png) + +1. Enter **"SSH"** in the `Name` field +1. Select **SSH** from the options in the `Service` drop-down +1. Make sure the `Action` is set to **Allow** +1. Click **"OK"** + + +It will take a moment for Azure to add each new Inbound Security Rule (and you may need to click on +**"Inbound security rules"** to refresh the list), but once completed, you should see the two new +rules in the list: + +![Azure - Inbound security rules - List](img/azure-inbound-sec-rules-list.png) + +## Connecting to GitLab +Use the domain name you set up earlier (or the public IP address) to visit your new GitLab instance +in your browser. If everything has gone according to plan you should be presented with the +following page, asking you to set a _new_ password for the administrator account automatically +created by GitLab: + +![GitLab - Change Password](img/gitlab-change-password.png) + +Enter your _new_ password into both form fields, and then click **"Change your password"**. + +Once you have changed the password you will be redirected to the GitLab login page. Use `root` as +the username, enter the new password you set in the previous step, and then click **"Sign in"**: + +![GitLab - Login](img/gitlab-login.png) + +### Success? + +After signing in successfully, you should see the GitLab Projects page displaying a +**"Welcome to GitLab!"** message: + +![GitLab - Projects Page](img/gitlab-home.png) + +If so, you now have a working GitLab instance on your own private Azure VM. **Congratulations!** + +## Creating your first GitLab project + +You can skip this section if you are familiar with Git and GitLab. Otherwise, let's create our first +project. From the Welcome page, click **"New Project"**. + +Let's give our project a name and a description, and then accept the default values for everything +else: + +1. Enter **"demo"** into the `Project path` project name field +1. Enter a `description`, e.g. **"My awesome demo project!"** +1. Click **"Create project"** + +![GitLab - New Project](img/gitlab-new-project.png) + +Once the new project has been created (which should only take a moment), you'll be redirected to +homepage for the project: + +![GitLab - Empty Project](img/gitlab-project-home-empty.png) + +If you scroll further down the project's home page, you'll see some basic instructions on how to +setup a local clone of your new repository and push and pull from it: + +![GitLab - Empty Project - Basic Instructions](img/gitlab-project-home-instructions.png) + +**That's it! You now have your own private GitLab environment installed and running in the cloud!** + +## Maintaining your GitLab instance + +It's important to keep your GitLab environment up-to-date. The GitLab team is constantly making +enhancements and occasionally you may need to update for security reasons. So let's review how to +update GitLab. + +### Checking our current version + +To check which version of GitLab we're currently running, click on the "Admin Area" link - it's the +the wrench icon displayed in the top-right, next to the search box. + +In the following screenshot you can see an **"update asap"** notification message in the top-right. +This particular message indicates that there is a newer version of GitLab available which contains +one or more security fixes: + +![GitLab - update asap](img/gitlab-admin-area.png) + +Under the **"Components"** section, we can see that our VM is currently running version `8.6.5` of +GitLab. This is the version of GitLab which was contained in the Azure Marketplace +**"GitLab Community Edition"** offering we used to build the VM when we wrote this tutorial. + +>**Note:** The version of GitLab in your own VM instance may well be different, but the update +process will still be the same. + +### Connect via SSH + +To perform an update, we need to connect directly to our Azure VM instance and run some commands +from the terminal. Our Azure VM is actually a server running Linux (Ubuntu), so we'll need to +connect to it using SSH ([Secure Shell][SSH]). + +If you're running Windows, you'll need to connect using [PuTTY] or an equivalent Windows SSH client. +If you're running Linux or macOS, then you already have an SSH client installed. + +>**Note:** +- Remember that you will need to login with the username and password you specified +[when you created](#basics) your Azure VM +- If you need to reset your VM password, read +[how to reset SSH credentials for a user on an Azure VM][Azure-Troubleshoot-SSH-Connection]. + +#### SSH from the command-line + +If you're running [SSH] from the command-line (terminal), then type in the following command to +connect to your VM, substituting `username` and `your-azure-domain-name.com` for the correct values. + +Again, remember that your Azure VM domain name will be the one you +[setup previously in the tutorial](#set-up-a-domain-name). If you didn't setup a domain name for +your VM, you can use the IP address in its place in the following command: + +```bash +ssh username@your-azure-domain-name.com +``` +Provide your password at the prompt to authenticate. + +#### SSH from Windows (PuTTY) + +If you're using [PuTTY] in Windows as your [SSH] client, then you might want to take a quick +read on [using PuTTY in Windows][Using-SSH-In-Putty]. + +### Updating GitLab + +Once you've logged in via SSH, enter the following command to update GitLab to the latest +version: + +```bash +sudo apt-get update && sudo apt-get install gitlab-ce +``` + +This command will update GitLab and its associated components to the latest versions, so it will +take a little time to complete. You'll see various update tasks being completed in your SSH +terminal window: + +![GitLab updating](img/gitlab-ssh-update-in-progress.png) + +Once the update process has completed, you'll see a message like this: + +``` +Upgrade complete! If your GitLab server is misbehaving try running + + sudo gitlab-ctl restart + +before anything else. +``` + +#### Check out your updated GitLab + +Refresh your GitLab instance in the browser and navigate to the Admin Area. You should now have an +up-to-date GitLab instance. + +When we wrote this tutorial our Azure VM GitLab instance was updated to the latest version at time +of writing (`9.4.0`). You can see that the message which was previously displaying **"update asap"** +is now showing **"up-to-date"**: + +![GitLab up to date](img/gitlab-admin-area-9.4.0.png) + +## Conclusion + +Naturally, we believe that GitLab is a great git repository tool. However, GitLab is a whole lot +more than that too. GitLab unifies issues, code review, CI and CD into a single UI, helping you to +move faster from idea to production, and in this tutorial we showed you how quick and easy it is to +setup and run your own instance of GitLab on Azure, Microsoft's cloud service. + +Azure is a great way to experiment with GitLab, and if you decide (as we hope) that GitLab is for +you, you can continue to use Azure as your secure, scalable cloud provider or of course run GitLab +on any cloud service you choose. + +## Where to next? + +Check out our other [Technical Articles][GitLab-Technical-Articles] or browse the [GitLab Documentation][GitLab-Docs] to learn more about GitLab. + +### Useful links + +- [GitLab Community Edition][CE] +- [GitLab Enterprise Edition][EE] +- [Microsoft Azure][Azure] + - [Azure - Free Account FAQ][Azure-Free-Account-FAQ] + - [Azure - Marketplace][Azure-Marketplace] + - [Azure Portal][Azure-Portal] + - [Azure - Pricing Calculator][Azure-Pricing-Calculator] + - [Azure - Troubleshoot SSH Connections to an Azure Linux VM][Azure-Troubleshoot-SSH-Connection] + - [Azure - Properly Shutdown an Azure VM][Azure-Properly-Shutdown-VM] +- [SSH], [PuTTY] and [Using SSH in PuTTY][Using-SSH-In-Putty] + +[Original-Blog-Post]: https://about.gitlab.com/2016/07/13/how-to-setup-a-gitlab-instance-on-microsoft-azure/ "How to Setup a GitLab Instance on Microsoft Azure" +[GitLab-Docs]: https://docs.gitlab.com/ce/README.html "GitLab Documentation" +[GitLab-Technical-Articles]: https://docs.gitlab.com/ce/articles/index.html "GitLab Technical Articles" +[GitLab-Docs-SSH]: https://docs.gitlab.com/ce/ssh/README.html "GitLab Documentation: SSH" +[CE]: https://about.gitlab.com/features/ +[EE]: https://about.gitlab.com/features/#ee-starter + +[Azure-Troubleshoot-Linux-VM]: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/troubleshoot-app-connection "Troubleshoot application connectivity issues on a Linux virtual machine in Azure" +[Azure-IP-Address-Types]: https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-ip-addresses-overview-arm "IP address types and allocation methods in Azure" +[Azure-How-To-Open-Ports]: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal "How to open ports to a virtual machine with the Azure portal" +[Azure-Troubleshoot-SSH-Connection]: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/troubleshoot-ssh-connection "Troubleshoot SSH connections to an Azure Linux VM" +[Azure]: https://azure.microsoft.com/en-us/ +[Azure-Free-Account-FAQ]: https://azure.microsoft.com/en-us/free/free-account-faq/ +[Azure-Marketplace]: https://azure.microsoft.com/en-us/marketplace/ +[Azure-Portal]: https://portal.azure.com +[Azure-Pricing-Calculator]: https://azure.microsoft.com/en-us/pricing/calculator/ +[Azure-Properly-Shutdown-VM]: https://buildazure.com/2017/03/16/properly-shutdown-azure-vm-to-save-money/ "Properly Shutdown an Azure VM to Save Money" + +[SSH]: https://en.wikipedia.org/wiki/Secure_Shell +[PuTTY]: http://www.putty.org/ +[Using-SSH-In-Putty]: https://mediatemple.net/community/products/dv/204404604/using-ssh-in-putty- \ No newline at end of file -- cgit v1.2.1 From 51ceacb1fc10e4f2adb1b1b960e9c4a4d6f111a3 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 24 Aug 2017 17:32:40 -0400 Subject: Add missing third argument to `Git::Repository#initialize` in spec --- spec/lib/gitlab/git/repository_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index b84f54c87fc..6b9773c9b63 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -980,7 +980,7 @@ describe Gitlab::Git::Repository, seed_helper: true do context 'with local and remote branches' do let(:repository) do - Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git')) + Gitlab::Git::Repository.new('default', File.join(TEST_MUTABLE_REPO_PATH, '.git'), '') end before do -- cgit v1.2.1 From ec1ec9b67a95de3b775eefe0f4cdce6fd3aa7b70 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 25 Aug 2017 08:54:50 +1100 Subject: Replace 'source/search_code.feature' spinach test with an rspec analog --- .../add_index_on_ci_runners_contacted_at.yml | 4 -- .../replace_spinach_search_code-feature.yml | 5 ++ features/project/source/search_code.feature | 15 ------ features/steps/project/source/search_code.rb | 19 ------- features/steps/shared/paths.rb | 4 -- spec/features/projects/files/find_files_spec.rb | 23 --------- .../projects/files/user_searches_for_files_spec.rb | 58 ++++++++++++++++++++++ 7 files changed, 63 insertions(+), 65 deletions(-) delete mode 100644 changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml create mode 100644 changelogs/unreleased/replace_spinach_search_code-feature.yml delete mode 100644 features/project/source/search_code.feature delete mode 100644 features/steps/project/source/search_code.rb delete mode 100644 spec/features/projects/files/find_files_spec.rb create mode 100644 spec/features/projects/files/user_searches_for_files_spec.rb diff --git a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml deleted file mode 100644 index 10c3206c2ff..00000000000 --- a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add index on ci_runners.contacted_at -merge_request: 10876 -author: blackst0ne diff --git a/changelogs/unreleased/replace_spinach_search_code-feature.yml b/changelogs/unreleased/replace_spinach_search_code-feature.yml new file mode 100644 index 00000000000..28d2108c871 --- /dev/null +++ b/changelogs/unreleased/replace_spinach_search_code-feature.yml @@ -0,0 +1,5 @@ +--- +title: Replace 'source/search_code.feature' spinach test with an rspec analog +merge_request: 13697 +author: blackst0ne +type: other diff --git a/features/project/source/search_code.feature b/features/project/source/search_code.feature deleted file mode 100644 index 4f9dcea249f..00000000000 --- a/features/project/source/search_code.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Project Source Search Code - Background: - Given I sign in as a user - - Scenario: Search for term "coffee" - Given I own project "Shop" - And I visit project source page - When I search for term "coffee" - Then I should see files from repository containing "coffee" - - Scenario: Search on empty project - Given I own an empty project - And I visit my project's home page - When I search for term "coffee" - Then I should see empty result diff --git a/features/steps/project/source/search_code.rb b/features/steps/project/source/search_code.rb deleted file mode 100644 index feee756d7ec..00000000000 --- a/features/steps/project/source/search_code.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Spinach::Features::ProjectSourceSearchCode < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedPaths - - step 'I search for term "coffee"' do - fill_in "search", with: "coffee" - click_button "Go" - end - - step 'I should see files from repository containing "coffee"' do - expect(page).to have_content 'coffee' - expect(page).to have_content 'CONTRIBUTING.md' - end - - step 'I should see empty result' do - expect(page).to have_content "We couldn't find any" - end -end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 830263fd038..be69a96c3ee 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -304,10 +304,6 @@ module SharedPaths visit project_commits_path(@project, 'stable', { limit: 5 }) end - step 'I visit project source page' do - visit project_tree_path(@project, root_ref) - end - step 'I visit blob file from repo' do visit project_blob_path(@project, File.join(sample_commit.id, sample_blob.path)) end diff --git a/spec/features/projects/files/find_files_spec.rb b/spec/features/projects/files/find_files_spec.rb deleted file mode 100644 index 57d67b28920..00000000000 --- a/spec/features/projects/files/find_files_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -feature 'Find files button in the tree header' do - given(:user) { create(:user) } - given(:project) { create(:project, :repository) } - - background do - sign_in(user) - project.team << [user, :developer] - end - - scenario 'project main screen' do - visit project_path(project) - - expect(page).to have_selector('.tree-controls .shortcuts-find-file') - end - - scenario 'project tree screen' do - visit project_tree_path(project, project.default_branch) - - expect(page).to have_selector('.tree-controls .shortcuts-find-file') - end -end diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb new file mode 100644 index 00000000000..a105685bca7 --- /dev/null +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe 'User searches for files' do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + + before do + sign_in(user) + end + + describe 'project main screen' do + context 'when project is empty' do + let(:empty_project) { create(:project) } + + before do + empty_project.add_developer(user) + visit project_path(empty_project) + end + + it 'does not show any result' do + fill_in('search', with: 'coffee') + click_button('Go') + + expect(page).to have_content("We couldn't find any") + end + end + + context 'when project is not empty' do + before do + project.add_developer(user) + visit project_path(project) + end + + it 'shows "Find file" button' do + expect(page).to have_selector('.tree-controls .shortcuts-find-file') + end + end + end + + describe 'project tree screen' do + before do + project.add_developer(user) + visit project_tree_path(project, project.default_branch) + end + + it 'shows "Find file" button' do + expect(page).to have_selector('.tree-controls .shortcuts-find-file') + end + + it 'shows found files' do + fill_in('search', with: 'coffee') + click_button('Go') + + expect(page).to have_content('coffee') + expect(page).to have_content('CONTRIBUTING.md') + end + end +end -- cgit v1.2.1 From 24244d03b55bc7732b3362bab1e1cc7e04c2dabf Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 25 Aug 2017 01:47:37 +0000 Subject: Revert "Merge branch 'sh-sidekiq-backtrace' into 'master'" This reverts merge request !13813 --- app/workers/concerns/exception_backtrace.rb | 8 -------- app/workers/group_destroy_worker.rb | 1 - app/workers/namespaceless_project_destroy_worker.rb | 1 - app/workers/project_destroy_worker.rb | 1 - app/workers/project_export_worker.rb | 1 - app/workers/repository_import_worker.rb | 1 - 6 files changed, 13 deletions(-) delete mode 100644 app/workers/concerns/exception_backtrace.rb diff --git a/app/workers/concerns/exception_backtrace.rb b/app/workers/concerns/exception_backtrace.rb deleted file mode 100644 index e3ecdfe2502..00000000000 --- a/app/workers/concerns/exception_backtrace.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Concern for enabling a few lines of exception backtraces in Sidekiq -module BuildQueue - extend ActiveSupport::Concern - - included do - sidekiq_options backtrace: 5 - end -end diff --git a/app/workers/group_destroy_worker.rb b/app/workers/group_destroy_worker.rb index bd8e212e928..07e82767b06 100644 --- a/app/workers/group_destroy_worker.rb +++ b/app/workers/group_destroy_worker.rb @@ -1,7 +1,6 @@ class GroupDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue - include ExceptionBacktrace def perform(group_id, user_id) begin diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb index f1cd1769421..1cfb0be759e 100644 --- a/app/workers/namespaceless_project_destroy_worker.rb +++ b/app/workers/namespaceless_project_destroy_worker.rb @@ -7,7 +7,6 @@ class NamespacelessProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue - include ExceptionBacktrace def self.bulk_perform_async(args_list) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list) diff --git a/app/workers/project_destroy_worker.rb b/app/workers/project_destroy_worker.rb index 3be7e686609..a9188b78460 100644 --- a/app/workers/project_destroy_worker.rb +++ b/app/workers/project_destroy_worker.rb @@ -1,7 +1,6 @@ class ProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue - include ExceptionBacktrace def perform(project_id, user_id, params) project = Project.find(project_id) diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb index f13ac9e5db2..6009aa1b191 100644 --- a/app/workers/project_export_worker.rb +++ b/app/workers/project_export_worker.rb @@ -1,7 +1,6 @@ class ProjectExportWorker include Sidekiq::Worker include DedicatedSidekiqQueue - include ExceptionBacktrace sidekiq_options retry: 3 diff --git a/app/workers/repository_import_worker.rb b/app/workers/repository_import_worker.rb index 00a021abbdc..2c2d1e8b91f 100644 --- a/app/workers/repository_import_worker.rb +++ b/app/workers/repository_import_worker.rb @@ -3,7 +3,6 @@ class RepositoryImportWorker include Sidekiq::Worker include DedicatedSidekiqQueue - include ExceptionBacktrace sidekiq_options status_expiration: StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION -- cgit v1.2.1 From 93f08ba05b9c40fe3e734798db299522234ab68f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 24 Aug 2017 15:40:21 -0400 Subject: Combine multiple expectations into one for shared system note example These are all performing unique checks on the same object, so there's no benefit to isolating them. --- spec/services/system_note_service_spec.rb | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 6d36affa9dc..e6a18654651 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -13,37 +13,16 @@ describe SystemNoteService do let(:expected_noteable) { noteable } let(:commit_count) { nil } - it 'is valid' do + it 'has the correct attributes', :aggregate_failures do expect(subject).to be_valid - end + expect(subject).to be_system - it 'sets the noteable model' do expect(subject.noteable).to eq expected_noteable - end - - it 'sets the project' do expect(subject.project).to eq project - end - - it 'sets the author' do expect(subject.author).to eq author - end - it 'is a system note' do - expect(subject).to be_system - end - - context 'metadata' do - it 'creates a new system note metadata record' do - expect { subject }.to change { SystemNoteMetadata.count }.from(0).to(1) - end - - it 'creates a record correctly' do - metadata = subject.system_note_metadata - - expect(metadata.commit_count).to eq(commit_count) - expect(metadata.action).to eq(action) - end + expect(subject.system_note_metadata.action).to eq(action) + expect(subject.system_note_metadata.commit_count).to eq(commit_count) end end -- cgit v1.2.1 From 1275ca3899a1432ea76b4a0a60f44672dd681da6 Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Thu, 24 Aug 2017 22:47:19 -0500 Subject: Fix repo editor scrollbar --- app/assets/stylesheets/pages/repo.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 1f4d4698199..c9bae03e590 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -182,7 +182,6 @@ padding: 5px 10px; position: relative; border-top: 1px solid $white-normal; - margin-top: -5px; } #binary-viewer { -- cgit v1.2.1 From 65c223ae836925a056c86b92351cea85aa26e9ef Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 25 Aug 2017 08:39:55 +0000 Subject: Revert "Merge branch 'mk-reenable-mysql-tests-on-all-branches' into 'master'" This reverts merge request !13812 --- .gitlab-ci.yml | 15 +++++++++++++++ doc/development/testing.md | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab9627d4ab7..6f356a07576 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,6 +68,19 @@ stages: - mysql:latest - redis:alpine +.only-if-want-mysql: &only-if-want-mysql + only: + - /mysql/ + - /-stable/ + - master@gitlab-org/gitlab-ce + - master@gitlab-org/gitlab-ee + - master@gitlab/gitlabhq + - master@gitlab/gitlab-ee + - tags@gitlab-org/gitlab-ce + - tags@gitlab-org/gitlab-ee + - tags@gitlab/gitlabhq + - tags@gitlab/gitlab-ee + # Skip all jobs except the ones that begin with 'docs/'. # Used for commits including ONLY documentation changes. # https://docs.gitlab.com/ce/development/writing_documentation.html#testing @@ -111,6 +124,7 @@ stages: .rspec-metadata-mysql: &rspec-metadata-mysql <<: *rspec-metadata <<: *use-mysql + <<: *only-if-want-mysql <<: *except-docs .spinach-metadata: &spinach-metadata @@ -142,6 +156,7 @@ stages: .spinach-metadata-mysql: &spinach-metadata-mysql <<: *spinach-metadata <<: *use-mysql + <<: *only-if-want-mysql <<: *except-docs .only-canonical-masters: &only-canonical-masters diff --git a/doc/development/testing.md b/doc/development/testing.md index 83269303005..efd56484b12 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -529,7 +529,10 @@ slowest test files and try to improve them. ## CI setup -- On CE and EE, the test suite runs both PostgreSQL and MySQL. +- On CE, the test suite only runs against PostgreSQL by default. We additionally + run the suite against MySQL for tags, `master`, and any branch that includes + `mysql` in the name. +- On EE, the test suite always runs both PostgreSQL and MySQL. - Rails logging to `log/test.log` is disabled by default in CI [for performance reasons][logging]. To override this setting, provide the `RAILS_ENABLE_TEST_LOG` environment variable. -- cgit v1.2.1 From 2ad3dcc5ca46905209dadd3b6ad1dcf451ee7fd6 Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Fri, 25 Aug 2017 14:04:08 +0700 Subject: Fix invite by email address duplication --- app/assets/javascripts/users_select.js | 7 ++++--- changelogs/unreleased/36937-fix-invite-by-email-text.yml | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/36937-fix-invite-by-email-text.yml diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index 16ebf5916dc..a31fedee021 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -588,9 +588,10 @@ function UsersSelect(currentUser, els) { if (showEmailUser && data.results.length === 0 && query.term.match(/^[^@]+@[^@]+$/)) { var trimmed = query.term.trim(); emailUser = { - name: "Invite \"" + query.term + "\"", + name: "Invite \"" + query.term + "\" by email", username: trimmed, - id: trimmed + id: trimmed, + invite: true }; data.results.unshift(emailUser); } @@ -642,7 +643,7 @@ UsersSelect.prototype.formatResult = function(user) { } else { avatar = gon.default_avatar_url; } - return "
"; + return "
"; }; UsersSelect.prototype.formatSelection = function(user) { diff --git a/changelogs/unreleased/36937-fix-invite-by-email-text.yml b/changelogs/unreleased/36937-fix-invite-by-email-text.yml new file mode 100644 index 00000000000..06c6105fab6 --- /dev/null +++ b/changelogs/unreleased/36937-fix-invite-by-email-text.yml @@ -0,0 +1,5 @@ +--- +title: Fix invite by email address duplication +merge_request: +author: +type: fixed -- cgit v1.2.1 From fa2915ec2deaf9aa73ae18a60836a831376da943 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Thu, 24 Aug 2017 14:46:08 +0100 Subject: Fix searching for files by path --- .../unreleased/36939-fix-find-blobs-by-path.yml | 5 +++ lib/gitlab/file_finder.rb | 43 ++++++++++++++++------ spec/lib/gitlab/file_finder_spec.rb | 14 +++++-- 3 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 changelogs/unreleased/36939-fix-find-blobs-by-path.yml diff --git a/changelogs/unreleased/36939-fix-find-blobs-by-path.yml b/changelogs/unreleased/36939-fix-find-blobs-by-path.yml new file mode 100644 index 00000000000..b48b10049ed --- /dev/null +++ b/changelogs/unreleased/36939-fix-find-blobs-by-path.yml @@ -0,0 +1,5 @@ +--- +title: Fix searching for files by path +merge_request: 13798 +author: +type: fixed diff --git a/lib/gitlab/file_finder.rb b/lib/gitlab/file_finder.rb index 093d9ed8092..10ffc345bd5 100644 --- a/lib/gitlab/file_finder.rb +++ b/lib/gitlab/file_finder.rb @@ -6,27 +6,48 @@ module Gitlab attr_reader :project, :ref + delegate :repository, to: :project + def initialize(project, ref) @project = project @ref = ref end def find(query) - blobs = project.repository.search_files_by_content(query, ref).first(BATCH_SIZE) - found_file_names = Set.new + by_content = find_by_content(query) - results = blobs.map do |blob| - blob = Gitlab::ProjectSearchResults.parse_search_result(blob) - found_file_names << blob.filename + already_found = Set.new(by_content.map(&:filename)) + by_filename = find_by_filename(query, except: already_found) - [blob.filename, blob] - end + (by_content + by_filename) + .sort_by(&:filename) + .map { |blob| [blob.filename, blob] } + end - project.repository.search_files_by_name(query, ref).first(BATCH_SIZE).each do |filename| - results << [filename, OpenStruct.new(ref: ref)] unless found_file_names.include?(filename) - end + private - results.sort_by(&:first) + def find_by_content(query) + results = repository.search_files_by_content(query, ref).first(BATCH_SIZE) + results.map { |result| Gitlab::ProjectSearchResults.parse_search_result(result) } + end + + def find_by_filename(query, except: []) + filenames = repository.search_files_by_name(query, ref).first(BATCH_SIZE) + filenames.delete_if { |filename| except.include?(filename) } unless except.empty? + + blob_refs = filenames.map { |filename| [ref, filename] } + blobs = Gitlab::Git::Blob.batch(repository, blob_refs, blob_size_limit: 1024) + + blobs.map do |blob| + Gitlab::SearchResults::FoundBlob.new( + id: blob.id, + filename: blob.path, + basename: File.basename(blob.path), + ref: ref, + startline: 1, + data: blob.data + ) + end end end end diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index 3fb6315a39a..07cb10e563e 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -7,15 +7,23 @@ describe Gitlab::FileFinder do it 'finds by name' do results = finder.find('files') - expect(results.map(&:first)).to include('files/images/wm.svg') + + filename, blob = results.find { |_, blob| blob.filename == 'files/images/wm.svg' } + expect(filename).to eq('files/images/wm.svg') + expect(blob).to be_a(Gitlab::SearchResults::FoundBlob) + expect(blob.ref).to eq(finder.ref) + expect(blob.data).not_to be_empty end it 'finds by content' do results = finder.find('files') - blob = results.select { |result| result.first == "CHANGELOG" }.flatten.last + filename, blob = results.find { |_, blob| blob.filename == 'CHANGELOG' } - expect(blob.filename).to eq("CHANGELOG") + expect(filename).to eq('CHANGELOG') + expect(blob).to be_a(Gitlab::SearchResults::FoundBlob) + expect(blob.ref).to eq(finder.ref) + expect(blob.data).not_to be_empty end end end -- cgit v1.2.1 From 9e203582b367a1b84035572261a79b62e22bfeaa Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Wed, 23 Aug 2017 01:51:53 +0900 Subject: Improve AutocompleteController#user.json performance --- app/models/user.rb | 2 +- .../improve-autocomplete-user-performance.yml | 5 ++++ lib/gitlab/sql/pattern.rb | 29 ++++++++++++++++++++ .../issues/filtered_search/dropdown_author_spec.rb | 12 ++++----- spec/lib/gitlab/sql/pattern_spec.rb | 31 ++++++++++++++++++++++ spec/models/user_spec.rb | 17 ++++++++++++ 6 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/improve-autocomplete-user-performance.yml create mode 100644 lib/gitlab/sql/pattern.rb create mode 100644 spec/lib/gitlab/sql/pattern_spec.rb diff --git a/app/models/user.rb b/app/models/user.rb index fbd08bc4d0a..e5a84ce4080 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -303,7 +303,7 @@ class User < ActiveRecord::Base # Returns an ActiveRecord::Relation. def search(query) table = arel_table - pattern = "%#{query}%" + pattern = Gitlab::SQL::Pattern.new(query).to_sql order = <<~SQL CASE diff --git a/changelogs/unreleased/improve-autocomplete-user-performance.yml b/changelogs/unreleased/improve-autocomplete-user-performance.yml new file mode 100644 index 00000000000..5a7153771ff --- /dev/null +++ b/changelogs/unreleased/improve-autocomplete-user-performance.yml @@ -0,0 +1,5 @@ +--- +title: Improve performance for AutocompleteController#users.json +merge_request: 13754 +author: Hiroyuki Sato +type: changed diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb new file mode 100644 index 00000000000..47ea19994a2 --- /dev/null +++ b/lib/gitlab/sql/pattern.rb @@ -0,0 +1,29 @@ +module Gitlab + module SQL + class Pattern + MIN_CHARS_FOR_PARTIAL_MATCHING = 3 + + attr_reader :query + + def initialize(query) + @query = query + end + + def to_sql + if exact_matching? + query + else + "%#{query}%" + end + end + + def exact_matching? + !partial_matching? + end + + def partial_matching? + @query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING + end + end + end +end diff --git a/spec/features/issues/filtered_search/dropdown_author_spec.rb b/spec/features/issues/filtered_search/dropdown_author_spec.rb index 975dc035f2d..3cec59050ab 100644 --- a/spec/features/issues/filtered_search/dropdown_author_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_author_spec.rb @@ -6,7 +6,7 @@ describe 'Dropdown author', js: true do let!(:project) { create(:project) } let!(:user) { create(:user, name: 'administrator', username: 'root') } let!(:user_john) { create(:user, name: 'John', username: 'th0mas') } - let!(:user_jacob) { create(:user, name: 'Jacob', username: 'otter32') } + let!(:user_jacob) { create(:user, name: 'Jacob', username: 'ooter32') } let(:filtered_search) { find('.filtered-search') } let(:js_dropdown_author) { '#js-dropdown-author' } @@ -82,31 +82,31 @@ describe 'Dropdown author', js: true do end it 'filters by name' do - send_keys_to_filtered_search('ja') + send_keys_to_filtered_search('jac') expect(dropdown_author_size).to eq(1) end it 'filters by case insensitive name' do - send_keys_to_filtered_search('Ja') + send_keys_to_filtered_search('Jac') expect(dropdown_author_size).to eq(1) end it 'filters by username with symbol' do - send_keys_to_filtered_search('@ot') + send_keys_to_filtered_search('@oot') expect(dropdown_author_size).to eq(2) end it 'filters by username without symbol' do - send_keys_to_filtered_search('ot') + send_keys_to_filtered_search('oot') expect(dropdown_author_size).to eq(2) end it 'filters by case insensitive username without symbol' do - send_keys_to_filtered_search('OT') + send_keys_to_filtered_search('OOT') expect(dropdown_author_size).to eq(2) end diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb new file mode 100644 index 00000000000..cbafe36de06 --- /dev/null +++ b/spec/lib/gitlab/sql/pattern_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::SQL::Pattern do + describe '#to_sql' do + subject(:to_sql) { described_class.new(query).to_sql } + + context 'when a query is shorter than 3 chars' do + let(:query) { '12' } + + it 'returns exact matching pattern' do + expect(to_sql).to eq('12') + end + end + + context 'when a query is equal to 3 chars' do + let(:query) { '123' } + + it 'returns partial matching pattern' do + expect(to_sql).to eq('%123%') + end + end + + context 'when a query is longer than 3 chars' do + let(:query) { '1234' } + + it 'returns partial matching pattern' do + expect(to_sql).to eq('%1234%') + end + end + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9a9e255f874..50abd7af429 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -789,6 +789,7 @@ describe User do describe '.search' do let!(:user) { create(:user, name: 'user', username: 'usern', email: 'email@gmail.com') } let!(:user2) { create(:user, name: 'user name', username: 'username', email: 'someemail@gmail.com') } + let!(:user3) { create(:user, name: 'us', username: 'se', email: 'foo@gmail.com') } describe 'name matching' do it 'returns users with a matching name with exact match first' do @@ -802,6 +803,14 @@ describe User do it 'returns users with a matching name regardless of the casing' do expect(described_class.search(user2.name.upcase)).to eq([user2]) end + + it 'returns users with a exact matching name shorter than 3 chars' do + expect(described_class.search(user3.name)).to eq([user3]) + end + + it 'returns users with a exact matching name shorter than 3 chars regardless of the casing' do + expect(described_class.search(user3.name.upcase)).to eq([user3]) + end end describe 'email matching' do @@ -830,6 +839,14 @@ describe User do it 'returns users with a matching username regardless of the casing' do expect(described_class.search(user2.username.upcase)).to eq([user2]) end + + it 'returns users with a exact matching username shorter than 3 chars' do + expect(described_class.search(user3.username)).to eq([user3]) + end + + it 'returns users with a exact matching username shorter than 3 chars regardless of the casing' do + expect(described_class.search(user3.username.upcase)).to eq([user3]) + end end end -- cgit v1.2.1 From 19da7a558711b38316d83012d919b7ea8252a26b Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Thu, 24 Aug 2017 17:59:24 +0200 Subject: Fix failure when issue author is nil --- app/views/projects/issues/show.html.haml | 3 ++- .../shared/issuable/_close_reopen_button.html.haml | 3 ++- .../issuable/_close_reopen_report_toggle.html.haml | 22 ++++++++++++---------- changelogs/unreleased/36860-deleted-user-fix.yml | 5 +++++ spec/features/issues/issue_detail_spec.rb | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 changelogs/unreleased/36860-deleted-user-fix.yml diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index ad5befc6ee5..de0f1de057d 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -32,7 +32,8 @@ %ul - if can_update_issue %li= link_to 'Edit', edit_project_issue_path(@project, @issue) - - unless current_user == @issue.author + / TODO: simplify condition back #36860 + - if @issue.author && current_user != @issue.author %li= link_to 'Report abuse', new_abuse_report_path(user_id: @issue.author.id, ref_url: issue_url(@issue)) - if can_update_issue %li= link_to 'Close issue', issue_path(@issue, issue: { state_event: :close }, format: 'json'), class: "btn-close #{issue_button_visibility(@issue, true)}", title: 'Close issue' diff --git a/app/views/shared/issuable/_close_reopen_button.html.haml b/app/views/shared/issuable/_close_reopen_button.html.haml index 8a1268a1c6d..f22b6c9a6c2 100644 --- a/app/views/shared/issuable/_close_reopen_button.html.haml +++ b/app/views/shared/issuable/_close_reopen_button.html.haml @@ -9,6 +9,7 @@ class: "hidden-xs hidden-sm btn btn-grouped btn-reopen #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}" - elsif can_update && !is_current_user = render 'shared/issuable/close_reopen_report_toggle', issuable: issuable -- else +- elsif issuable.author + / TODO: change back to else #36860 = link_to 'Report abuse', new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), class: 'hidden-xs hidden-sm btn btn-grouped btn-close-color', title: 'Report abuse' diff --git a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml index 6756a7f17fd..daa05990ae9 100644 --- a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml +++ b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml @@ -37,13 +37,15 @@ %li.divider.droplab-item-ignore - %li.report-item{ data: { text: 'Report abuse', url: new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), - button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } } - %button.btn.btn-transparent - = icon('check', class: 'icon') - .description - %strong.title Report abuse - %p.text - Report - = display_issuable_type.pluralize - that are abusive, inappropriate or spam. + / TODO: remove condition #36860 + - if issuable.author + %li.report-item{ data: { text: 'Report abuse', url: new_abuse_report_path(user_id: issuable.author.id, ref_url: issuable_url(issuable)), + button_class: "#{button_class} btn-close-color", toggle_class: "#{toggle_class} btn-close-color", method: '' } } + %button.btn.btn-transparent + = icon('check', class: 'icon') + .description + %strong.title Report abuse + %p.text + Report + = display_issuable_type.pluralize + that are abusive, inappropriate or spam. diff --git a/changelogs/unreleased/36860-deleted-user-fix.yml b/changelogs/unreleased/36860-deleted-user-fix.yml new file mode 100644 index 00000000000..79e75441134 --- /dev/null +++ b/changelogs/unreleased/36860-deleted-user-fix.yml @@ -0,0 +1,5 @@ +--- +title: Fix failure when issue is authored by a deleted user +merge_request: 13807 +author: +type: fixed diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb index 28b636f9359..c470cb7c716 100644 --- a/spec/features/issues/issue_detail_spec.rb +++ b/spec/features/issues/issue_detail_spec.rb @@ -40,4 +40,18 @@ feature 'Issue Detail', :js do end end end + + context 'when authored by a user who is later deleted' do + before do + issue.update_attribute(:author_id, nil) + sign_in(user) + visit project_issue_path(project, issue) + end + + it 'shows the issue' do + page.within('.issuable-details') do + expect(find('h2')).to have_content(issue.title) + end + end + end end -- cgit v1.2.1 From 4737fc3beeb3785c2f75ee0749830c40a901e061 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 25 Aug 2017 12:04:40 +0200 Subject: Decrease statuses batch size even more in a migration --- db/post_migrate/20170711145558_migrate_stages_statuses.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb index 7eb577ff3b2..aeb900354db 100644 --- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb +++ b/db/post_migrate/20170711145558_migrate_stages_statuses.rb @@ -6,7 +6,7 @@ class MigrateStagesStatuses < ActiveRecord::Migration disable_ddl_transaction! BATCH_SIZE = 10000 - RANGE_SIZE = 500 + RANGE_SIZE = 100 MIGRATION = 'MigrateStageStatus'.freeze class Stage < ActiveRecord::Base -- cgit v1.2.1 From 529a07bd1e05a85b3cfa117ed8980ad64d997db0 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Fri, 25 Aug 2017 12:35:47 +0200 Subject: Handle creating a nested group on MySQL correctly Since we don't support nested groups on MySQL, raise an error explaining that on import instead of trying anyway. --- app/services/groups/nested_create_service.rb | 4 + spec/lib/gitlab/bare_repository_importer_spec.rb | 104 ++++++++++++++------- spec/services/groups/nested_create_service_spec.rb | 87 +++++++++++------ 3 files changed, 133 insertions(+), 62 deletions(-) diff --git a/app/services/groups/nested_create_service.rb b/app/services/groups/nested_create_service.rb index 8d793f5c02e..d6f08fc3cce 100644 --- a/app/services/groups/nested_create_service.rb +++ b/app/services/groups/nested_create_service.rb @@ -15,6 +15,10 @@ module Groups return group end + if group_path.include?('/') && !Group.supports_nested_groups? + raise 'Nested groups are not supported on MySQL' + end + create_group_path end diff --git a/spec/lib/gitlab/bare_repository_importer_spec.rb b/spec/lib/gitlab/bare_repository_importer_spec.rb index 892f2dafc96..36d1844b5b1 100644 --- a/spec/lib/gitlab/bare_repository_importer_spec.rb +++ b/spec/lib/gitlab/bare_repository_importer_spec.rb @@ -2,67 +2,99 @@ require 'spec_helper' describe Gitlab::BareRepositoryImporter, repository: true do subject(:importer) { described_class.new('default', project_path) } - let(:project_path) { 'a-group/a-sub-group/a-project' } + let!(:admin) { create(:admin) } before do allow(described_class).to receive(:log) end - describe '.execute' do - it 'creates a project for a repository in storage' do - FileUtils.mkdir_p(File.join(TestEnv.repos_path, "#{project_path}.git")) - fake_importer = double + shared_examples 'importing a repository' do + describe '.execute' do + it 'creates a project for a repository in storage' do + FileUtils.mkdir_p(File.join(TestEnv.repos_path, "#{project_path}.git")) + fake_importer = double - expect(described_class).to receive(:new).with('default', project_path) - .and_return(fake_importer) - expect(fake_importer).to receive(:create_project_if_needed) + expect(described_class).to receive(:new).with('default', project_path) + .and_return(fake_importer) + expect(fake_importer).to receive(:create_project_if_needed) - described_class.execute - end + described_class.execute + end - it 'skips wiki repos' do - FileUtils.mkdir_p(File.join(TestEnv.repos_path, 'the-group', 'the-project.wiki.git')) + it 'skips wiki repos' do + FileUtils.mkdir_p(File.join(TestEnv.repos_path, 'the-group', 'the-project.wiki.git')) - expect(described_class).to receive(:log).with(' * Skipping wiki repo') - expect(described_class).not_to receive(:new) + expect(described_class).to receive(:log).with(' * Skipping wiki repo') + expect(described_class).not_to receive(:new) - described_class.execute + described_class.execute + end end - end - describe '#initialize' do - context 'without admin users' do - let(:admin) { nil } + describe '#initialize' do + context 'without admin users' do + let(:admin) { nil } - it 'raises an error' do - expect { importer }.to raise_error(Gitlab::BareRepositoryImporter::NoAdminError) + it 'raises an error' do + expect { importer }.to raise_error(Gitlab::BareRepositoryImporter::NoAdminError) + end end end - end - describe '#create_project_if_needed' do - it 'starts an import for a project that did not exist' do - expect(importer).to receive(:create_project) + describe '#create_project_if_needed' do + it 'starts an import for a project that did not exist' do + expect(importer).to receive(:create_project) + + importer.create_project_if_needed + end + + it 'skips importing when the project already exists' do + project = create(:project, path: 'a-project', namespace: existing_group) + + expect(importer).not_to receive(:create_project) + expect(importer).to receive(:log).with(" * #{project.name} (#{project_path}) exists") + + importer.create_project_if_needed + end + + it 'creates a project with the correct path in the database' do + importer.create_project_if_needed - importer.create_project_if_needed + expect(Project.find_by_full_path(project_path)).not_to be_nil + end end + end + + context 'with subgroups', :nested_groups do + let(:project_path) { 'a-group/a-sub-group/a-project' } - it 'skips importing when the project already exists' do + let(:existing_group) do group = create(:group, path: 'a-group') - subgroup = create(:group, path: 'a-sub-group', parent: group) - project = create(:project, path: 'a-project', namespace: subgroup) + create(:group, path: 'a-sub-group', parent: group) + end - expect(importer).not_to receive(:create_project) - expect(importer).to receive(:log).with(" * #{project.name} (a-group/a-sub-group/a-project) exists") + it_behaves_like 'importing a repository' + end - importer.create_project_if_needed - end + context 'without subgroups' do + let(:project_path) { 'a-group/a-project' } + let(:existing_group) { create(:group, path: 'a-group') } - it 'creates a project with the correct path in the database' do - importer.create_project_if_needed + it_behaves_like 'importing a repository' + end + + context 'when subgroups are not available' do + let(:project_path) { 'a-group/a-sub-group/a-project' } + + before do + expect(Group).to receive(:supports_nested_groups?) { false } + end - expect(Project.find_by_full_path(project_path)).not_to be_nil + describe '#create_project_if_needed' do + it 'raises an error' do + expect { importer.create_project_if_needed }.to raise_error('Nested groups are not supported on MySQL') + end end end end diff --git a/spec/services/groups/nested_create_service_spec.rb b/spec/services/groups/nested_create_service_spec.rb index 6d11edb5842..6491fb34777 100644 --- a/spec/services/groups/nested_create_service_spec.rb +++ b/spec/services/groups/nested_create_service_spec.rb @@ -2,52 +2,87 @@ require 'spec_helper' describe Groups::NestedCreateService do let(:user) { create(:user) } - let(:params) { { group_path: 'a-group/a-sub-group' } } subject(:service) { described_class.new(user, params) } - describe "#execute" do - it 'returns the group if it already existed' do - parent = create(:group, path: 'a-group', owner: user) - child = create(:group, path: 'a-sub-group', parent: parent, owner: user) + shared_examples 'with a visibility level' do + it 'creates the group with correct visibility level' do + allow(Gitlab::CurrentSettings.current_application_settings) + .to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL } + + group = service.execute - expect(service.execute).to eq(child) + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) end - it 'reuses a parent if it already existed', :nested_groups do - parent = create(:group, path: 'a-group') - parent.add_owner(user) + context 'adding a visibility level ' do + it 'overwrites the visibility level' do + service = described_class.new(user, params.merge(visibility_level: Gitlab::VisibilityLevel::PRIVATE)) + + group = service.execute - expect(service.execute.parent).to eq(parent) + expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + end end + end + + describe 'without subgroups' do + let(:params) { { group_path: 'a-group' } } - it 'creates group and subgroup in the database', :nested_groups do - service.execute + before do + allow(Group).to receive(:supports_nested_groups?) { false } + end - parent = Group.find_by_full_path('a-group') - child = parent.children.find_by(path: 'a-sub-group') + it 'creates the group' do + group = service.execute - expect(parent).not_to be_nil - expect(child).not_to be_nil + expect(group).to be_persisted end - it 'creates the group with correct visibility level' do - allow(Gitlab::CurrentSettings.current_application_settings) - .to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL } + it 'returns the group if it already existed' do + existing_group = create(:group, path: 'a-group') - group = service.execute + expect(service.execute).to eq(existing_group) + end - expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL) + it 'raises an error when tring to create a subgroup' do + service = described_class.new(user, group_path: 'a-group/a-sub-group') + + expect { service.execute }.to raise_error('Nested groups are not supported on MySQL') end - context 'adding a visibility level ' do - let(:params) { { group_path: 'a-group/a-sub-group', visibility_level: Gitlab::VisibilityLevel::PRIVATE } } + it_behaves_like 'with a visibility level' + end - it 'overwrites the visibility level' do - group = service.execute + describe 'with subgroups', :nested_groups do + let(:params) { { group_path: 'a-group/a-sub-group' } } - expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + describe "#execute" do + it 'returns the group if it already existed' do + parent = create(:group, path: 'a-group', owner: user) + child = create(:group, path: 'a-sub-group', parent: parent, owner: user) + + expect(service.execute).to eq(child) end + + it 'reuses a parent if it already existed' do + parent = create(:group, path: 'a-group') + parent.add_owner(user) + + expect(service.execute.parent).to eq(parent) + end + + it 'creates group and subgroup in the database' do + service.execute + + parent = Group.find_by_full_path('a-group') + child = parent.children.find_by(path: 'a-sub-group') + + expect(parent).not_to be_nil + expect(child).not_to be_nil + end + + it_behaves_like 'with a visibility level' end end end -- cgit v1.2.1 From a8176662ae28e96120ee182afa40b3220619ab02 Mon Sep 17 00:00:00 2001 From: Marcia Ramos Date: Fri, 25 Aug 2017 11:18:20 +0000 Subject: Docs: update - fix headers --- doc/install/azure/index.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/install/azure/index.md b/doc/install/azure/index.md index 9842d99ed02..9cc4b56c932 100644 --- a/doc/install/azure/index.md +++ b/doc/install/azure/index.md @@ -10,7 +10,7 @@ like Ubuntu, Red Hat Enterprise Linux, and of course - GitLab! This means that y pre-configured GitLab VM and have your very own private GitLab up and running in around 30 minutes. Let's get started. -### Getting started +## Getting started First, you'll need an account on Azure. There are three ways to do this: @@ -25,7 +25,7 @@ This is a great way to try out Azure and cloud computing, and you can subscription gives you recurring Azure credits every month, so why not put those credits to use and try out GitLab right now? -### Working with Azure +## Working with Azure Once you have an Azure account, you can get started. Login to Azure using [portal.azure.com](https://portal.azure.com) and the first thing you will see is the Dashboard: @@ -35,7 +35,7 @@ Once you have an Azure account, you can get started. Login to Azure using The Dashboard gives you a quick overview of Azure resources, and from here you you can build VMs, create SQL Databases, author websites, and perform lots of other cloud tasks. -### Create New VM +## Create New VM The [Azure Marketplace][Azure-Marketplace] is an online store for pre-configured applications and services which have been optimized for the cloud by software vendors like GitLab, and both @@ -56,7 +56,7 @@ Click **"Create"** and you will be presented with the "Create virtual machine" b ![Azure - Create Virtual Machine - Basics](img/azure-create-virtual-machine-basics.png) -### Basics +## Basics The first items we need to configure are the basic settings of the underlying virtual machine: @@ -84,7 +84,7 @@ Here are the settings we've used: Check the settings you have entered, and then click **"OK"** when you're ready to proceed. -### Size +## Size Next, you need to choose the size of your VM - selecting features such as the number of CPU cores, the amount of RAM, the size of storage (and its speed), etc. @@ -108,7 +108,7 @@ free trial credits, you'll likely want to learn Go ahead and click your chosen size, then click **"Select"** when you're ready to proceed to the next step. -### Settings +## Settings On the next blade, you're asked to configure the Storage, Network and Extension settings. We've gone with the default settings as they're sufficient for test-driving GitLab, but please @@ -118,7 +118,7 @@ choose the settings which best meet your own requirements: Review the settings and then click **"OK"** when you're ready to proceed to the last step. -### Purchase +## Purchase The Purchase page is the last step and here you will be presented with the price per hour for your new VM. You'll be billed only for the VM itself (e.g. "Standard DS1 v2") because the @@ -131,7 +131,7 @@ previous steps, just click on any of the four steps to re-open them. When you have read and agreed to the terms of use and are ready to proceed, click **"Purchase"**. -### Deployment +## Deployment At this point, Azure will begin deploying your new VM. The deployment process will take a few minutes to complete, with progress displayed on the **"Deployment"** blade: @@ -146,7 +146,7 @@ on the Azure Dashboard (you may need to refresh the page): The new VM can also be accessed by clicking the `All resources` or `Virtual machines` icons in the Azure Portal sidebar navigation menu. -### Setup a domain name +## Setup a domain name The VM will have a public IP address (static by default), but Azure allows us to assign a friendly DNS name to the VM, so let's go ahead and do that. @@ -174,7 +174,7 @@ to make sure your VM is configured to use a _static_ public IP address (i.e. not or you will have to reconfigure the DNS `A` record each time Azure reassigns your VM a new public IP address. Read [IP address types and allocation methods in Azure][Azure-IP-Address-Types] to learn more. -### Let's open some ports! +## Let's open some ports! At this stage you should have a running and fully operational VM. However, none of the services on your VM (e.g. GitLab) will be publicly accessible via the internet until you have opened up the @@ -202,7 +202,7 @@ Next, click **"Add"**: ![Azure - Network security group - Inbound security rules - Add](img/azure-nsg-inbound-sec-rules-add-highlight.png) -#### Which ports to open? +### Which ports to open? Like all servers, our VM will be running many services. However, we want to open up the correct ports to enable public internet access to two services in particular: @@ -213,7 +213,7 @@ public access to the instance of GitLab running on our VM. allowing public access (with authentication) to remote terminal sessions _(you'll see why we need [SSH] access to our VM [later on in this tutorial](#maintaining-your-gitlab-instance))_ -#### Open HTTP on Port 80 +### Open HTTP on Port 80 In the **"Add inbound security rule"** blade, let's open port 80 so that our VM will accept HTTP connections: @@ -225,7 +225,7 @@ connections: 1. Make sure the `Action` is set to **Allow** 1. Click **"OK"** -#### Open SSH on Port 22 +### Open SSH on Port 22 Repeat the above process, adding a second Inbound security rule to open port 22, enabling our VM to accept [SSH] connections: -- cgit v1.2.1 From 2d4744c34c947d98a8c6f88c4a66eefbc7e8bb4c Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 24 Aug 2017 21:50:05 +0800 Subject: Make default trigger factory generate an owner And specify owners more clearly --- spec/factories/ci/triggers.rb | 2 ++ spec/requests/api/triggers_spec.rb | 6 ++---- spec/requests/api/v3/triggers_spec.rb | 5 ++++- spec/services/ci/create_pipeline_service_spec.rb | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/factories/ci/triggers.rb b/spec/factories/ci/triggers.rb index 40c4663c6d8..3734c7040c0 100644 --- a/spec/factories/ci/triggers.rb +++ b/spec/factories/ci/triggers.rb @@ -1,5 +1,7 @@ FactoryGirl.define do factory :ci_trigger_without_token, class: Ci::Trigger do + owner + factory :ci_trigger do sequence(:token) { |n| "token#{n}" } end diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 572e9a0fd07..9a98e217643 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -8,8 +8,8 @@ describe API::Triggers do let!(:project) { create(:project, :repository, creator: user) } let!(:master) { create(:project_member, :master, user: user, project: project) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) } - let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) } - let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2) } + let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token, owner: user) } + let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2, owner: user2) } let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') } describe 'POST /projects/:project_id/trigger/pipeline' do @@ -254,8 +254,6 @@ describe API::Triggers do describe 'POST /projects/:id/triggers/:trigger_id/take_ownership' do context 'authenticated user with valid permissions' do it 'updates owner' do - expect(trigger.owner).to be_nil - post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user) expect(response).to have_http_status(200) diff --git a/spec/requests/api/v3/triggers_spec.rb b/spec/requests/api/v3/triggers_spec.rb index 075de2c0cba..d4648136841 100644 --- a/spec/requests/api/v3/triggers_spec.rb +++ b/spec/requests/api/v3/triggers_spec.rb @@ -7,7 +7,10 @@ describe API::V3::Triggers do let!(:project) { create(:project, :repository, creator: user) } let!(:master) { create(:project_member, :master, user: user, project: project) } let!(:developer) { create(:project_member, :developer, user: user2, project: project) } - let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token) } + + let!(:trigger) do + create(:ci_trigger, project: project, token: trigger_token, owner: user) + end describe 'POST /projects/:project_id/trigger' do let!(:project2) { create(:project) } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 8465a6f99bd..fdd0cea4f3b 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -470,7 +470,8 @@ describe Ci::CreatePipelineService do context 'when ref is not protected' do context 'when trigger belongs to no one' do let(:user) {} - let(:trigger_request) { create(:ci_trigger_request) } + let(:trigger) { create(:ci_trigger, owner: nil) } + let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) } it 'creates a pipeline' do expect(execute_service(trigger_request: trigger_request)) -- cgit v1.2.1 From 4a14efb00ef148884fec56e4a06b7ff748b38115 Mon Sep 17 00:00:00 2001 From: Dimitrie Hoekstra Date: Fri, 25 Aug 2017 12:19:26 +0000 Subject: Add support for copying permalink to notes via more actions dropdown --- app/assets/javascripts/copy_to_clipboard.js | 14 ++--- app/helpers/button_helper.rb | 20 ++++--- .../notes/_more_actions_dropdown.html.haml | 2 + changelogs/unreleased/35811-copy-link-note.yml | 5 ++ spec/helpers/button_helper_spec.rb | 63 ++++++++++++++++++++++ 5 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 changelogs/unreleased/35811-copy-link-note.yml diff --git a/app/assets/javascripts/copy_to_clipboard.js b/app/assets/javascripts/copy_to_clipboard.js index ab9a8e43dd1..1f3c7e1772d 100644 --- a/app/assets/javascripts/copy_to_clipboard.js +++ b/app/assets/javascripts/copy_to_clipboard.js @@ -29,12 +29,14 @@ showTooltip = function(target, title) { var $target = $(target); var originalTitle = $target.data('original-title'); - $target - .attr('title', 'Copied') - .tooltip('fixTitle') - .tooltip('show') - .attr('title', originalTitle) - .tooltip('fixTitle'); + if (!$target.data('hideTooltip')) { + $target + .attr('title', 'Copied') + .tooltip('fixTitle') + .tooltip('show') + .attr('title', originalTitle) + .tooltip('fixTitle'); + } }; $(function() { diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index bf9ad95b7c2..48cf30a48ab 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -20,6 +20,9 @@ module ButtonHelper def clipboard_button(data = {}) css_class = data[:class] || 'btn-clipboard btn-transparent' title = data[:title] || 'Copy to clipboard' + button_text = data[:button_text] || '' + hide_tooltip = data[:hide_tooltip] || false + hide_button_icon = data[:hide_button_icon] || false # This supports code in app/assets/javascripts/copy_to_clipboard.js that # works around ClipboardJS limitations to allow the context-specific copy/pasting of plain text or GFM. @@ -35,17 +38,22 @@ module ButtonHelper target = data.delete(:target) data[:clipboard_target] = target if target - data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data) + unless hide_tooltip + data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data) + end - content_tag :button, - icon('clipboard', 'aria-hidden': 'true'), + button_attributes = { class: "btn #{css_class}", data: data, type: :button, title: title, - aria: { - label: title - } + aria: { label: title } + } + + content_tag :button, button_attributes do + concat(icon('clipboard', 'aria-hidden': 'true')) unless hide_button_icon + concat(button_text) + end end def http_clone_button(project, placement = 'right', append_link: true) diff --git a/app/views/projects/notes/_more_actions_dropdown.html.haml b/app/views/projects/notes/_more_actions_dropdown.html.haml index 5930209a682..7e854186973 100644 --- a/app/views/projects/notes/_more_actions_dropdown.html.haml +++ b/app/views/projects/notes/_more_actions_dropdown.html.haml @@ -6,6 +6,8 @@ %span.icon = custom_icon('ellipsis_v') %ul.dropdown-menu.more-actions-dropdown.dropdown-open-left + %li + = clipboard_button(text: noteable_note_url(note), title: "Copy reference to clipboard", button_text: 'Copy link', hide_tooltip: true, hide_button_icon: true) - unless is_current_user %li = link_to new_abuse_report_path(user_id: note.author.id, ref_url: noteable_note_url(note)) do diff --git a/changelogs/unreleased/35811-copy-link-note.yml b/changelogs/unreleased/35811-copy-link-note.yml new file mode 100644 index 00000000000..9fa74884c8a --- /dev/null +++ b/changelogs/unreleased/35811-copy-link-note.yml @@ -0,0 +1,5 @@ +--- +title: Add support for copying permalink to notes via more actions dropdown +merge_request: 13299 +author: +type: added diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb index 250ba239033..4423560ecaa 100644 --- a/spec/helpers/button_helper_spec.rb +++ b/spec/helpers/button_helper_spec.rb @@ -62,4 +62,67 @@ describe ButtonHelper do end end end + + describe 'clipboard_button' do + let(:user) { create(:user) } + let(:project) { build_stubbed(:project) } + + def element(data = {}) + element = helper.clipboard_button(data) + Nokogiri::HTML::DocumentFragment.parse(element).first_element_child + end + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'with default options' do + context 'when no `text` attribute is not provided' do + it 'shows copy to clipboard button with default configuration and no text set to copy' do + expect(element.attr('class')).to eq('btn btn-clipboard btn-transparent') + expect(element.attr('type')).to eq('button') + expect(element.attr('aria-label')).to eq('Copy to clipboard') + expect(element.attr('data-toggle')).to eq('tooltip') + expect(element.attr('data-placement')).to eq('bottom') + expect(element.attr('data-container')).to eq('body') + expect(element.attr('data-clipboard-text')).to eq(nil) + expect(element.inner_text).to eq("") + + expect(element).to have_selector('.fa.fa-clipboard') + end + end + + context 'when `text` attribute is provided' do + it 'shows copy to clipboard button with provided `text` to copy' do + expect(element(text: 'Hello World!').attr('data-clipboard-text')).to eq('Hello World!') + end + end + + context 'when `title` attribute is provided' do + it 'shows copy to clipboard button with provided `title` as tooltip' do + expect(element(title: 'Copy to my clipboard!').attr('aria-label')).to eq('Copy to my clipboard!') + end + end + end + + context 'with `button_text` attribute provided' do + it 'shows copy to clipboard button with provided `button_text` as button label' do + expect(element(button_text: 'Copy text').inner_text).to eq('Copy text') + end + end + + context 'with `hide_tooltip` attribute provided' do + it 'shows copy to clipboard button without tooltip support' do + expect(element(hide_tooltip: true).attr('data-placement')).to eq(nil) + expect(element(hide_tooltip: true).attr('data-toggle')).to eq(nil) + expect(element(hide_tooltip: true).attr('data-container')).to eq(nil) + end + end + + context 'with `hide_button_icon` attribute provided' do + it 'shows copy to clipboard button without tooltip support' do + expect(element(hide_button_icon: true)).not_to have_selector('.fa.fa-clipboard') + end + end + end end -- cgit v1.2.1 From e984a8a3543fa9a26308cea35a42046392f4a488 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 25 Aug 2017 14:22:28 +0200 Subject: Migrate new jobs when reverting pipeline queues migration --- .../20170822101017_migrate_pipeline_sidekiq_queues.rb | 3 +++ spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb index 48fa3af0c60..8441cfe7968 100644 --- a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb +++ b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb @@ -10,5 +10,8 @@ class MigratePipelineSidekiqQueues < ActiveRecord::Migration def down sidekiq_queue_migrate 'pipeline_default', to: 'pipeline' + sidekiq_queue_migrate 'pipeline_processing', to: 'pipeline' + sidekiq_queue_migrate 'pipeline_hooks', to: 'pipeline' + sidekiq_queue_migrate 'pipeline_cache', to: 'pipeline' end end diff --git a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb index fff531a78c5..e02bcd2f4da 100644 --- a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb +++ b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb @@ -21,12 +21,17 @@ describe MigratePipelineSidekiqQueues, :sidekiq, :redis do it 'correctly migrates queue when migrating down' do Sidekiq::Testing.disable! do stubbed_worker(queue: :pipeline_default).perform_async('Class', [1]) - stubbed_worker(queue: :pipeline_default).perform_async('Class', [2]) + stubbed_worker(queue: :pipeline_processing).perform_async('Class', [2]) + stubbed_worker(queue: :pipeline_hooks).perform_async('Class', [3]) + stubbed_worker(queue: :pipeline_cache).perform_async('Class', [4]) described_class.new.down - expect(sidekiq_queue_length('pipeline')).to eq 2 + expect(sidekiq_queue_length('pipeline')).to eq 4 expect(sidekiq_queue_length('pipeline_default')).to eq 0 + expect(sidekiq_queue_length('pipeline_processing')).to eq 0 + expect(sidekiq_queue_length('pipeline_hooks')).to eq 0 + expect(sidekiq_queue_length('pipeline_cache')).to eq 0 end end end -- cgit v1.2.1 From 32b688e78572803f4557c5f78d1585b3ca6e8fbd Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 24 Aug 2017 12:24:58 -0700 Subject: Enable 5 lines of Sidekiq backtrace lines to aid in debugging Customers often have Sidekiq jobs that failed without much context. Without Sentry, there's no way to tell where these exceptions were hit. Adding in additional lines adds a bit more Redis storage overhead. This commit adds in backtrace logging for workers that delete groups/projects and import/export projects. Closes #27626 --- app/workers/concerns/exception_backtrace.rb | 8 ++++++++ app/workers/group_destroy_worker.rb | 1 + app/workers/namespaceless_project_destroy_worker.rb | 1 + app/workers/project_destroy_worker.rb | 1 + app/workers/project_export_worker.rb | 1 + app/workers/repository_import_worker.rb | 1 + 6 files changed, 13 insertions(+) create mode 100644 app/workers/concerns/exception_backtrace.rb diff --git a/app/workers/concerns/exception_backtrace.rb b/app/workers/concerns/exception_backtrace.rb new file mode 100644 index 00000000000..ea0f1f8d19b --- /dev/null +++ b/app/workers/concerns/exception_backtrace.rb @@ -0,0 +1,8 @@ +# Concern for enabling a few lines of exception backtraces in Sidekiq +module ExceptionBacktrace + extend ActiveSupport::Concern + + included do + sidekiq_options backtrace: 5 + end +end diff --git a/app/workers/group_destroy_worker.rb b/app/workers/group_destroy_worker.rb index 07e82767b06..bd8e212e928 100644 --- a/app/workers/group_destroy_worker.rb +++ b/app/workers/group_destroy_worker.rb @@ -1,6 +1,7 @@ class GroupDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def perform(group_id, user_id) begin diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb index 1cfb0be759e..f1cd1769421 100644 --- a/app/workers/namespaceless_project_destroy_worker.rb +++ b/app/workers/namespaceless_project_destroy_worker.rb @@ -7,6 +7,7 @@ class NamespacelessProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def self.bulk_perform_async(args_list) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list) diff --git a/app/workers/project_destroy_worker.rb b/app/workers/project_destroy_worker.rb index a9188b78460..3be7e686609 100644 --- a/app/workers/project_destroy_worker.rb +++ b/app/workers/project_destroy_worker.rb @@ -1,6 +1,7 @@ class ProjectDestroyWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace def perform(project_id, user_id, params) project = Project.find(project_id) diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb index 6009aa1b191..f13ac9e5db2 100644 --- a/app/workers/project_export_worker.rb +++ b/app/workers/project_export_worker.rb @@ -1,6 +1,7 @@ class ProjectExportWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace sidekiq_options retry: 3 diff --git a/app/workers/repository_import_worker.rb b/app/workers/repository_import_worker.rb index 2c2d1e8b91f..00a021abbdc 100644 --- a/app/workers/repository_import_worker.rb +++ b/app/workers/repository_import_worker.rb @@ -3,6 +3,7 @@ class RepositoryImportWorker include Sidekiq::Worker include DedicatedSidekiqQueue + include ExceptionBacktrace sidekiq_options status_expiration: StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION -- cgit v1.2.1 From 8b73df0cf534797bff9ce0f5b95af5347ea59ca6 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 23 Aug 2017 15:28:16 +0100 Subject: Move sidekiq-based project authorization refresh out of Projects::CreateService If the project is in a group, the `group.refresh_members_authorized_projects` is made non-blocking, and we call `current_user.refresh_authorized_projects` directly. Projects in a personal namespace are more difficult. Rather than passing the `blocking:` parameter through the entire `add_master` chain, have the `AuthorizedProjectsWorker` automatically inline authorizations for three IDs or less. Since the maximum number of IDs in this path is 2, that has the same effect. --- app/models/group.rb | 4 +- app/services/projects/create_service.rb | 16 +++++-- .../user_project_access_changed_service.rb | 10 +++- app/workers/authorized_projects_worker.rb | 22 ++++++++- ...2-inline-user-refresh-when-creating-project.yml | 5 ++ .../user_project_access_changed_service_spec.rb | 7 +++ spec/workers/authorized_projects_worker_spec.rb | 55 ++++++++++++++++++++-- 7 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 changelogs/unreleased/36792-inline-user-refresh-when-creating-project.yml diff --git a/app/models/group.rb b/app/models/group.rb index 2816a68257c..cb3ee032f69 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -206,9 +206,9 @@ class Group < Namespace SystemHooksService.new end - def refresh_members_authorized_projects + def refresh_members_authorized_projects(blocking: true) UserProjectAccessChangedService.new(user_ids_for_project_authorizations) - .execute + .execute(blocking: blocking) end def user_ids_for_project_authorizations diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 48578b6d9e5..0d6066b70c7 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -99,12 +99,22 @@ module Projects event_service.create_project(@project, current_user) system_hook_service.execute_hooks_for(@project, :create) - unless @project.group || @project.gitlab_project_import? + setup_authorizations + end + + # Refresh the current user's authorizations inline (so they can access the + # project immediately after this request completes), and any other affected + # users in the background + def setup_authorizations + group = @project.group + group&.refresh_members_authorized_projects(blocking: false) + + if group || @project.gitlab_project_import? + current_user.refresh_authorized_projects + else owners = [current_user, @project.namespace.owner].compact.uniq @project.add_master(owners, current_user: current_user) end - - @project.group&.refresh_members_authorized_projects end def skip_wiki? diff --git a/app/services/user_project_access_changed_service.rb b/app/services/user_project_access_changed_service.rb index d7a6804ee88..8630e572624 100644 --- a/app/services/user_project_access_changed_service.rb +++ b/app/services/user_project_access_changed_service.rb @@ -3,7 +3,13 @@ class UserProjectAccessChangedService @user_ids = Array.wrap(user_ids) end - def execute - AuthorizedProjectsWorker.bulk_perform_and_wait(@user_ids.map { |id| [id] }) + def execute(blocking: true) + bulk_args = @user_ids.map { |id| [id] } + + if blocking + AuthorizedProjectsWorker.bulk_perform_and_wait(bulk_args) + else + AuthorizedProjectsWorker.bulk_perform_async(bulk_args) + end end end diff --git a/app/workers/authorized_projects_worker.rb b/app/workers/authorized_projects_worker.rb index be4c77503bb..55d8d0c69d1 100644 --- a/app/workers/authorized_projects_worker.rb +++ b/app/workers/authorized_projects_worker.rb @@ -4,20 +4,40 @@ class AuthorizedProjectsWorker # Schedules multiple jobs and waits for them to be completed. def self.bulk_perform_and_wait(args_list) + # Short-circuit: it's more efficient to do small numbers of jobs inline + return bulk_perform_inline(args_list) if args_list.size <= 3 + waiter = Gitlab::JobWaiter.new(args_list.size) # Point all the bulk jobs at the same JobWaiter. Converts, [[1], [2], [3]] # into [[1, "key"], [2, "key"], [3, "key"]] - waiting_args_list = args_list.map { |args| args << waiter.key } + waiting_args_list = args_list.map { |args| [*args, waiter.key] } bulk_perform_async(waiting_args_list) waiter.wait end + # Schedules multiple jobs to run in sidekiq without waiting for completion def self.bulk_perform_async(args_list) Sidekiq::Client.push_bulk('class' => self, 'queue' => sidekiq_options['queue'], 'args' => args_list) end + # Performs multiple jobs directly. Failed jobs will be put into sidekiq so + # they can benefit from retries + def self.bulk_perform_inline(args_list) + failed = [] + + args_list.each do |args| + begin + new.perform(*args) + rescue + failed << args + end + end + + bulk_perform_async(failed) if failed.present? + end + def perform(user_id, notify_key = nil) user = User.find_by(id: user_id) diff --git a/changelogs/unreleased/36792-inline-user-refresh-when-creating-project.yml b/changelogs/unreleased/36792-inline-user-refresh-when-creating-project.yml new file mode 100644 index 00000000000..be08da0433a --- /dev/null +++ b/changelogs/unreleased/36792-inline-user-refresh-when-creating-project.yml @@ -0,0 +1,5 @@ +--- +title: Never wait for sidekiq jobs when creating projects +merge_request: 13775 +author: +type: other diff --git a/spec/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb index 14a5e40350a..87a90378e2b 100644 --- a/spec/services/user_project_access_changed_service_spec.rb +++ b/spec/services/user_project_access_changed_service_spec.rb @@ -8,5 +8,12 @@ describe UserProjectAccessChangedService do described_class.new([1, 2]).execute end + + it 'permits non-blocking operation' do + expect(AuthorizedProjectsWorker).to receive(:bulk_perform_async) + .with([[1], [2]]) + + described_class.new([1, 2]).execute(blocking: false) + end end end diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb index f8385ae7c72..90ed1309d4a 100644 --- a/spec/workers/authorized_projects_worker_spec.rb +++ b/spec/workers/authorized_projects_worker_spec.rb @@ -3,28 +3,75 @@ require 'spec_helper' describe AuthorizedProjectsWorker do let(:project) { create(:project) } + def build_args_list(*ids, multiply: 1) + args_list = ids.map { |id| [id] } + args_list * multiply + end + describe '.bulk_perform_and_wait' do it 'schedules the ids and waits for the jobs to complete' do + args_list = build_args_list(project.owner.id) + + project.owner.project_authorizations.delete_all + described_class.bulk_perform_and_wait(args_list) + + expect(project.owner.project_authorizations.count).to eq(1) + end + + it 'inlines workloads <= 3 jobs' do + args_list = build_args_list(project.owner.id, multiply: 3) + expect(described_class).to receive(:bulk_perform_inline).with(args_list) + + described_class.bulk_perform_and_wait(args_list) + end + + it 'runs > 3 jobs using sidekiq' do + project.owner.project_authorizations.delete_all + + expect(described_class).to receive(:bulk_perform_async).and_call_original + + args_list = build_args_list(project.owner.id, multiply: 4) + described_class.bulk_perform_and_wait(args_list) + + expect(project.owner.project_authorizations.count).to eq(1) + end + end + + describe '.bulk_perform_inline' do + it 'refreshes the authorizations inline' do project.owner.project_authorizations.delete_all - described_class.bulk_perform_and_wait([[project.owner.id]]) + expect_any_instance_of(described_class).to receive(:perform).and_call_original + + described_class.bulk_perform_inline(build_args_list(project.owner.id)) expect(project.owner.project_authorizations.count).to eq(1) end + + it 'enqueues jobs if an error is raised' do + invalid_id = -1 + args_list = build_args_list(project.owner.id, invalid_id) + + allow_any_instance_of(described_class).to receive(:perform).with(project.owner.id) + allow_any_instance_of(described_class).to receive(:perform).with(invalid_id).and_raise(ArgumentError) + expect(described_class).to receive(:bulk_perform_async).with(build_args_list(invalid_id)) + + described_class.bulk_perform_inline(args_list) + end end describe '.bulk_perform_async' do it "uses it's respective sidekiq queue" do - args = [[project.owner.id]] + args_list = build_args_list(project.owner.id) push_bulk_args = { 'class' => described_class, 'queue' => described_class.sidekiq_options['queue'], - 'args' => args + 'args' => args_list } expect(Sidekiq::Client).to receive(:push_bulk).with(push_bulk_args).once - described_class.bulk_perform_async(args) + described_class.bulk_perform_async(args_list) end end -- cgit v1.2.1 From 66e18a128498d6f3fab193a80c6b4f45f2c3d7fc Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Fri, 25 Aug 2017 16:21:27 +0100 Subject: Don't add admins as masters to projects created in another user's namespace Only admins have the ability to create a project in another user's personal namespace. Prior to this commit, we were explicitly adding them as masters to the project. However, admins already have access (by virture of being admins), so this is unnecessary. --- app/services/projects/create_service.rb | 3 +-- spec/services/projects/create_service_spec.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 0d6066b70c7..68e592d79c3 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -112,8 +112,7 @@ module Projects if group || @project.gitlab_project_import? current_user.refresh_authorized_projects else - owners = [current_user, @project.namespace.owner].compact.uniq - @project.add_master(owners, current_user: current_user) + @project.add_master(@project.namespace.owner, current_user: current_user) end end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index b0dc7488b5f..088b7b4fc04 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -38,7 +38,7 @@ describe Projects::CreateService, '#execute' do expect(project).to be_persisted expect(project.owner).to eq(user) - expect(project.team.masters).to include(user, admin) + expect(project.team.masters).to contain_exactly(user) expect(project.namespace).to eq(user.namespace) end end -- cgit v1.2.1 From 0a1160e5d7d8234fa9e88038608a37c0f7fe2b05 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Fri, 25 Aug 2017 16:32:06 +0100 Subject: Don't treat gitlab project imports specially in Projects::CreateService --- app/services/projects/create_service.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb index 68e592d79c3..a0cd52014a2 100644 --- a/app/services/projects/create_service.rb +++ b/app/services/projects/create_service.rb @@ -106,10 +106,8 @@ module Projects # project immediately after this request completes), and any other affected # users in the background def setup_authorizations - group = @project.group - group&.refresh_members_authorized_projects(blocking: false) - - if group || @project.gitlab_project_import? + if @project.group + @project.group.refresh_members_authorized_projects(blocking: false) current_user.refresh_authorized_projects else @project.add_master(@project.namespace.owner, current_user: current_user) -- cgit v1.2.1 From e85362d5fff886df3118630cbdc46e469322fbeb Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 24 Aug 2017 20:28:44 -0500 Subject: Update and fix resolvable note icons for easier recognition --- app/assets/stylesheets/framework/variables.scss | 1 + app/assets/stylesheets/pages/notes.scss | 14 +++++++++++--- app/views/projects/notes/_actions.html.haml | 8 ++++++-- app/views/shared/icons/_icon_status_success.svg | 2 +- app/views/shared/icons/_icon_status_success_solid.svg | 1 + changelogs/unreleased/36582-fix-note-resolved-icon.yml | 5 +++++ 6 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/views/shared/icons/_icon_status_success_solid.svg create mode 100644 changelogs/unreleased/36582-fix-note-resolved-icon.yml diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 8a2e64f7bf5..26920869bec 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -120,6 +120,7 @@ $gl-text-color-quaternary: #d6d6d6; $gl-text-color-inverted: rgba(255, 255, 255, 1.0); $gl-text-color-secondary-inverted: rgba(255, 255, 255, .85); $gl-text-green: $green-600; +$gl-text-green-hover: $green-700; $gl-text-red: $red-500; $gl-text-orange: $orange-600; $gl-link-color: $blue-600; diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index 0a194f3707f..fbfe5d3c682 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -766,17 +766,25 @@ ul.notes { background-color: transparent; border: none; outline: 0; + transition: color $general-hover-transition-duration $general-hover-transition-curve; &.is-disabled { cursor: default; } - &:not(.is-disabled):hover, + &:not(.is-disabled) { + &:hover, + &:focus { + color: $gl-text-green; + } + } + &.is-active { color: $gl-text-green; - svg { - fill: $gl-text-green; + &:hover, + &:focus { + color: $gl-text-green-hover; } } diff --git a/app/views/projects/notes/_actions.html.haml b/app/views/projects/notes/_actions.html.haml index cb737d129f0..b04f5efe1f9 100644 --- a/app/views/projects/notes/_actions.html.haml +++ b/app/views/projects/notes/_actions.html.haml @@ -26,8 +26,12 @@ ":title" => "buttonText", ":ref" => "'button'" } - = icon('spin spinner', 'v-show' => 'loading', class: 'loading', 'aria-hidden' => 'true', 'aria-label' => 'Loading') - %div{ 'v-show' => '!loading' }= render 'shared/icons/icon_status_success.svg' + = icon('spin spinner', 'v-if' => 'loading', class: 'loading', 'aria-hidden' => 'true', 'aria-label' => 'Loading') + %div{ 'v-else' => '' } + %template{ 'v-if' => 'isResolved' } + = render 'shared/icons/icon_status_success_solid.svg' + %template{ 'v-else' => '' } + = render 'shared/icons/icon_status_success.svg' - if current_user - if note.emoji_awardable? diff --git a/app/views/shared/icons/_icon_status_success.svg b/app/views/shared/icons/_icon_status_success.svg index eed5006bebe..845562e9320 100755 --- a/app/views/shared/icons/_icon_status_success.svg +++ b/app/views/shared/icons/_icon_status_success.svg @@ -1 +1 @@ - + diff --git a/app/views/shared/icons/_icon_status_success_solid.svg b/app/views/shared/icons/_icon_status_success_solid.svg new file mode 100644 index 00000000000..0aac6d933e1 --- /dev/null +++ b/app/views/shared/icons/_icon_status_success_solid.svg @@ -0,0 +1 @@ + diff --git a/changelogs/unreleased/36582-fix-note-resolved-icon.yml b/changelogs/unreleased/36582-fix-note-resolved-icon.yml new file mode 100644 index 00000000000..758c0ecd212 --- /dev/null +++ b/changelogs/unreleased/36582-fix-note-resolved-icon.yml @@ -0,0 +1,5 @@ +--- +title: Update and fix resolvable note icons for easier recognition +merge_request: +author: +type: changed -- cgit v1.2.1 From ad097512c9eb918e1fe83f502286fb8fed31ff50 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 21 Aug 2017 12:50:06 -0500 Subject: fix deprecation warning present during webpack compiles --- config/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/webpack.config.js b/config/webpack.config.js index 6a347c2e660..a75f9e86fd6 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -171,7 +171,7 @@ var config = { if (chunk.name) { return chunk.name; } - return chunk.modules.map((m) => { + return chunk.mapModules((m) => { var chunkPath = m.request.split('!').pop(); return path.relative(m.context, chunkPath); }).join('_'); -- cgit v1.2.1 From bd1be9bb43fa08f79843fb786b61487a256f7c2c Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Fri, 25 Aug 2017 16:36:42 +0000 Subject: Remove 'dependent: :destroy' from ProtectedRef has_many :"#{type}_access_levels" --- app/models/concerns/protected_ref.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb index ef95d6b0f98..454374121f3 100644 --- a/app/models/concerns/protected_ref.rb +++ b/app/models/concerns/protected_ref.rb @@ -23,7 +23,7 @@ module ProtectedRef # If we don't `protected_branch` or `protected_tag` would be empty and # `project` cannot be delegated to it, which in turn would cause validations # to fail. - has_many :"#{type}_access_levels", dependent: :destroy, inverse_of: self.model_name.singular # rubocop:disable Cop/ActiveRecordDependent + has_many :"#{type}_access_levels", inverse_of: self.model_name.singular # rubocop:disable Cop/ActiveRecordDependent validates :"#{type}_access_levels", length: { is: 1, message: "are restricted to a single instance per #{self.model_name.human}." } -- cgit v1.2.1 From c199535d13f7ad20e0ff92e1c24e174cdf38d569 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Thu, 24 Aug 2017 11:45:37 -0700 Subject: Reenable MySQL tests on all branches To protect master from surprise failures, as long as we continue to support MySQL. --- .gitlab-ci.yml | 15 --------------- doc/development/testing.md | 5 +---- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f356a07576..ab9627d4ab7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,19 +68,6 @@ stages: - mysql:latest - redis:alpine -.only-if-want-mysql: &only-if-want-mysql - only: - - /mysql/ - - /-stable/ - - master@gitlab-org/gitlab-ce - - master@gitlab-org/gitlab-ee - - master@gitlab/gitlabhq - - master@gitlab/gitlab-ee - - tags@gitlab-org/gitlab-ce - - tags@gitlab-org/gitlab-ee - - tags@gitlab/gitlabhq - - tags@gitlab/gitlab-ee - # Skip all jobs except the ones that begin with 'docs/'. # Used for commits including ONLY documentation changes. # https://docs.gitlab.com/ce/development/writing_documentation.html#testing @@ -124,7 +111,6 @@ stages: .rspec-metadata-mysql: &rspec-metadata-mysql <<: *rspec-metadata <<: *use-mysql - <<: *only-if-want-mysql <<: *except-docs .spinach-metadata: &spinach-metadata @@ -156,7 +142,6 @@ stages: .spinach-metadata-mysql: &spinach-metadata-mysql <<: *spinach-metadata <<: *use-mysql - <<: *only-if-want-mysql <<: *except-docs .only-canonical-masters: &only-canonical-masters diff --git a/doc/development/testing.md b/doc/development/testing.md index efd56484b12..83269303005 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -529,10 +529,7 @@ slowest test files and try to improve them. ## CI setup -- On CE, the test suite only runs against PostgreSQL by default. We additionally - run the suite against MySQL for tags, `master`, and any branch that includes - `mysql` in the name. -- On EE, the test suite always runs both PostgreSQL and MySQL. +- On CE and EE, the test suite runs both PostgreSQL and MySQL. - Rails logging to `log/test.log` is disabled by default in CI [for performance reasons][logging]. To override this setting, provide the `RAILS_ENABLE_TEST_LOG` environment variable. -- cgit v1.2.1 From d97a6cbe633a285926dea6f8c7e210dcbaa1c0ec Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Fri, 25 Aug 2017 19:23:49 +0000 Subject: Common Docker Documentation Location in `gitlab-ce` --- doc/install/README.md | 2 +- doc/install/docker.md | 18 ++++++++++++++++++ docker/README.md | 6 +----- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 doc/install/docker.md diff --git a/doc/install/README.md b/doc/install/README.md index 1d510cb29c3..656f8720361 100644 --- a/doc/install/README.md +++ b/doc/install/README.md @@ -17,7 +17,7 @@ the hardware requirements. - [Installation from source](installation.md) - Install GitLab from source. Useful for unsupported systems like *BSD. For an overview of the directory structure, read the [structure documentation](structure.md). -- [Docker](https://docs.gitlab.com/omnibus/docker/) - Install GitLab using Docker. +- [Docker](docker.md) - Install GitLab using Docker. ## Install GitLab on cloud providers diff --git a/doc/install/docker.md b/doc/install/docker.md new file mode 100644 index 00000000000..933756072ff --- /dev/null +++ b/doc/install/docker.md @@ -0,0 +1,18 @@ +# GitLab Docker images + +[Docker](https://www.docker.com) and container technology have been revolutionizing the software world for the past few years. They combine the performance and efficiency of native execution with the abstraction, security, and immutability of virtualization. + +GitLab provides official Docker images to allowing you to easily take advantage of the benefits of containerization while operating your GitLab instance. + +## Omnibus GitLab based images + +GitLab maintains a set of [official Docker images](https://hub.docker.com/r/gitlab) based on our [Omnibus GitLab package](https://docs.gitlab.com/omnibus/README.html). These images include: +* [GitLab Community Edition](https://hub.docker.com/r/gitlab/gitlab-ce/) +* [GitLab Enterprise Edition](https://hub.docker.com/r/gitlab/gitlab-ee/) +* [GitLab Runner](https://hub.docker.com/r/gitlab/gitlab-runner/) + +A [complete usage guide](https://docs.gitlab.com/omnibus/docker/) to these images is available, as well as the [Dockerfile used for building the images](https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/docker). + +## Cloud native images + +GitLab is also working towards a [cloud native set of containers](https://gitlab.com/charts/helm.gitlab.io#docker-container-images), with a single image for each component service. We intend for these images to eventually replace the [Omnibus GitLab based images](#omnibus-gitlab-based-images). diff --git a/docker/README.md b/docker/README.md index f9e12c5733b..61b41d2f109 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,7 +1,3 @@ # GitLab Docker images -* The official GitLab Community Edition Docker image is [available on Docker Hub](https://hub.docker.com/r/gitlab/gitlab-ce/). -* The official GitLab Enterprise Edition Docker image is [available on Docker Hub](https://hub.docker.com/r/gitlab/gitlab-ee/). -* The complete usage guide can be found in [Using GitLab Docker images](https://docs.gitlab.com/omnibus/docker/) -* The Dockerfile used for building public images is in [Omnibus Repository](https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/docker) -* Check the guide for [creating Omnibus-based Docker Image](https://docs.gitlab.com/omnibus/build/README.html#build-docker-image) +This content has been moved to [our documentation site](https://docs.gitlab.com/ce/install/docker.html). -- cgit v1.2.1 From 2b7f0b140a302ec3aeb11d7cb65e4b5c23421750 Mon Sep 17 00:00:00 2001 From: Annabel Dunstone Gray Date: Fri, 25 Aug 2017 15:29:27 -0500 Subject: Remove unnecessary divider --- app/views/layouts/nav/_new_admin_sidebar.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/nav/_new_admin_sidebar.html.haml b/app/views/layouts/nav/_new_admin_sidebar.html.haml index 1c3fd4a082c..f367dc5cf58 100644 --- a/app/views/layouts/nav/_new_admin_sidebar.html.haml +++ b/app/views/layouts/nav/_new_admin_sidebar.html.haml @@ -82,6 +82,7 @@ = custom_icon('messages') %span.nav-item-name Messages + = nav_link(controller: [:hooks, :hook_logs]) do = link_to admin_hooks_path, title: 'Hooks' do .nav-icon-container @@ -140,7 +141,6 @@ %span.nav-item-name Appearance - %li.divider = nav_link(controller: :application_settings) do = link_to admin_application_settings_path, title: 'Settings' do .nav-icon-container -- cgit v1.2.1 From dc5a6b614209f075bedbc756c78a207331f2efc0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 25 Aug 2017 18:37:05 -0400 Subject: Remove skipped examples in filtered issues feature spec We perform a ton of expensive setup in this spec, via both `before` and `let!`. When we use `skip` inside an `it` block, rather than skipping the block entirely via `xit`, we still perform this expensive setup, only to do absolutely nothing with it, resulting in wasted time. Minutes, in this case. Further, these specs have been sitting in our test suite for about seven months now, so the likelihood of them being addressed soon seems low. --- .../issues/filtered_search/filter_issues_spec.rb | 50 ---------------------- 1 file changed, 50 deletions(-) diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb index 2070043d842..a64c1cf220b 100644 --- a/spec/features/issues/filtered_search/filter_issues_spec.rb +++ b/spec/features/issues/filtered_search/filter_issues_spec.rb @@ -103,14 +103,6 @@ describe 'Filter issues', js: true do expect_issues_list_count(5) expect_filtered_search_input_empty end - - it 'filters issues by invalid author' do - skip('to be tested, issue #26546') - end - - it 'filters issues by multiple authors' do - skip('to be tested, issue #26546') - end end context 'author with other filters' do @@ -165,10 +157,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input(search_term) end end - - it 'sorting' do - skip('to be tested, issue #26546') - end end describe 'filter issues by assignee' do @@ -190,14 +178,6 @@ describe 'Filter issues', js: true do expect_issues_list_count(8, 1) expect_filtered_search_input_empty end - - it 'filters issues by invalid assignee' do - skip('to be tested, issue #26546') - end - - it 'filters issues by multiple assignees' do - skip('to be tested, issue #26546') - end end context 'assignee with other filters' do @@ -250,12 +230,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input(search_term) end end - - context 'sorting' do - it 'sorts' do - skip('to be tested, issue #26546') - end - end end describe 'filter issues by label' do @@ -278,10 +252,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input_empty end - it 'filters issues by invalid label' do - skip('to be tested, issue #26546') - end - it 'filters issues by multiple labels' do input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title}") @@ -493,12 +463,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input_empty end end - - context 'sorting' do - it 'sorts' do - skip('to be tested, issue #26546') - end - end end describe 'filter issues by milestone' do @@ -535,14 +499,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input_empty end - it 'filters issues by invalid milestones' do - skip('to be tested, issue #26546') - end - - it 'filters issues by multiple milestones' do - skip('to be tested, issue #26546') - end - it 'filters issues by milestone containing special characters' do special_milestone = create(:milestone, title: '!@\#{$%^&*()}', project: project) create(:issue, title: "Issue with special character milestone", project: project, milestone: special_milestone) @@ -618,12 +574,6 @@ describe 'Filter issues', js: true do expect_filtered_search_input(search_term) end end - - context 'sorting' do - it 'sorts' do - skip('to be tested, issue #26546') - end - end end describe 'filter issues by text' do -- cgit v1.2.1 From e94a2fde0dbb1802ad3e01486c2c8f6d8a3ee4da Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 25 Aug 2017 16:15:43 -0700 Subject: Fire system hooks when a user is created via LDAP or OAuth Closes #37073 --- app/services/concerns/users/new_user_notifier.rb | 9 +++++++++ app/services/users/create_service.rb | 8 +++----- app/services/users/update_service.rb | 6 ++++++ changelogs/unreleased/sh-system-hooks-ldap-users.yml | 5 +++++ spec/services/users/update_service_spec.rb | 17 ++++++++++++++++- 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 app/services/concerns/users/new_user_notifier.rb create mode 100644 changelogs/unreleased/sh-system-hooks-ldap-users.yml diff --git a/app/services/concerns/users/new_user_notifier.rb b/app/services/concerns/users/new_user_notifier.rb new file mode 100644 index 00000000000..231693ce7a9 --- /dev/null +++ b/app/services/concerns/users/new_user_notifier.rb @@ -0,0 +1,9 @@ +module Users + module NewUserNotifier + def notify_new_user(user, reset_token) + log_info("User \"#{user.name}\" (#{user.email}) was created") + notification_service.new_user(user, reset_token) if reset_token + system_hook_service.execute_hooks_for(user, :create) + end + end +end diff --git a/app/services/users/create_service.rb b/app/services/users/create_service.rb index 74abc017cea..c8a3c461d60 100644 --- a/app/services/users/create_service.rb +++ b/app/services/users/create_service.rb @@ -1,5 +1,7 @@ module Users class CreateService < BaseService + include NewUserNotifier + def initialize(current_user, params = {}) @current_user = current_user @params = params.dup @@ -10,11 +12,7 @@ module Users @reset_token = user.generate_reset_token if user.recently_sent_password_reset? - if user.save - log_info("User \"#{user.name}\" (#{user.email}) was created") - notification_service.new_user(user, @reset_token) if @reset_token - system_hook_service.execute_hooks_for(user, :create) - end + notify_new_user(user, @reset_token) if user.save user end diff --git a/app/services/users/update_service.rb b/app/services/users/update_service.rb index dfbd6016c3f..2f9855273dc 100644 --- a/app/services/users/update_service.rb +++ b/app/services/users/update_service.rb @@ -1,5 +1,7 @@ module Users class UpdateService < BaseService + include NewUserNotifier + def initialize(user, params = {}) @user = user @params = params.dup @@ -10,7 +12,11 @@ module Users assign_attributes(&block) + user_exists = @user.persisted? + if @user.save(validate: validate) + notify_new_user(@user, nil) unless user_exists + success else error(@user.errors.full_messages.uniq.join('. ')) diff --git a/changelogs/unreleased/sh-system-hooks-ldap-users.yml b/changelogs/unreleased/sh-system-hooks-ldap-users.yml new file mode 100644 index 00000000000..87514ec00ea --- /dev/null +++ b/changelogs/unreleased/sh-system-hooks-ldap-users.yml @@ -0,0 +1,5 @@ +--- +title: Fire system hooks when a user is created via LDAP +merge_request: +author: +type: fixed diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb index 985f6d94876..6ee35a33b2d 100644 --- a/spec/services/users/update_service_spec.rb +++ b/spec/services/users/update_service_spec.rb @@ -37,7 +37,10 @@ describe Users::UpdateService do describe '#execute!' do it 'updates the name' do - result = update_user(user, name: 'New Name') + service = described_class.new(user, name: 'New Name') + expect(service).not_to receive(:notify_new_user) + + result = service.execute! expect(result).to be true expect(user.name).to eq('New Name') @@ -49,6 +52,18 @@ describe Users::UpdateService do end.to raise_error(ActiveRecord::RecordInvalid) end + it 'fires system hooks when a new user is saved' do + system_hook_service = spy(:system_hook_service) + user = build(:user) + service = described_class.new(user, name: 'John Doe') + expect(service).to receive(:notify_new_user).and_call_original + expect(service).to receive(:system_hook_service).and_return(system_hook_service) + + service.execute + + expect(system_hook_service).to have_received(:execute_hooks_for).with(user, :create) + end + def update_user(user, opts) described_class.new(user, opts).execute! end -- cgit v1.2.1 From 866aab7f2a92f9929a5c5811d3d3c23c11184b26 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Sat, 26 Aug 2017 22:32:55 +0900 Subject: Fix escape characters was not sanitized --- lib/gitlab/sql/pattern.rb | 9 +++++++-- spec/lib/gitlab/sql/pattern_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb index 47ea19994a2..46c973d8a11 100644 --- a/lib/gitlab/sql/pattern.rb +++ b/lib/gitlab/sql/pattern.rb @@ -11,9 +11,9 @@ module Gitlab def to_sql if exact_matching? - query + sanitized_query else - "%#{query}%" + "%#{sanitized_query}%" end end @@ -24,6 +24,11 @@ module Gitlab def partial_matching? @query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING end + + def sanitized_query + # Note: ActiveRecord::Base.sanitize_sql_like is a protected method + ActiveRecord::Base.__send__(:sanitize_sql_like, query) + end end end end diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb index cbafe36de06..d0412f37098 100644 --- a/spec/lib/gitlab/sql/pattern_spec.rb +++ b/spec/lib/gitlab/sql/pattern_spec.rb @@ -12,6 +12,14 @@ describe Gitlab::SQL::Pattern do end end + context 'when a query with a escape character is shorter than 3 chars' do + let(:query) { '_2' } + + it 'returns sanitized exact matching pattern' do + expect(to_sql).to eq('\_2') + end + end + context 'when a query is equal to 3 chars' do let(:query) { '123' } @@ -20,6 +28,14 @@ describe Gitlab::SQL::Pattern do end end + context 'when a query with a escape character is equal to 3 chars' do + let(:query) { '_23' } + + it 'returns partial matching pattern' do + expect(to_sql).to eq('%\_23%') + end + end + context 'when a query is longer than 3 chars' do let(:query) { '1234' } @@ -27,5 +43,13 @@ describe Gitlab::SQL::Pattern do expect(to_sql).to eq('%1234%') end end + + context 'when a query with a escape character is longer than 3 chars' do + let(:query) { '_234' } + + it 'returns sanitized partial matching pattern' do + expect(to_sql).to eq('%\_234%') + end + end end end -- cgit v1.2.1 From e6c13d29544c7cbdad16575af04e5f2efca06e01 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 26 Aug 2017 12:51:47 -0700 Subject: Improve flaky ACE editor spec The ACE editor JavaScript may not be loaded when the spec runs evaluateScript. Wait for the editor to load before attempting to run ACE-specific JavaScript. --- spec/features/projects/user_creates_files_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/features/projects/user_creates_files_spec.rb b/spec/features/projects/user_creates_files_spec.rb index 4b78cc4fc53..3d335687510 100644 --- a/spec/features/projects/user_creates_files_spec.rb +++ b/spec/features/projects/user_creates_files_spec.rb @@ -56,11 +56,10 @@ describe 'User creates files' do find('.add-to-tree').click click_link('New file') + expect(page).to have_selector('.file-editor') end it 'creates and commit a new file', js: true do - expect(page).to have_selector('.file-editor') - execute_script("ace.edit('editor').setValue('*.rbca')") fill_in(:file_name, with: 'not_a_file.md') fill_in(:commit_message, with: 'New commit message', visible: true) -- cgit v1.2.1 From e19c560d78277f476978c2f847c40ed982165f03 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Sun, 27 Aug 2017 15:41:42 +0900 Subject: Add a simple spec that checks filtered search works at group merge request page --- spec/features/groups/merge_requests_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/groups/merge_requests_spec.rb b/spec/features/groups/merge_requests_spec.rb index c2241feb9f7..9ba9f5686f7 100644 --- a/spec/features/groups/merge_requests_spec.rb +++ b/spec/features/groups/merge_requests_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' feature 'Group merge requests page' do + include FilteredSearchHelpers + let(:path) { merge_requests_group_path(group) } let(:issuable) { create(:merge_request, source_project: project, target_project: project, title: 'this is my created issuable') } @@ -33,4 +35,17 @@ feature 'Group merge requests page' do expect(page.find('#state-all span.badge').text).to eq("1") end end + + context 'group filtered search', :js do + let(:access_level) { ProjectFeature::ENABLED } + let(:user) { user_in_group } + let(:user2) { user_outside_group } + + it 'filters by assignee only group users' do + filtered_search.set('assignee:') + + expect(find('#js-dropdown-assignee .filter-dropdown')).to have_content(user.name) + expect(find('#js-dropdown-assignee .filter-dropdown')).not_to have_content(user2.name) + end + end end -- cgit v1.2.1 From 5e0b1442f00817d9f940638e30c08c3f6add0a60 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Mon, 28 Aug 2017 06:16:14 +0900 Subject: Add changelog entry --- changelogs/unreleased/group-mr-search-bar.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/group-mr-search-bar.yml diff --git a/changelogs/unreleased/group-mr-search-bar.yml b/changelogs/unreleased/group-mr-search-bar.yml new file mode 100644 index 00000000000..0b554a5d7c9 --- /dev/null +++ b/changelogs/unreleased/group-mr-search-bar.yml @@ -0,0 +1,5 @@ +--- +title: Add filtered search to group merge requests dashboard +merge_request: 13688 +author: Hiroyuki Sato +type: changed -- cgit v1.2.1 From 1e53f40c25a87a285ce6f35b5ae1717fe87477ae Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 27 Aug 2017 14:43:42 -0700 Subject: Simplify system hook testing and guarantee test will fire The change in !11728 would cause an arbitrary project to be chosen to test system hooks, and it's likely that the project would not have any commits or relevant commits to test the hook. This would prevent admins from verifying that the hook fired. Instead of trying to create a representative hook dynamically, just send static data to guarantee the hook will actually be tested. Closes #37067 --- app/services/test_hooks/system_service.rb | 37 ++----------------------- lib/gitlab/data_builder/push.rb | 33 ++++++++++++++++++++++ lib/gitlab/data_builder/repository.rb | 21 ++++++++++++++ spec/services/test_hooks/system_service_spec.rb | 33 ++++------------------ 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/app/services/test_hooks/system_service.rb b/app/services/test_hooks/system_service.rb index 76c3c19bd74..67552edefc9 100644 --- a/app/services/test_hooks/system_service.rb +++ b/app/services/test_hooks/system_service.rb @@ -2,47 +2,16 @@ module TestHooks class SystemService < TestHooks::BaseService private - def project - @project ||= begin - project = Project.first - - throw(:validation_error, 'Ensure that at least one project exists.') unless project - - project - end - end - def push_events_data - if project.empty_repo? - throw(:validation_error, "Ensure project \"#{project.human_name}\" has commits.") - end - - Gitlab::DataBuilder::Push.build_sample(project, current_user) + Gitlab::DataBuilder::Push.sample_data end def tag_push_events_data - if project.repository.tags.empty? - throw(:validation_error, "Ensure project \"#{project.human_name}\" has tags.") - end - - Gitlab::DataBuilder::Push.build_sample(project, current_user) + Gitlab::DataBuilder::Push.sample_data end def repository_update_events_data - commit = project.commit - ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}#{project.default_branch}" - - unless commit - throw(:validation_error, "Ensure project \"#{project.human_name}\" has commits.") - end - - change = Gitlab::DataBuilder::Repository.single_change( - commit.parent_id || Gitlab::Git::BLANK_SHA, - commit.id, - ref - ) - - Gitlab::DataBuilder::Repository.update(project, current_user, [change], [ref]) + Gitlab::DataBuilder::Repository.sample_data end end end diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb index 5c5f507d44d..4ab5b3455a5 100644 --- a/lib/gitlab/data_builder/push.rb +++ b/lib/gitlab/data_builder/push.rb @@ -3,6 +3,35 @@ module Gitlab module Push extend self + SAMPLE_DATA = + { + object_kind: "push", + event_name: "push", + before: "95790bf891e76fee5e1747ab589903a6a1f80f22", + after: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + ref: "refs/heads/master", + checkout_sha: "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + message: "Hello World", + user_id: 4, + user_name: "John Smith", + user_email: "john@example.com", + user_avatar: "https://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=8://s.gravatar.com/avatar/d4c74594d841139328695756648b6bd6?s=80", + project_id: 15, + commits: [ + { + id: "c5feabde2d8cd023215af4d2ceeb7a64839fc428", + message: "Add simple search to projects in public area", + timestamp: "2013-05-13T18:18:08+00:00", + url: "https://test.example.com/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", + author: { + name: "Test User", + email: "test@example.com" + } + } + ], + total_commits_count: 1 + }.freeze + # Produce a hash of post-receive data # # data = { @@ -74,6 +103,10 @@ module Gitlab build(project, user, commits.last&.id, commits.first&.id, ref, commits) end + def sample_data + SAMPLE_DATA + end + private def checkout_sha(repository, newrev, ref) diff --git a/lib/gitlab/data_builder/repository.rb b/lib/gitlab/data_builder/repository.rb index b42dc052949..c9c13ec6487 100644 --- a/lib/gitlab/data_builder/repository.rb +++ b/lib/gitlab/data_builder/repository.rb @@ -3,6 +3,23 @@ module Gitlab module Repository extend self + SAMPLE_DATA = { + event_name: 'repository_update', + user_id: 10, + user_name: 'john.doe', + user_email: 'test@example.com', + user_avatar: 'http://example.com/avatar/user.png', + project_id: 40, + changes: [ + { + before: "8205ea8d81ce0c6b90fbe8280d118cc9fdad6130", + after: "4045ea7a3df38697b3730a20fb73c8bed8a3e69e", + ref: "refs/heads/master" + } + ], + "refs": ["refs/heads/master"] + }.freeze + # Produce a hash of post-receive data def update(project, user, changes, refs) { @@ -30,6 +47,10 @@ module Gitlab ref: ref } end + + def sample_data + SAMPLE_DATA + end end end end diff --git a/spec/services/test_hooks/system_service_spec.rb b/spec/services/test_hooks/system_service_spec.rb index 00d89924766..a15708bf82f 100644 --- a/spec/services/test_hooks/system_service_spec.rb +++ b/spec/services/test_hooks/system_service_spec.rb @@ -7,7 +7,6 @@ describe TestHooks::SystemService do let(:project) { create(:project, :repository) } let(:hook) { create(:system_hook) } let(:service) { described_class.new(hook, current_user, trigger) } - let(:sample_data) { { data: 'sample' }} let(:success_result) { { status: :success, http_status: 200, message: 'ok' } } before do @@ -26,18 +25,11 @@ describe TestHooks::SystemService do context 'push_events' do let(:trigger) { 'push_events' } - it 'returns error message if not enough data' do - allow(project).to receive(:empty_repo?).and_return(true) - - expect(hook).not_to receive(:execute) - expect(service.execute).to include({ status: :error, message: "Ensure project \"#{project.human_name}\" has commits." }) - end - it 'executes hook' do allow(project).to receive(:empty_repo?).and_return(false) - allow(Gitlab::DataBuilder::Push).to receive(:build_sample).and_return(sample_data) + expect(Gitlab::DataBuilder::Push).to receive(:sample_data).and_call_original - expect(hook).to receive(:execute).with(sample_data, trigger).and_return(success_result) + expect(hook).to receive(:execute).with(Gitlab::DataBuilder::Push::SAMPLE_DATA, trigger).and_return(success_result) expect(service.execute).to include(success_result) end end @@ -45,18 +37,11 @@ describe TestHooks::SystemService do context 'tag_push_events' do let(:trigger) { 'tag_push_events' } - it 'returns error message if not enough data' do - allow(project.repository).to receive(:tags).and_return([]) - - expect(hook).not_to receive(:execute) - expect(service.execute).to include({ status: :error, message: "Ensure project \"#{project.human_name}\" has tags." }) - end - it 'executes hook' do allow(project.repository).to receive(:tags).and_return(['tag']) - allow(Gitlab::DataBuilder::Push).to receive(:build_sample).and_return(sample_data) + expect(Gitlab::DataBuilder::Push).to receive(:sample_data).and_call_original - expect(hook).to receive(:execute).with(sample_data, trigger).and_return(success_result) + expect(hook).to receive(:execute).with(Gitlab::DataBuilder::Push::SAMPLE_DATA, trigger).and_return(success_result) expect(service.execute).to include(success_result) end end @@ -64,17 +49,11 @@ describe TestHooks::SystemService do context 'repository_update_events' do let(:trigger) { 'repository_update_events' } - it 'returns error message if not enough data' do - allow(project).to receive(:commit).and_return(nil) - expect(hook).not_to receive(:execute) - expect(service.execute).to include({ status: :error, message: "Ensure project \"#{project.human_name}\" has commits." }) - end - it 'executes hook' do allow(project).to receive(:empty_repo?).and_return(false) - allow(Gitlab::DataBuilder::Repository).to receive(:update).and_return(sample_data) + expect(Gitlab::DataBuilder::Repository).to receive(:sample_data).and_call_original - expect(hook).to receive(:execute).with(sample_data, trigger).and_return(success_result) + expect(hook).to receive(:execute).with(Gitlab::DataBuilder::Repository::SAMPLE_DATA, trigger).and_return(success_result) expect(service.execute).to include(success_result) end end -- cgit v1.2.1 From bcd2135e08fea5193b0ed9960cd96fab6e7015a4 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Mon, 28 Aug 2017 15:03:33 +1000 Subject: fix transient test failures caused by wrong dropdown trigger --- spec/features/snippets/notes_on_personal_snippets_spec.rb | 2 +- spec/support/features/reportable_note_shared_examples.rb | 2 +- spec/support/helpers/note_interaction_helpers.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/snippets/notes_on_personal_snippets_spec.rb b/spec/features/snippets/notes_on_personal_snippets_spec.rb index c0c293dee78..bf79974b8c6 100644 --- a/spec/features/snippets/notes_on_personal_snippets_spec.rb +++ b/spec/features/snippets/notes_on_personal_snippets_spec.rb @@ -91,7 +91,7 @@ describe 'Comments on personal snippets', :js do context 'when editing a note' do it 'changes the text' do - find('.js-note-edit').click + find('.js-note-edit').trigger('click') page.within('.current-note-edit-form') do fill_in 'note[note]', with: 'new content' diff --git a/spec/support/features/reportable_note_shared_examples.rb b/spec/support/features/reportable_note_shared_examples.rb index cb483ae9a5a..5a0e7c3d099 100644 --- a/spec/support/features/reportable_note_shared_examples.rb +++ b/spec/support/features/reportable_note_shared_examples.rb @@ -34,7 +34,7 @@ shared_examples 'reportable note' do end def open_dropdown(dropdown) - dropdown.click + dropdown.find('.more-actions-toggle').trigger('click') dropdown.find('.dropdown-menu li', match: :first) end end diff --git a/spec/support/helpers/note_interaction_helpers.rb b/spec/support/helpers/note_interaction_helpers.rb index 551c759133c..86008698692 100644 --- a/spec/support/helpers/note_interaction_helpers.rb +++ b/spec/support/helpers/note_interaction_helpers.rb @@ -2,7 +2,7 @@ module NoteInteractionHelpers def open_more_actions_dropdown(note) note_element = find("#note_#{note.id}") - note_element.find('.more-actions').click + note_element.find('.more-actions-toggle').trigger('click') note_element.find('.more-actions .dropdown-menu li', match: :first) end end -- cgit v1.2.1 From 45aa23a6d142c0cd5e77146057c20d4ffd652c3b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 28 Aug 2017 15:36:07 +0800 Subject: Remove duplicate update for owner --- spec/requests/api/triggers_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 9a98e217643..1e206fd2a9e 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -22,7 +22,6 @@ describe API::Triggers do before do stub_ci_pipeline_to_return_yaml_file - trigger.update(owner: user) end context 'Handles errors' do -- cgit v1.2.1 From 77c8e2b4f05fdbcab908eb68c1014b27665258c0 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 28 Aug 2017 03:30:03 -0500 Subject: ensure graph overlay is in front of cursor flag --- .../monitoring/components/monitoring_column.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/monitoring/components/monitoring_column.vue b/app/assets/javascripts/monitoring/components/monitoring_column.vue index 407af51cb7a..8ad89c19aeb 100644 --- a/app/assets/javascripts/monitoring/components/monitoring_column.vue +++ b/app/assets/javascripts/monitoring/components/monitoring_column.vue @@ -266,14 +266,6 @@ stroke-width="2" transform="translate(-5, 20)"> - - + + -- cgit v1.2.1 From 6c4d13fe65835628619f9b791f2e287c67266c16 Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Mon, 28 Aug 2017 10:10:11 +0000 Subject: Update 'Using Docker images' documentation --- .../docs-update-ci-docker-using-docker-images.yml | 5 +++ doc/ci/docker/using_docker_images.md | 40 ++++++++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/docs-update-ci-docker-using-docker-images.yml diff --git a/changelogs/unreleased/docs-update-ci-docker-using-docker-images.yml b/changelogs/unreleased/docs-update-ci-docker-using-docker-images.yml new file mode 100644 index 00000000000..d8a5073f110 --- /dev/null +++ b/changelogs/unreleased/docs-update-ci-docker-using-docker-images.yml @@ -0,0 +1,5 @@ +--- +title: Update 'Using Docker images' documentation +merge_request: 13848 +author: +type: other diff --git a/doc/ci/docker/using_docker_images.md b/doc/ci/docker/using_docker_images.md index dc5313c5597..6e8beceb6fe 100644 --- a/doc/ci/docker/using_docker_images.md +++ b/doc/ci/docker/using_docker_images.md @@ -388,15 +388,40 @@ that runner. As an example, let's assume that you want to use the `registry.example.com/private/image:latest` image which is private and requires you to login into a private container registry. + +Let's also assume that these are the login credentials: + +| Key | Value | +|----------|----------------------| +| registry | registry.example.com | +| username | my_username | +| password | my_password | + To configure access for `registry.example.com`, follow these steps: -1. Do a `docker login` on your computer: +1. Find what the value of `DOCKER_AUTH_CONFIG` should be. There are two ways to + accomplish this: + - **First way -** Do a `docker login` on your local machine: - ```bash - docker login registry.example.com --username my_username --password my_password - ``` + ```bash + docker login registry.example.com --username my_username --password my_password + ``` + + Then copy the content of `~/.docker/config.json`. + - **Second way -** In some setups, it's possible that Docker client will use + the available system keystore to store the result of `docker login`. In + that case, it's impossible to read `~/.docker/config.json`, so you will + need to prepare the required base64-encoded version of + `${username}:${password}` manually. Open a terminal and execute the + following command: + + ```bash + echo -n "my_username:my_password" | base64 + + # Example output to copy + bXlfdXNlcm5hbWU6bXlfcGFzc3dvcmQ= + ``` -1. Copy the content of `~/.docker/config.json` 1. Create a [secret variable] `DOCKER_AUTH_CONFIG` with the content of the Docker configuration file as the value: @@ -410,7 +435,8 @@ To configure access for `registry.example.com`, follow these steps: } ``` -1. Do a `docker logout` on your computer if you don't need access to the +1. Optionally,if you followed the first way of finding the `DOCKER_AUTH_CONFIG` + value, do a `docker logout` on your computer if you don't need access to the registry from it: ```bash @@ -418,7 +444,7 @@ To configure access for `registry.example.com`, follow these steps: ``` 1. You can now use any private image from `registry.example.com` defined in - `image` and/or `services` in your [`.gitlab-ci.yml` file][yaml-priv-reg]: + `image` and/or `services` in your `.gitlab-ci.yml` file: ```yaml image: my.registry.tld:5000/namespace/image:tag -- cgit v1.2.1 From db4bd1a67d0d2acd7cde8b0ffedcab4e5eaf934e Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 28 Aug 2017 12:49:43 +0200 Subject: Clear schema cache after running tests for migrations --- spec/support/migrations_helpers.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/support/migrations_helpers.rb b/spec/support/migrations_helpers.rb index 255b3d96a62..4ca019c1b05 100644 --- a/spec/support/migrations_helpers.rb +++ b/spec/support/migrations_helpers.rb @@ -16,6 +16,8 @@ module MigrationsHelpers end def reset_column_in_migration_models + ActiveRecord::Base.clear_cache! + described_class.constants.sort.each do |name| const = described_class.const_get(name) -- cgit v1.2.1 From 54b3908cd1fac68318007e6800305ece6013727e Mon Sep 17 00:00:00 2001 From: winh Date: Thu, 17 Aug 2017 10:42:18 +0200 Subject: Make notification dropdowns consistent --- app/assets/stylesheets/pages/notifications.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/pages/notifications.scss b/app/assets/stylesheets/pages/notifications.scss index bdf07a99daf..c28b1e68008 100644 --- a/app/assets/stylesheets/pages/notifications.scss +++ b/app/assets/stylesheets/pages/notifications.scss @@ -14,3 +14,7 @@ font-size: 18px; } } + +.notification-form { + @include new-style-dropdown; +} -- cgit v1.2.1 From a01ed201344a2bfebcf07d33564774a319380a26 Mon Sep 17 00:00:00 2001 From: winh Date: Wed, 16 Aug 2017 13:29:25 +0200 Subject: Make todos dashboard dropdowns consistent --- app/assets/stylesheets/pages/todos.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/pages/todos.scss b/app/assets/stylesheets/pages/todos.scss index 5b9fafe31bd..6c8d87185e9 100644 --- a/app/assets/stylesheets/pages/todos.scss +++ b/app/assets/stylesheets/pages/todos.scss @@ -265,3 +265,7 @@ font-weight: $gl-font-weight-bold; } } + +.todos-filters { + @include new-style-dropdown; +} -- cgit v1.2.1 From 53fd93220c19aec495212e848979293da41164ba Mon Sep 17 00:00:00 2001 From: winh Date: Tue, 15 Aug 2017 22:39:19 +0200 Subject: Make file template dropdowns consistent --- app/assets/stylesheets/pages/editor.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/pages/editor.scss b/app/assets/stylesheets/pages/editor.scss index f6b8c8ee2bc..d3cd4d507de 100644 --- a/app/assets/stylesheets/pages/editor.scss +++ b/app/assets/stylesheets/pages/editor.scss @@ -204,6 +204,8 @@ .gitlab-ci-yml-selector, .dockerfile-selector, .template-type-selector { + @include new-style-dropdown; + display: inline-block; vertical-align: top; font-family: $regular_font; -- cgit v1.2.1 From 76945ed119fbd2927fbb2ad9490914a8cf6569a9 Mon Sep 17 00:00:00 2001 From: winh Date: Mon, 14 Aug 2017 21:34:10 +0200 Subject: Make member search dropdown consistent --- app/assets/stylesheets/pages/members.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/pages/members.scss b/app/assets/stylesheets/pages/members.scss index a385eb359e1..3fb02e9964f 100644 --- a/app/assets/stylesheets/pages/members.scss +++ b/app/assets/stylesheets/pages/members.scss @@ -96,6 +96,8 @@ } .member-search-form { + @include new-style-dropdown; + position: relative; @media (min-width: $screen-sm-min) { -- cgit v1.2.1 From b7316ffdff561cc16a003c5540f2c6e627818a2e Mon Sep 17 00:00:00 2001 From: Kai Kontio Date: Mon, 28 Aug 2017 11:47:09 +0000 Subject: Update backup_restore.md documentation regarding S3 and IAM profiles. https://gitlab.com/gitlab-org/gitlab-ce/commit/7f8ef19c411eceec207fef5d8459fbeaa40bf464 most likely broke the old configuration format where empty string aws_access_key_id & aws_secret_access_key were still OK. From 9.5 onwards moving backups to S3 using IAM profiles will fail if they are configured. --- doc/raketasks/backup_restore.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index 10f5ab3370d..ae69d7f92f2 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -144,9 +144,8 @@ gitlab_rails['backup_upload_connection'] = { 'region' => 'eu-west-1', 'aws_access_key_id' => 'AKIAKIAKI', 'aws_secret_access_key' => 'secret123' - # If using an IAM Profile, leave aws_access_key_id & aws_secret_access_key empty - # ie. 'aws_access_key_id' => '', - # 'use_iam_profile' => 'true' + # If using an IAM Profile, don't configure aws_access_key_id & aws_secret_access_key + # 'use_iam_profile' => true } gitlab_rails['backup_upload_remote_directory'] = 'my.s3.bucket' ``` -- cgit v1.2.1 From 7ba19ab620f5e89a6ff15df8603b315cd154bc6c Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Mon, 28 Aug 2017 15:21:05 +0200 Subject: Instrument MergeRequest#ensure_ref_fetched --- changelogs/unreleased/36061-mr-ref.yml | 5 +++++ config/initializers/8_metrics.rb | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/unreleased/36061-mr-ref.yml diff --git a/changelogs/unreleased/36061-mr-ref.yml b/changelogs/unreleased/36061-mr-ref.yml new file mode 100644 index 00000000000..039666070a7 --- /dev/null +++ b/changelogs/unreleased/36061-mr-ref.yml @@ -0,0 +1,5 @@ +--- +title: Instrument MergeRequest#ensure_ref_fetched +merge_request: +author: +type: other diff --git a/config/initializers/8_metrics.rb b/config/initializers/8_metrics.rb index 2aeb94d47cd..370a976b64a 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/8_metrics.rb @@ -119,6 +119,9 @@ def instrument_classes(instrumentation) # Needed for https://gitlab.com/gitlab-org/gitlab-ce/issues/30224#note_32306159 instrumentation.instrument_instance_method(MergeRequestDiff, :load_commits) + + # Needed for https://gitlab.com/gitlab-org/gitlab-ce/issues/36061 + instrumentation.instrument_instance_method(MergeRequest, :ensure_ref_fetched) end # rubocop:enable Metrics/AbcSize -- cgit v1.2.1 From eef5135e0826b5f43a9229c82d482215546c7cf5 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 28 Aug 2017 10:46:18 +0200 Subject: Fix events error importing GitLab projects --- changelogs/unreleased/fix-import-events.yml | 5 +++++ lib/gitlab/import_export/import_export.yml | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 changelogs/unreleased/fix-import-events.yml diff --git a/changelogs/unreleased/fix-import-events.yml b/changelogs/unreleased/fix-import-events.yml new file mode 100644 index 00000000000..84b4410a019 --- /dev/null +++ b/changelogs/unreleased/fix-import-events.yml @@ -0,0 +1,5 @@ +--- +title: Fix events error importing GitLab projects +merge_request: +author: +type: fixed diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index e5d4bb686e7..78795dd3d92 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -138,3 +138,7 @@ methods: - :target_branch_sha project: - :description_html + events: + - :action + push_event_payload: + - :action \ No newline at end of file -- cgit v1.2.1 From 49495fe63d119e9023e9dfc179eb28d1f8f344c4 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 28 Aug 2017 11:00:28 +0200 Subject: fix spec --- spec/lib/gitlab/import_export/project_tree_restorer_spec.rb | 4 ++++ spec/support/import_export/export_file_helper.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb index c10427d798f..5b16fc5d084 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -86,6 +86,10 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do expect(event).not_to be_nil end + it 'has the action' do + expect(event.action).not_to be_nil + end + it 'event belongs to note, belongs to merge request, belongs to a project' do expect(event.note.noteable.project).not_to be_nil end diff --git a/spec/support/import_export/export_file_helper.rb b/spec/support/import_export/export_file_helper.rb index 2011408be93..931c91bde7c 100644 --- a/spec/support/import_export/export_file_helper.rb +++ b/spec/support/import_export/export_file_helper.rb @@ -35,7 +35,8 @@ module ExportFileHelper project: project, commit_id: ci_pipeline.sha) - create(:event, :created, target: milestone, project: project, author: user) + create(:event, :created, target: milestone, project: project, author: user, action: 5) + create(:push_event_payload, event: event) create(:project_member, :master, user: user, project: project) create(:ci_variable, project: project) create(:ci_trigger, project: project) -- cgit v1.2.1 From 998afa5f74558be215a924d95aa131a69831ca43 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Wed, 1 Mar 2017 14:35:48 +0100 Subject: API: Respect the 'If-Unmodified-Since' for delete endpoints --- lib/api/access_requests.rb | 3 +++ lib/api/award_emoji.rb | 1 + lib/api/boards.rb | 1 + lib/api/broadcast_messages.rb | 1 + lib/api/deploy_keys.rb | 2 ++ lib/api/environments.rb | 1 + lib/api/groups.rb | 2 ++ lib/api/helpers.rb | 8 ++++++++ lib/api/issues.rb | 2 ++ lib/api/labels.rb | 2 ++ lib/api/members.rb | 3 ++- lib/api/merge_requests.rb | 2 ++ lib/api/notes.rb | 2 ++ lib/api/project_hooks.rb | 2 ++ lib/api/project_snippets.rb | 2 ++ lib/api/projects.rb | 2 ++ lib/api/runners.rb | 2 ++ lib/api/services.rb | 2 ++ lib/api/snippets.rb | 1 + lib/api/system_hooks.rb | 2 ++ lib/api/triggers.rb | 2 ++ lib/api/users.rb | 28 ++++++++++++++++++++++++++++ 22 files changed, 72 insertions(+), 1 deletion(-) diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index cdacf9839e5..0c5b8862d79 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -67,6 +67,9 @@ module API end delete ":id/access_requests/:user_id" do source = find_source(source_type, params[:id]) + member = source.public_send(:requesters).find_by!(user_id: params[:user_id]) + + check_unmodified_since(member.updated_at) status 204 ::Members::DestroyService.new(source, current_user, params) diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb index 5a028fc9d0b..51a8587d26e 100644 --- a/lib/api/award_emoji.rb +++ b/lib/api/award_emoji.rb @@ -85,6 +85,7 @@ module API end delete "#{endpoint}/:award_id" do award = awardable.award_emoji.find(params[:award_id]) + check_unmodified_since(award.updated_at) unauthorized! unless award.user == current_user || current_user.admin? diff --git a/lib/api/boards.rb b/lib/api/boards.rb index 5a2d7a681e3..d36df77dc6c 100644 --- a/lib/api/boards.rb +++ b/lib/api/boards.rb @@ -124,6 +124,7 @@ module API authorize!(:admin_list, user_project) list = board_lists.find(params[:list_id]) + check_unmodified_since(list.updated_at) service = ::Boards::Lists::DestroyService.new(user_project, current_user) diff --git a/lib/api/broadcast_messages.rb b/lib/api/broadcast_messages.rb index 9980aec4752..352972b584a 100644 --- a/lib/api/broadcast_messages.rb +++ b/lib/api/broadcast_messages.rb @@ -90,6 +90,7 @@ module API end delete ':id' do message = find_message + check_unmodified_since(message.updated_at) status 204 message.destroy diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 42e7c1486b0..971cc816454 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -125,6 +125,8 @@ module API key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id]) not_found!('Deploy Key') unless key + check_unmodified_since(key.updated_at) + status 204 key.destroy end diff --git a/lib/api/environments.rb b/lib/api/environments.rb index c774a5c6685..3fc423ae79a 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -78,6 +78,7 @@ module API authorize! :update_environment, user_project environment = user_project.environments.find(params[:environment_id]) + check_unmodified_since(environment.updated_at) status 204 environment.destroy diff --git a/lib/api/groups.rb b/lib/api/groups.rb index e56427304a6..c9b32a85487 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -117,6 +117,8 @@ module API delete ":id" do group = find_group!(params[:id]) authorize! :admin_group, group + + check_unmodified_since(group.updated_at) status 204 ::Groups::DestroyService.new(group, current_user).execute diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index b56fd2388b3..1c74a14d91c 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -11,6 +11,14 @@ module API declared(params, options).to_h.symbolize_keys end + def check_unmodified_since(last_modified) + if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) if headers.key?('If-Unmodified-Since') rescue nil + + if if_unmodified_since && if_unmodified_since < last_modified + render_api_error!('412 Precondition Failed', 412) + end + end + def current_user return @current_user if defined?(@current_user) diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 4cec1145f3a..cee9898d3a6 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -230,6 +230,8 @@ module API not_found!('Issue') unless issue authorize!(:destroy_issue, issue) + check_unmodified_since(issue.updated_at) + status 204 issue.destroy end diff --git a/lib/api/labels.rb b/lib/api/labels.rb index 4520c98d951..45fa57fdf55 100644 --- a/lib/api/labels.rb +++ b/lib/api/labels.rb @@ -56,6 +56,8 @@ module API label = user_project.labels.find_by(title: params[:name]) not_found!('Label') unless label + check_unmodified_since(label.updated_at) + status 204 label.destroy end diff --git a/lib/api/members.rb b/lib/api/members.rb index bb970b7cd54..5634f123eca 100644 --- a/lib/api/members.rb +++ b/lib/api/members.rb @@ -94,7 +94,8 @@ module API delete ":id/members/:user_id" do source = find_source(source_type, params[:id]) # Ensure that memeber exists - source.members.find_by!(user_id: params[:user_id]) + member = source.members.find_by!(user_id: params[:user_id]) + check_unmodified_since(member.updated_at) status 204 ::Members::DestroyService.new(source, current_user, declared_params).execute diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 8810d4e441d..c6fecc1aa6c 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -164,6 +164,8 @@ module API merge_request = find_project_merge_request(params[:merge_request_iid]) authorize!(:destroy_merge_request, merge_request) + check_unmodified_since(merge_request.updated_at) + status 204 merge_request.destroy end diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 4e4e473994b..58d71787aca 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -129,7 +129,9 @@ module API end delete ":id/#{noteables_str}/:noteable_id/notes/:note_id" do note = user_project.notes.find(params[:note_id]) + authorize! :admin_note, note + check_unmodified_since(note.updated_at) status 204 ::Notes::DestroyService.new(user_project, current_user).execute(note) diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb index 649dd891f56..74d736fda59 100644 --- a/lib/api/project_hooks.rb +++ b/lib/api/project_hooks.rb @@ -96,6 +96,8 @@ module API delete ":id/hooks/:hook_id" do hook = user_project.hooks.find(params.delete(:hook_id)) + check_unmodified_since(hook.updated_at) + status 204 hook.destroy end diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb index f3d905b0068..645162d564d 100644 --- a/lib/api/project_snippets.rb +++ b/lib/api/project_snippets.rb @@ -116,6 +116,8 @@ module API not_found!('Snippet') unless snippet authorize! :admin_project_snippet, snippet + check_unmodified_since(snippet.updated_at) + status 204 snippet.destroy end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 15c3832b032..eab0ca0b3c9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -334,6 +334,8 @@ module API desc 'Remove a project' delete ":id" do authorize! :remove_project, user_project + check_unmodified_since(user_project.updated_at) + ::Projects::DestroyService.new(user_project, current_user, {}).async_execute accepted! diff --git a/lib/api/runners.rb b/lib/api/runners.rb index 31f940fe96b..e3b2eb904b7 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -77,7 +77,9 @@ module API end delete ':id' do runner = get_runner(params[:id]) + authenticate_delete_runner!(runner) + check_unmodified_since(runner.updated_at) status 204 runner.destroy! diff --git a/lib/api/services.rb b/lib/api/services.rb index 843c05ae32e..4fef3383e5e 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -655,6 +655,8 @@ module API end delete ":id/services/:service_slug" do service = user_project.find_or_initialize_service(params[:service_slug].underscore) + # Todo, not sure + check_unmodified_since(service.updated_at) attrs = service_attributes(service).inject({}) do |hash, key| hash.merge!(key => nil) diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 35ece56c65c..7107b3d669c 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -122,6 +122,7 @@ module API return not_found!('Snippet') unless snippet authorize! :destroy_personal_snippet, snippet + check_unmodified_since(snippet.updated_at) status 204 snippet.destroy diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index c0179037440..64066a75b15 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -66,6 +66,8 @@ module API hook = SystemHook.find_by(id: params[:id]) not_found!('System hook') unless hook + check_unmodified_since(hook.updated_at) + status 204 hook.destroy end diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb index edfdb63d183..4ae70c65759 100644 --- a/lib/api/triggers.rb +++ b/lib/api/triggers.rb @@ -140,6 +140,8 @@ module API trigger = user_project.triggers.find(params.delete(:trigger_id)) return not_found!('Trigger') unless trigger + check_unmodified_since(trigger.updated_at) + status 204 trigger.destroy end diff --git a/lib/api/users.rb b/lib/api/users.rb index e2019d6d512..942bb72cf97 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -230,7 +230,12 @@ module API key = user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key +<<<<<<< HEAD status 204 +======= + check_unmodified_since(key.updated_at) + +>>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints key.destroy end @@ -287,7 +292,14 @@ module API email = user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email +<<<<<<< HEAD Emails::DestroyService.new(user, email: email.email).execute +======= + check_unmodified_since(email.updated_at) + + email.destroy + user.update_secondary_emails! +>>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints end desc 'Delete a user. Available only for admins.' do @@ -299,11 +311,18 @@ module API end delete ":id" do authenticated_as_admin! + user = User.find_by(id: params[:id]) not_found!('User') unless user +<<<<<<< HEAD status 204 user.delete_async(deleted_by: current_user, params: params) +======= + check_unmodified_since(user.updated_at) + + ::Users::DestroyService.new(current_user).execute(user) +>>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints end desc 'Block a user. Available only for admins.' @@ -481,6 +500,8 @@ module API key = current_user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key + check_unmodified_since(key.updated_at) + status 204 key.destroy end @@ -533,6 +554,7 @@ module API email = current_user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email +<<<<<<< HEAD status 204 Emails::DestroyService.new(current_user, email: email.email).execute end @@ -550,6 +572,12 @@ module API .reorder(last_activity_on: :asc) present paginate(activities), with: Entities::UserActivity +======= + check_unmodified_since(email.updated_at) + + email.destroy + current_user.update_secondary_emails! +>>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints end end end -- cgit v1.2.1 From e80313f9ee5b3495a8713e6ddae111bc8106155b Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Thu, 2 Mar 2017 13:14:13 +0100 Subject: Conditionally destroy a ressource --- lib/api/access_requests.rb | 11 +++++----- lib/api/award_emoji.rb | 4 +--- lib/api/boards.rb | 11 +++++----- lib/api/broadcast_messages.rb | 4 +--- lib/api/deploy_keys.rb | 5 +---- lib/api/environments.rb | 4 +--- lib/api/groups.rb | 7 +++---- lib/api/helpers.rb | 17 ++++++++++++--- lib/api/issues.rb | 4 +--- lib/api/labels.rb | 5 +---- lib/api/members.rb | 7 +++---- lib/api/merge_requests.rb | 4 +--- lib/api/notes.rb | 6 +++--- lib/api/project_hooks.rb | 5 +---- lib/api/project_snippets.rb | 4 +--- lib/api/projects.rb | 5 +++-- lib/api/runner.rb | 6 ++++-- lib/api/runners.rb | 7 ++----- lib/api/services.rb | 4 ++-- lib/api/snippets.rb | 4 +--- lib/api/system_hooks.rb | 5 +---- lib/api/triggers.rb | 5 +---- lib/api/users.rb | 47 ++++++++++++------------------------------ spec/requests/api/tags_spec.rb | 4 ++-- 24 files changed, 71 insertions(+), 114 deletions(-) diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb index 0c5b8862d79..4fa9b2b2494 100644 --- a/lib/api/access_requests.rb +++ b/lib/api/access_requests.rb @@ -67,13 +67,12 @@ module API end delete ":id/access_requests/:user_id" do source = find_source(source_type, params[:id]) - member = source.public_send(:requesters).find_by!(user_id: params[:user_id]) + member = source.requesters.find_by!(user_id: params[:user_id]) - check_unmodified_since(member.updated_at) - - status 204 - ::Members::DestroyService.new(source, current_user, params) - .execute(:requesters) + destroy_conditionally!(member) do + ::Members::DestroyService.new(source, current_user, params) + .execute(:requesters) + end end end end diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb index 51a8587d26e..8e3851640da 100644 --- a/lib/api/award_emoji.rb +++ b/lib/api/award_emoji.rb @@ -85,12 +85,10 @@ module API end delete "#{endpoint}/:award_id" do award = awardable.award_emoji.find(params[:award_id]) - check_unmodified_since(award.updated_at) unauthorized! unless award.user == current_user || current_user.admin? - status 204 - award.destroy + destroy_conditionally!(award) end end end diff --git a/lib/api/boards.rb b/lib/api/boards.rb index d36df77dc6c..0d11c5fc971 100644 --- a/lib/api/boards.rb +++ b/lib/api/boards.rb @@ -122,14 +122,13 @@ module API end delete "/lists/:list_id" do authorize!(:admin_list, user_project) - list = board_lists.find(params[:list_id]) - check_unmodified_since(list.updated_at) - - service = ::Boards::Lists::DestroyService.new(user_project, current_user) - unless service.execute(list) - render_api_error!({ error: 'List could not be deleted!' }, 400) + destroy_conditionally!(list) do |list| + service = ::Boards::Lists::DestroyService.new(user_project, current_user) + unless service.execute(list) + render_api_error!({ error: 'List could not be deleted!' }, 400) + end end end end diff --git a/lib/api/broadcast_messages.rb b/lib/api/broadcast_messages.rb index 352972b584a..0b45621ce7b 100644 --- a/lib/api/broadcast_messages.rb +++ b/lib/api/broadcast_messages.rb @@ -90,10 +90,8 @@ module API end delete ':id' do message = find_message - check_unmodified_since(message.updated_at) - status 204 - message.destroy + destroy_conditionally!(message) end end end diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index 971cc816454..f405c341398 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -125,10 +125,7 @@ module API key = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id]) not_found!('Deploy Key') unless key - check_unmodified_since(key.updated_at) - - status 204 - key.destroy + destroy_conditionally!(key) end end end diff --git a/lib/api/environments.rb b/lib/api/environments.rb index 3fc423ae79a..e33269f9483 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -78,10 +78,8 @@ module API authorize! :update_environment, user_project environment = user_project.environments.find(params[:environment_id]) - check_unmodified_since(environment.updated_at) - status 204 - environment.destroy + destroy_conditionally!(environment) end desc 'Stops an existing environment' do diff --git a/lib/api/groups.rb b/lib/api/groups.rb index c9b32a85487..ee2ad27837b 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -117,11 +117,10 @@ module API delete ":id" do group = find_group!(params[:id]) authorize! :admin_group, group - - check_unmodified_since(group.updated_at) - status 204 - ::Groups::DestroyService.new(group, current_user).execute + destroy_conditionally!(group) do |group| + ::Groups::DestroyService.new(group, current_user).execute + end end desc 'Get a list of projects in this group.' do diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 1c74a14d91c..8d4f8c01903 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -11,14 +11,25 @@ module API declared(params, options).to_h.symbolize_keys end - def check_unmodified_since(last_modified) - if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) if headers.key?('If-Unmodified-Since') rescue nil + def check_unmodified_since!(last_modified) + if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) rescue nil - if if_unmodified_since && if_unmodified_since < last_modified + if if_unmodified_since && last_modified > if_unmodified_since render_api_error!('412 Precondition Failed', 412) end end + def destroy_conditionally!(resource, last_update_field: :updated_at) + check_unmodified_since!(resource.public_send(last_update_field)) + + status 204 + if block_given? + yield resource + else + resource.destroy + end + end + def current_user return @current_user if defined?(@current_user) diff --git a/lib/api/issues.rb b/lib/api/issues.rb index cee9898d3a6..6503629e2a2 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -230,10 +230,8 @@ module API not_found!('Issue') unless issue authorize!(:destroy_issue, issue) - check_unmodified_since(issue.updated_at) - status 204 - issue.destroy + destroy_conditionally!(issue) end desc 'List merge requests closing issue' do diff --git a/lib/api/labels.rb b/lib/api/labels.rb index 45fa57fdf55..c0cf618ee8d 100644 --- a/lib/api/labels.rb +++ b/lib/api/labels.rb @@ -56,10 +56,7 @@ module API label = user_project.labels.find_by(title: params[:name]) not_found!('Label') unless label - check_unmodified_since(label.updated_at) - - status 204 - label.destroy + destroy_conditionally!(label) end desc 'Update an existing label. At least one optional parameter is required.' do diff --git a/lib/api/members.rb b/lib/api/members.rb index 5634f123eca..a5d3d7f25a0 100644 --- a/lib/api/members.rb +++ b/lib/api/members.rb @@ -93,12 +93,11 @@ module API end delete ":id/members/:user_id" do source = find_source(source_type, params[:id]) - # Ensure that memeber exists member = source.members.find_by!(user_id: params[:user_id]) - check_unmodified_since(member.updated_at) - status 204 - ::Members::DestroyService.new(source, current_user, declared_params).execute + destroy_conditionally!(member) do + ::Members::DestroyService.new(source, current_user, declared_params).execute + end end end end diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index c6fecc1aa6c..969c6064662 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -164,10 +164,8 @@ module API merge_request = find_project_merge_request(params[:merge_request_iid]) authorize!(:destroy_merge_request, merge_request) - check_unmodified_since(merge_request.updated_at) - status 204 - merge_request.destroy + destroy_conditionally!(merge_request) end params do diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 58d71787aca..e116448c15b 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -131,10 +131,10 @@ module API note = user_project.notes.find(params[:note_id]) authorize! :admin_note, note - check_unmodified_since(note.updated_at) - status 204 - ::Notes::DestroyService.new(user_project, current_user).execute(note) + destroy_conditionally!(note) do |note| + ::Notes::DestroyService.new(user_project, current_user).execute(note) + end end end end diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb index 74d736fda59..5b457bbe639 100644 --- a/lib/api/project_hooks.rb +++ b/lib/api/project_hooks.rb @@ -96,10 +96,7 @@ module API delete ":id/hooks/:hook_id" do hook = user_project.hooks.find(params.delete(:hook_id)) - check_unmodified_since(hook.updated_at) - - status 204 - hook.destroy + destroy_conditionally!(hook) end end end diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb index 645162d564d..704e8c6718d 100644 --- a/lib/api/project_snippets.rb +++ b/lib/api/project_snippets.rb @@ -116,10 +116,8 @@ module API not_found!('Snippet') unless snippet authorize! :admin_project_snippet, snippet - check_unmodified_since(snippet.updated_at) - status 204 - snippet.destroy + destroy_conditionally!(snippet) end desc 'Get a raw project snippet' diff --git a/lib/api/projects.rb b/lib/api/projects.rb index eab0ca0b3c9..36fe3f243b9 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -334,9 +334,10 @@ module API desc 'Remove a project' delete ":id" do authorize! :remove_project, user_project - check_unmodified_since(user_project.updated_at) - ::Projects::DestroyService.new(user_project, current_user, {}).async_execute + destroy_conditionally!(user_project) do + ::Projects::DestroyService.new(user_project, current_user, {}).async_execute + end accepted! end diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 88fc62d33df..daa8ddbe251 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -45,8 +45,10 @@ module API end delete '/' do authenticate_runner! - status 204 - Ci::Runner.find_by_token(params[:token]).destroy + + runner = Ci::Runner.find_by_token(params[:token]) + + destroy_conditionally!(runner) end desc 'Validates authentication credentials' do diff --git a/lib/api/runners.rb b/lib/api/runners.rb index e3b2eb904b7..68c2120cc15 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -79,10 +79,8 @@ module API runner = get_runner(params[:id]) authenticate_delete_runner!(runner) - check_unmodified_since(runner.updated_at) - status 204 - runner.destroy! + destroy_conditionally!(runner) end end @@ -137,8 +135,7 @@ module API runner = runner_project.runner forbidden!("Only one project associated with the runner. Please remove the runner instead") if runner.projects.count == 1 - status 204 - runner_project.destroy + destroy_conditionally!(runner_project) end end diff --git a/lib/api/services.rb b/lib/api/services.rb index 4fef3383e5e..2b5ef75b6bf 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -655,8 +655,8 @@ module API end delete ":id/services/:service_slug" do service = user_project.find_or_initialize_service(params[:service_slug].underscore) - # Todo, not sure - check_unmodified_since(service.updated_at) + # Todo: Check if this done the right way + check_unmodified_since!(service.updated_at) attrs = service_attributes(service).inject({}) do |hash, key| hash.merge!(key => nil) diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 7107b3d669c..00eb7c60f16 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -122,10 +122,8 @@ module API return not_found!('Snippet') unless snippet authorize! :destroy_personal_snippet, snippet - check_unmodified_since(snippet.updated_at) - status 204 - snippet.destroy + destroy_conditionally!(snippet) end desc 'Get a raw snippet' do diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 64066a75b15..6b6a03e3300 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -66,10 +66,7 @@ module API hook = SystemHook.find_by(id: params[:id]) not_found!('System hook') unless hook - check_unmodified_since(hook.updated_at) - - status 204 - hook.destroy + destroy_conditionally!(hook) end end end diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb index 4ae70c65759..c9fee7e5193 100644 --- a/lib/api/triggers.rb +++ b/lib/api/triggers.rb @@ -140,10 +140,7 @@ module API trigger = user_project.triggers.find(params.delete(:trigger_id)) return not_found!('Trigger') unless trigger - check_unmodified_since(trigger.updated_at) - - status 204 - trigger.destroy + destroy_conditionally!(trigger) end end end diff --git a/lib/api/users.rb b/lib/api/users.rb index 942bb72cf97..d7c7b9ae9c1 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -230,13 +230,7 @@ module API key = user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key -<<<<<<< HEAD - status 204 -======= - check_unmodified_since(key.updated_at) - ->>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints - key.destroy + destroy_conditionally!(key) end desc 'Add an email address to a specified user. Available only for admins.' do @@ -292,14 +286,11 @@ module API email = user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email -<<<<<<< HEAD - Emails::DestroyService.new(user, email: email.email).execute -======= - check_unmodified_since(email.updated_at) + destroy_conditionally!(email) do |email| + Emails::DestroyService.new(current_user, email: email.email).execute + end - email.destroy user.update_secondary_emails! ->>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints end desc 'Delete a user. Available only for admins.' do @@ -315,14 +306,9 @@ module API user = User.find_by(id: params[:id]) not_found!('User') unless user -<<<<<<< HEAD - status 204 - user.delete_async(deleted_by: current_user, params: params) -======= - check_unmodified_since(user.updated_at) - - ::Users::DestroyService.new(current_user).execute(user) ->>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints + destroy_conditionally!(user) do + user.delete_async(deleted_by: current_user, params: params) + end end desc 'Block a user. Available only for admins.' @@ -500,10 +486,7 @@ module API key = current_user.keys.find_by(id: params[:key_id]) not_found!('Key') unless key - check_unmodified_since(key.updated_at) - - status 204 - key.destroy + destroy_conditionally!(key) end desc "Get the currently authenticated user's email addresses" do @@ -554,9 +537,11 @@ module API email = current_user.emails.find_by(id: params[:email_id]) not_found!('Email') unless email -<<<<<<< HEAD - status 204 - Emails::DestroyService.new(current_user, email: email.email).execute + destroy_conditionally!(email) do |email| + Emails::DestroyService.new(current_user, email: email.email).execute + end + + current_user.update_secondary_emails! end desc 'Get a list of user activities' @@ -572,12 +557,6 @@ module API .reorder(last_activity_on: :asc) present paginate(activities), with: Entities::UserActivity -======= - check_unmodified_since(email.updated_at) - - email.destroy - current_user.update_secondary_emails! ->>>>>>> API: Respect the 'If-Unmodified-Since' for delete endpoints end end end diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 9884c1ec206..54900c75eb8 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -283,7 +283,7 @@ describe API::Tags do it_behaves_like '404 response' do let(:request) { delete api(route, current_user) } - let(:message) { 'No such tag' } + let(:message) { '404 Tag Not Found' } end end @@ -394,7 +394,7 @@ describe API::Tags do it_behaves_like '404 response' do let(:request) { put api(route, current_user), description: new_description } - let(:message) { 'Tag does not exist' } + let(:message) { '404 Tag Not Found' } end end -- cgit v1.2.1 From f0f3f38576c0691e6d0e751c962382beea998afb Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Thu, 2 Mar 2017 14:21:36 +0100 Subject: Use commit date for branches and tags --- lib/api/branches.rb | 15 +++++++++++---- lib/api/tags.rb | 15 +++++++++++---- spec/requests/api/tags_spec.rb | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/api/branches.rb b/lib/api/branches.rb index d3dbf941298..b87f7cdbad1 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -125,11 +125,18 @@ module API delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do authorize_push_project - result = DeleteBranchService.new(user_project, current_user) - .execute(params[:branch]) + branch = user_project.repository.find_branch(params[:branch]) + not_found!('Branch') unless branch + + commit = user_project.repository.commit(branch.dereferenced_target) + + destroy_conditionally!(commit, last_update_field: :authored_date) do + result = DeleteBranchService.new(user_project, current_user) + .execute(params[:branch]) - if result[:status] != :success - render_api_error!(result[:message], result[:return_code]) + if result[:status] != :success + render_api_error!(result[:message], result[:return_code]) + end end end diff --git a/lib/api/tags.rb b/lib/api/tags.rb index 1333747cced..81b17935b81 100644 --- a/lib/api/tags.rb +++ b/lib/api/tags.rb @@ -65,11 +65,18 @@ module API delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do authorize_push_project - result = ::Tags::DestroyService.new(user_project, current_user) - .execute(params[:tag_name]) + tag = user_project.repository.find_tag(params[:tag_name]) + not_found!('Tag') unless tag + + commit = user_project.repository.commit(tag.dereferenced_target) + + destroy_conditionally!(commit, last_update_field: :authored_date) do + result = ::Tags::DestroyService.new(user_project, current_user) + .execute(params[:tag_name]) - if result[:status] != :success - render_api_error!(result[:message], result[:return_code]) + if result[:status] != :success + render_api_error!(result[:message], result[:return_code]) + end end end diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 54900c75eb8..6ac0caa7fe8 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -394,7 +394,7 @@ describe API::Tags do it_behaves_like '404 response' do let(:request) { put api(route, current_user), description: new_description } - let(:message) { '404 Tag Not Found' } + let(:message) { 'Tag does not exist' } end end -- cgit v1.2.1 From dcd4ea473cab20eee05995ecaca043da98ca5a8d Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Thu, 24 Aug 2017 10:41:54 +0200 Subject: Update remaining endpoints --- lib/api/group_variables.rb | 3 +-- lib/api/helpers.rb | 2 +- lib/api/pipeline_schedules.rb | 3 +-- lib/api/projects.rb | 1 - lib/api/protected_branches.rb | 4 +--- lib/api/services.rb | 14 +++++++------- lib/api/users.rb | 7 +++++-- lib/api/variables.rb | 1 + spec/requests/api/pipeline_schedules_spec.rb | 3 +-- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/api/group_variables.rb b/lib/api/group_variables.rb index f64da4ab77b..25152f30998 100644 --- a/lib/api/group_variables.rb +++ b/lib/api/group_variables.rb @@ -88,8 +88,7 @@ module API variable = user_group.variables.find_by(key: params[:key]) not_found!('GroupVariable') unless variable - status 204 - variable.destroy + destroy_conditionally!(variable) end end end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 8d4f8c01903..84980864151 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -14,7 +14,7 @@ module API def check_unmodified_since!(last_modified) if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) rescue nil - if if_unmodified_since && last_modified > if_unmodified_since + if if_unmodified_since && last_modified && last_modified > if_unmodified_since render_api_error!('412 Precondition Failed', 412) end end diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb index dbeaf9e17ef..e3123ef4e2d 100644 --- a/lib/api/pipeline_schedules.rb +++ b/lib/api/pipeline_schedules.rb @@ -117,8 +117,7 @@ module API not_found!('PipelineSchedule') unless pipeline_schedule authorize! :admin_pipeline_schedule, pipeline_schedule - status :accepted - present pipeline_schedule.destroy, with: Entities::PipelineScheduleDetails + destroy_conditionally!(pipeline_schedule) end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 36fe3f243b9..78e25b6da03 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -1,7 +1,6 @@ require_dependency 'declarative_policy' module API - # Projects API class Projects < Grape::API include PaginationParams diff --git a/lib/api/protected_branches.rb b/lib/api/protected_branches.rb index dccf4fa27a7..15fcb9e8e27 100644 --- a/lib/api/protected_branches.rb +++ b/lib/api/protected_branches.rb @@ -76,9 +76,7 @@ module API delete ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do protected_branch = user_project.protected_branches.find_by!(name: params[:name]) - protected_branch.destroy - - status 204 + destroy_conditionally!(protected_branch) end end end diff --git a/lib/api/services.rb b/lib/api/services.rb index 2b5ef75b6bf..ff9ddd44439 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -655,15 +655,15 @@ module API end delete ":id/services/:service_slug" do service = user_project.find_or_initialize_service(params[:service_slug].underscore) - # Todo: Check if this done the right way - check_unmodified_since!(service.updated_at) - attrs = service_attributes(service).inject({}) do |hash, key| - hash.merge!(key => nil) - end + destroy_conditionally!(service) do + attrs = service_attributes(service).inject({}) do |hash, key| + hash.merge!(key => nil) + end - unless service.update_attributes(attrs.merge(active: false)) - render_api_error!('400 Bad Request', 400) + unless service.update_attributes(attrs.merge(active: false)) + render_api_error!('400 Bad Request', 400) + end end end diff --git a/lib/api/users.rb b/lib/api/users.rb index d7c7b9ae9c1..96f47bb618a 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -408,8 +408,11 @@ module API requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token' end delete ':impersonation_token_id' do - status 204 - find_impersonation_token.revoke! + token = find_impersonation_token + + destroy_conditionally!(token) do + token.revoke! + end end end end diff --git a/lib/api/variables.rb b/lib/api/variables.rb index 7c0fdd3d1be..da71787abab 100644 --- a/lib/api/variables.rb +++ b/lib/api/variables.rb @@ -88,6 +88,7 @@ module API variable = user_project.variables.find_by(key: params[:key]) not_found!('Variable') unless variable + # Variables don't have any timestamp. Therfore, destroy unconditionally. status 204 variable.destroy end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 1fc0ec528b9..150a391bb8d 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -267,8 +267,7 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", master) end.to change { project.pipeline_schedules.count }.by(-1) - expect(response).to have_http_status(:accepted) - expect(response).to match_response_schema('pipeline_schedule') + expect(response).to have_http_status(204) end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do -- cgit v1.2.1 From 915dd57fe26fb228f30ae08edc4905b24d4c4339 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Thu, 24 Aug 2017 18:03:39 +0200 Subject: Add tests for the unmodified header --- spec/requests/api/award_emoji_spec.rb | 16 +++++ spec/requests/api/boards_spec.rb | 4 ++ spec/requests/api/branches_spec.rb | 4 ++ spec/requests/api/broadcast_messages_spec.rb | 4 ++ spec/requests/api/deploy_keys_spec.rb | 4 ++ spec/requests/api/environments_spec.rb | 4 ++ spec/requests/api/group_variables_spec.rb | 4 ++ spec/requests/api/groups_spec.rb | 4 ++ spec/requests/api/issues_spec.rb | 4 ++ spec/requests/api/labels_spec.rb | 5 ++ spec/requests/api/members_spec.rb | 4 ++ spec/requests/api/merge_requests_spec.rb | 4 ++ spec/requests/api/notes_spec.rb | 12 ++++ spec/requests/api/pipeline_schedules_spec.rb | 4 ++ spec/requests/api/project_hooks_spec.rb | 4 ++ spec/requests/api/project_snippets_spec.rb | 7 ++- spec/requests/api/projects_spec.rb | 69 +++++++++++++++------- spec/requests/api/protected_branches_spec.rb | 4 ++ spec/requests/api/runner_spec.rb | 5 ++ spec/requests/api/runners_spec.rb | 12 ++++ spec/requests/api/snippets_spec.rb | 4 ++ spec/requests/api/system_hooks_spec.rb | 4 ++ spec/requests/api/tags_spec.rb | 4 ++ spec/requests/api/triggers_spec.rb | 4 ++ spec/requests/api/users_spec.rb | 24 ++++++++ .../requests/api/status_shared_examples.rb | 11 ++++ 26 files changed, 206 insertions(+), 23 deletions(-) diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 1dd9f3f6ddc..593068b8cd7 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -253,6 +253,10 @@ describe API::AwardEmoji do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) } + end end context 'when the awardable is a Merge Request' do @@ -269,6 +273,10 @@ describe API::AwardEmoji do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) } + end end context 'when the awardable is a Snippet' do @@ -282,6 +290,10 @@ describe API::AwardEmoji do expect(response).to have_http_status(204) end.to change { snippet.award_emoji.count }.from(1).to(0) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) } + end end end @@ -295,5 +307,9 @@ describe API::AwardEmoji do expect(response).to have_http_status(204) end.to change { note.award_emoji.count }.from(1).to(0) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) } + end end end diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index 43b381c2219..f698d5dddb3 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -195,6 +195,10 @@ describe API::Boards do expect(response).to have_http_status(204) end + + it_behaves_like '412 response' do + let(:request) { api("#{base_url}/#{dev_list.id}", owner) } + end end end end diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 5a2e1b2cf2d..b1e011de604 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -499,6 +499,10 @@ describe API::Branches do expect(response).to have_gitlab_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/repository/branches/#{branch_name}", user) } + end end describe 'DELETE /projects/:id/repository/merged_branches' do diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index 67989689799..b043a333d33 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -171,6 +171,10 @@ describe API::BroadcastMessages do expect(response).to have_http_status(403) end + it_behaves_like '412 response' do + let(:request) { api("/broadcast_messages/#{message.id}", admin) } + end + it 'deletes the broadcast message for admins' do expect do delete api("/broadcast_messages/#{message.id}", admin) diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index e497ec333a2..684877c33c0 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -190,6 +190,10 @@ describe API::DeployKeys do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) } + end end describe 'POST /projects/:id/deploy_keys/:key_id/enable' do diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb index 87716c6fe3a..2361809e0e1 100644 --- a/spec/requests/api/environments_spec.rb +++ b/spec/requests/api/environments_spec.rb @@ -138,6 +138,10 @@ describe API::Environments do expect(response).to have_http_status(404) expect(json_response['message']).to eq('404 Not found') end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/environments/#{environment.id}", user) } + end end context 'a non member' do diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb index 2179790d098..93b9cf85c1d 100644 --- a/spec/requests/api/group_variables_spec.rb +++ b/spec/requests/api/group_variables_spec.rb @@ -200,6 +200,10 @@ describe API::GroupVariables do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/groups/#{group.id}/variables/#{variable.key}", user) } + end end context 'authorized user with invalid permissions' do diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index a7557c7fb22..39d76cdbc74 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -488,6 +488,10 @@ describe API::Groups do expect(response).to have_http_status(204) end + it_behaves_like '412 response' do + let(:request) { api("/groups/#{group1.id}", user1) } + end + it "does not remove a group if not an owner" do user4 = create(:user) group1.add_master(user4) diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 7d120e4a234..58d89451073 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -1304,6 +1304,10 @@ describe API::Issues, :mailer do expect(response).to have_http_status(204) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}", owner) } + end end context 'when issue does not exist' do diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index 5a4257d1009..b231fdea2a3 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -189,6 +189,11 @@ describe API::Labels do delete api("/projects/#{project.id}/labels", user) expect(response).to have_http_status(400) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/labels", user) } + let(:params) { { name: 'label1' } } + end end describe 'PUT /projects/:id/labels' do diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index 06aca698c91..d3bae8d2888 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -284,6 +284,10 @@ describe API::Members do expect(response).to have_http_status(204) end.to change { source.members.count }.by(-1) end + + it_behaves_like '412 response' do + let(:request) { api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) } + end end it 'returns 404 if member does not exist' do diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 0db645863fb..9027090aabd 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -698,6 +698,10 @@ describe API::MergeRequests do expect(response).to have_gitlab_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user) } + end end end diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 75e5062a99c..f5882c0c74a 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -390,6 +390,10 @@ describe API::Notes do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", user) } + end end context 'when noteable is a Snippet' do @@ -410,6 +414,10 @@ describe API::Notes do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user) } + end end context 'when noteable is a Merge Request' do @@ -430,6 +438,10 @@ describe API::Notes do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes/#{merge_request_note.id}", user) } + end end end end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 150a391bb8d..b6a5a7ffbb5 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -275,6 +275,10 @@ describe API::PipelineSchedules do expect(response).to have_http_status(:not_found) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", master) } + end end context 'authenticated user with invalid permissions' do diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index 2829c243af3..ac3bab09c4c 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -212,5 +212,9 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(response).to have_http_status(404) expect(WebHook.exists?(hook.id)).to be_truthy end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/hooks/#{hook.id}", user) } + end end end diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 2b541f5719e..0ea95f487ac 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -228,9 +228,6 @@ describe API::ProjectSnippets do let(:snippet) { create(:project_snippet, author: admin) } it 'deletes snippet' do - admin = create(:admin) - snippet = create(:project_snippet, author: admin) - delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) expect(response).to have_http_status(204) @@ -242,6 +239,10 @@ describe API::ProjectSnippets do expect(response).to have_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) } + end end describe 'GET /projects/:project_id/snippets/:id/raw' do diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index a89a58ff713..46550243d06 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1029,6 +1029,10 @@ describe API::Projects do delete api("/projects/#{project.id}/snippets/1234", user) expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/snippets/#{snippet.id}", user) } + end end describe 'GET /projects/:id/snippets/:snippet_id/raw' do @@ -1104,23 +1108,31 @@ describe API::Projects do project_fork_target.group.add_developer user2 end - it 'is forbidden to non-owner users' do - delete api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) - end + context 'for a forked project' do + before do + post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) + project_fork_target.reload + expect(project_fork_target.forked_from_project).not_to be_nil + expect(project_fork_target.forked?).to be_truthy + end - it 'makes forked project unforked' do - post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - project_fork_target.reload - expect(project_fork_target.forked_from_project).not_to be_nil - expect(project_fork_target.forked?).to be_truthy + it 'makes forked project unforked' do + delete api("/projects/#{project_fork_target.id}/fork", admin) - delete api("/projects/#{project_fork_target.id}/fork", admin) + expect(response).to have_http_status(204) + project_fork_target.reload + expect(project_fork_target.forked_from_project).to be_nil + expect(project_fork_target.forked?).not_to be_truthy + end - expect(response).to have_http_status(204) - project_fork_target.reload - expect(project_fork_target.forked_from_project).to be_nil - expect(project_fork_target.forked?).not_to be_truthy + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project_fork_target.id}/fork", admin) } + end + end + + it 'is forbidden to non-owner users' do + delete api("/projects/#{project_fork_target.id}/fork", user2) + expect(response).to have_http_status(403) end it 'is idempotent if not forked' do @@ -1188,14 +1200,23 @@ describe API::Projects do end describe 'DELETE /projects/:id/share/:group_id' do - it 'returns 204 when deleting a group share' do - group = create(:group, :public) - create(:project_group_link, group: group, project: project) + context 'for a valid group' do + let(:group) { create(:group, :public) } + + before do + create(:project_group_link, group: group, project: project) + end + + it 'returns 204 when deleting a group share' do + delete api("/projects/#{project.id}/share/#{group.id}", user) - delete api("/projects/#{project.id}/share/#{group.id}", user) + expect(response).to have_http_status(204) + expect(project.project_group_links).to be_empty + end - expect(response).to have_http_status(204) - expect(project.project_group_links).to be_empty + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/share/#{group.id}", user) } + end end it 'returns a 400 when group id is not an integer' do @@ -1519,6 +1540,10 @@ describe API::Projects do expect(json_response['message']).to eql('202 Accepted') end + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}", user) } + end + it 'does not remove a project if not an owner' do user3 = create(:user) project.team << [user3, :developer] @@ -1549,6 +1574,10 @@ describe API::Projects do delete api('/projects/1328', admin) expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}", admin) } + end end end diff --git a/spec/requests/api/protected_branches_spec.rb b/spec/requests/api/protected_branches_spec.rb index 1aa8a95780e..07d7f96bd70 100644 --- a/spec/requests/api/protected_branches_spec.rb +++ b/spec/requests/api/protected_branches_spec.rb @@ -213,6 +213,10 @@ describe API::ProtectedBranches do expect(response).to have_gitlab_http_status(204) end + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/protected_branches/#{branch_name}", user) } + end + it "returns 404 if branch does not exist" do delete api("/projects/#{project.id}/protected_branches/barfoo", user) diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index e9ee3dd679d..993164aa8fe 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -149,6 +149,11 @@ describe API::Runner do expect(response).to have_http_status 204 expect(Ci::Runner.count).to eq(0) end + + it_behaves_like '412 response' do + let(:request) { api('/runners') } + let(:params) { { token: runner.token } } + end end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index c8ff25f70fa..244895a417e 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -279,6 +279,10 @@ describe API::Runners do expect(response).to have_http_status(204) end.to change { Ci::Runner.shared.count }.by(-1) end + + it_behaves_like '412 response' do + let(:request) { api("/runners/#{shared_runner.id}", admin) } + end end context 'when runner is not shared' do @@ -332,6 +336,10 @@ describe API::Runners do expect(response).to have_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end + + it_behaves_like '412 response' do + let(:request) { api("/runners/#{specific_runner.id}", user) } + end end end @@ -463,6 +471,10 @@ describe API::Runners do expect(response).to have_http_status(204) end.to change { project.runners.count }.by(-1) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) } + end end context 'when runner have one associated projects' do diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index d09b8bc42f1..351dd3276d0 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -270,6 +270,10 @@ describe API::Snippets do expect(response).to have_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end + + it_behaves_like '412 response' do + let(:request) { api("/snippets/#{public_snippet.id}", user) } + end end describe "GET /snippets/:id/user_agent_detail" do diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index f65b475fe44..216d278ad21 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -102,5 +102,9 @@ describe API::SystemHooks do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/hooks/#{hook.id}", admin) } + end end end diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 6ac0caa7fe8..0bf7863bdc8 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -278,6 +278,10 @@ describe API::Tags do expect(response).to have_gitlab_http_status(204) end + it_behaves_like '412 response' do + let(:request) { api(route, current_user) } + end + context 'when tag does not exist' do let(:tag_name) { 'unknown' } diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 1e206fd2a9e..d1ed57b1825 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -293,6 +293,10 @@ describe API::Triggers do expect(response).to have_http_status(404) end + + it_behaves_like '412 response' do + let(:request) { api("/projects/#{project.id}/triggers/#{trigger.id}", user) } + end end context 'authenticated user with invalid permissions' do diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 49739a1601a..5fef4437997 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -733,6 +733,10 @@ describe API::Users do end.to change { user.keys.count }.by(-1) end + it_behaves_like '412 response' do + let(:request) { api("/users/#{user.id}/keys/#{key.id}", admin) } + end + it 'returns 404 error if user not found' do user.keys << key user.save @@ -838,6 +842,10 @@ describe API::Users do end.to change { user.emails.count }.by(-1) end + it_behaves_like '412 response' do + let(:request) { api("/users/#{user.id}/emails/#{email.id}", admin) } + end + it 'returns 404 error if user not found' do user.emails << email user.save @@ -876,6 +884,10 @@ describe API::Users do expect { Namespace.find(namespace.id) }.to raise_error ActiveRecord::RecordNotFound end + it_behaves_like '412 response' do + let(:request) { api("/users/#{user.id}", admin) } + end + it "does not delete for unauthenticated user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}") } expect(response).to have_http_status(401) @@ -1116,6 +1128,10 @@ describe API::Users do end.to change { user.keys.count}.by(-1) end + it_behaves_like '412 response' do + let(:request) { api("/user/keys/#{key.id}", user) } + end + it "returns 404 if key ID not found" do delete api("/user/keys/42", user) @@ -1239,6 +1255,10 @@ describe API::Users do end.to change { user.emails.count}.by(-1) end + it_behaves_like '412 response' do + let(:request) { api("/user/emails/#{email.id}", user) } + end + it "returns 404 if email ID not found" do delete api("/user/emails/42", user) @@ -1551,6 +1571,10 @@ describe API::Users do expect(json_response['message']).to eq('403 Forbidden') end + it_behaves_like '412 response' do + let(:request) { api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) } + end + it 'revokes a impersonation token' do delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb index 226277411d6..1bffd1e49db 100644 --- a/spec/support/shared_examples/requests/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -40,3 +40,14 @@ shared_examples_for '404 response' do end end end + +shared_examples_for '412 response' do + let(:params) { nil } + before do + delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' } + end + + it 'returns 412' do + expect(response).to have_gitlab_http_status(412) + end +end -- cgit v1.2.1 From 8bd9fb4cc4f8689a23c68e1b7f893ee59907069f Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Fri, 25 Aug 2017 14:31:09 +0200 Subject: Add changelog and doc --- changelogs/unreleased/api-delete-respect-headers.yml | 5 +++++ doc/api/README.md | 1 + 2 files changed, 6 insertions(+) create mode 100644 changelogs/unreleased/api-delete-respect-headers.yml diff --git a/changelogs/unreleased/api-delete-respect-headers.yml b/changelogs/unreleased/api-delete-respect-headers.yml new file mode 100644 index 00000000000..cfc8fbfdf91 --- /dev/null +++ b/changelogs/unreleased/api-delete-respect-headers.yml @@ -0,0 +1,5 @@ +--- +title: 'API: Respect the "If-Unmodified-Since" header when delting a resource' +merge_request: 9621 +author: Robert Schilling +type: added diff --git a/doc/api/README.md b/doc/api/README.md index 266b5f018d9..c2a08dcff07 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -263,6 +263,7 @@ The following table shows the possible return codes for API requests. | `404 Not Found` | A resource could not be accessed, e.g., an ID for a resource could not be found. | | `405 Method Not Allowed` | The request is not supported. | | `409 Conflict` | A conflicting resource already exists, e.g., creating a project with a name that already exists. | +| `412` | Indicates the request was denied. May happen if the `If-Unmodified-Since` header is provided when trying to delete a resource, which was modified in between. | | `422 Unprocessable` | The entity could not be processed. | | `500 Server Error` | While handling the request something went wrong server-side. | -- cgit v1.2.1 From 40819467b957ce0768ae1acfeabb2184a1b87679 Mon Sep 17 00:00:00 2001 From: James Lopez Date: Mon, 28 Aug 2017 14:18:14 +0200 Subject: fix typo --- spec/support/import_export/export_file_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/import_export/export_file_helper.rb b/spec/support/import_export/export_file_helper.rb index 931c91bde7c..562423afc2a 100644 --- a/spec/support/import_export/export_file_helper.rb +++ b/spec/support/import_export/export_file_helper.rb @@ -35,7 +35,7 @@ module ExportFileHelper project: project, commit_id: ci_pipeline.sha) - create(:event, :created, target: milestone, project: project, author: user, action: 5) + event = create(:event, :created, target: milestone, project: project, author: user, action: 5) create(:push_event_payload, event: event) create(:project_member, :master, user: user, project: project) create(:ci_variable, project: project) -- cgit v1.2.1 From b870ae1f59ab0b3f4a10f9dbb2d64324b90ba38b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 28 Aug 2017 17:35:10 +0200 Subject: Eager load head pipeline projects for MRs index This ensures the project of an MR's head pipeline is eager loaded, preventing an N+1 query problem from occurring when viewing the list of MRs of a project. --- app/controllers/concerns/issuable_collections.rb | 12 +++++++++++- changelogs/unreleased/mr-index-eager-load.yml | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/mr-index-eager-load.yml diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index b43b2c5621f..a34a82b7ba6 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -15,7 +15,17 @@ module IssuableCollections end def merge_requests_collection - merge_requests_finder.execute.preload(:source_project, :target_project, :author, :assignee, :labels, :milestone, :head_pipeline, target_project: :namespace, merge_request_diff: :merge_request_diff_commits) + merge_requests_finder.execute.preload( + :source_project, + :target_project, + :author, + :assignee, + :labels, + :milestone, + head_pipeline: :project, + target_project: :namespace, + merge_request_diff: :merge_request_diff_commits + ) end def issues_finder diff --git a/changelogs/unreleased/mr-index-eager-load.yml b/changelogs/unreleased/mr-index-eager-load.yml new file mode 100644 index 00000000000..11c33055b17 --- /dev/null +++ b/changelogs/unreleased/mr-index-eager-load.yml @@ -0,0 +1,5 @@ +--- +title: Eager load head pipeline projects for MRs index +merge_request: +author: +type: other -- cgit v1.2.1 From 8d72f0973032afa79729d651ebfaa786a5f519f2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 25 Aug 2017 18:03:41 -0400 Subject: Fix a transient failure in mini_pipeline_graph_spec This spec failed reliably with a specific run order (see issue), the reasons for which are still unknown. This simplification resolves the failure. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/34323 --- .../projects/commit/mini_pipeline_graph_spec.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 2ef74e8857c..807a2189cc4 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -1,13 +1,8 @@ require 'rails_helper' feature 'Mini Pipeline Graph in Commit View', :js do - let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } - before do - sign_in(user) - end - context 'when commit has pipelines' do let(:pipeline) do create(:ci_empty_pipeline, @@ -15,21 +10,14 @@ feature 'Mini Pipeline Graph in Commit View', :js do ref: project.default_branch, sha: project.commit.sha) end + let(:build) { create(:ci_build, pipeline: pipeline) } - let(:build) do - create(:ci_build, pipeline: pipeline) - end - - before do + it 'displays a mini pipeline graph' do build.run visit project_commit_path(project, project.commit.id) - end - it 'should display a mini pipeline graph' do expect(page).to have_selector('.mr-widget-pipeline-graph') - end - it 'should show the builds list when stage is clicked' do first('.mini-pipeline-graph-dropdown-toggle').click wait_for_requests @@ -38,6 +26,8 @@ feature 'Mini Pipeline Graph in Commit View', :js do expect(page).to have_selector('.ci-status-icon-running') expect(page).to have_content(build.stage) end + + build.drop end end -- cgit v1.2.1 From 84ab8a716f2f2739da82c5bafd8f29f2ee7180cb Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 28 Aug 2017 15:35:26 +0900 Subject: Reproduced bug --- spec/requests/api/triggers_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 1e206fd2a9e..b5d6b732969 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -86,6 +86,22 @@ describe API::Triggers do end end + context 'when legacy trigger' do + before do + trigger.update(owner: nil) + end + + it 'creates pipeline' do + post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') + + expect(response).to have_http_status(201) + expect(json_response).to include('id' => pipeline.id) + pipeline.builds.reload + expect(pipeline.builds.pending.size).to eq(2) + expect(pipeline.builds.size).to eq(5) + end + end + context 'when triggering a pipeline from a trigger token' do it 'does not leak the presence of project when token is for different project' do post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } -- cgit v1.2.1 From 815483b389e9b8efb16f94316a1a9425bc27a7a5 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 28 Aug 2017 16:00:11 +0900 Subject: Remove trigger_request.trigger.owner --- app/services/ci/create_pipeline_service.rb | 2 +- spec/requests/api/triggers_spec.rb | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb index d0ba9f89460..de2cd7e87be 100644 --- a/app/services/ci/create_pipeline_service.rb +++ b/app/services/ci/create_pipeline_service.rb @@ -15,7 +15,7 @@ module Ci pipeline_schedule: schedule ) - result = validate(current_user || trigger_request.trigger.owner, + result = validate(current_user, ignore_skip_ci: ignore_skip_ci, save_on_errors: save_on_errors) diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index b5d6b732969..402d1040436 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -84,21 +84,21 @@ describe API::Triggers do expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) end end - end - context 'when legacy trigger' do - before do - trigger.update(owner: nil) - end + context 'when legacy trigger' do + before do + trigger.update(owner: nil) + end - it 'creates pipeline' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') + it 'creates pipeline' do + post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') - expect(response).to have_http_status(201) - expect(json_response).to include('id' => pipeline.id) - pipeline.builds.reload - expect(pipeline.builds.pending.size).to eq(2) - expect(pipeline.builds.size).to eq(5) + expect(response).to have_http_status(201) + expect(json_response).to include('id' => pipeline.id) + pipeline.builds.reload + expect(pipeline.builds.pending.size).to eq(2) + expect(pipeline.builds.size).to eq(5) + end end end -- cgit v1.2.1 From 2b3b5c3bcefbff82208f2797e6533cf7e179931d Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 28 Aug 2017 16:01:29 +0900 Subject: Add changelog --- ...trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml diff --git a/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml new file mode 100644 index 00000000000..1d4bbeee866 --- /dev/null +++ b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml @@ -0,0 +1,5 @@ +--- +title: Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5.1 +merge_request: +author: +type: fixed -- cgit v1.2.1 From 1d7a1e9ce7c8ba44c6f26af38d9bf0f34e92e476 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 28 Aug 2017 18:01:59 +0900 Subject: Fix spec --- spec/services/ci/create_pipeline_service_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index fdd0cea4f3b..ab3c8a34783 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -413,7 +413,7 @@ describe Ci::CreatePipelineService do end context 'when trigger belongs to a developer' do - let(:user) {} + let(:user) { trigger_request.trigger.owner } let(:trigger_request) do create(:ci_trigger_request).tap do |request| @@ -431,7 +431,7 @@ describe Ci::CreatePipelineService do end context 'when trigger belongs to a master' do - let(:user) {} + let(:user) { trigger_request.trigger.owner } let(:trigger_request) do create(:ci_trigger_request).tap do |request| @@ -441,7 +441,7 @@ describe Ci::CreatePipelineService do end end - it 'does not create a pipeline' do + it 'creates a pipeline' do expect(execute_service(trigger_request: trigger_request)) .to be_persisted expect(Ci::Pipeline.count).to eq(1) -- cgit v1.2.1 From 9b7a0ecf59cca248681b7837b706428e86bb1da4 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Mon, 28 Aug 2017 21:53:48 +0900 Subject: Fix changelog --- ...ne-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml index 1d4bbeee866..fb97bdb6b30 100644 --- a/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml +++ b/changelogs/unreleased/fix-sm-37040-regression-pipeline-trigger-via-api-fails-with-500-internal-server-error-in-9-5-1.yml @@ -1,5 +1,5 @@ --- -title: Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5.1 +title: Fix pipeline trigger via API fails with 500 Internal Server Error in 9.5 merge_request: author: type: fixed -- cgit v1.2.1 From 4401b7595510a6126a1d38b5743113777ad9aa2f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 29 Aug 2017 01:21:50 +0900 Subject: Fix spec --- spec/services/ci/create_pipeline_service_spec.rb | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index ab3c8a34783..4ba3dada37c 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -413,14 +413,12 @@ describe Ci::CreatePipelineService do end context 'when trigger belongs to a developer' do - let(:user) { trigger_request.trigger.owner } + let(:user) { create(:user) } + let(:trigger) { create(:ci_trigger, owner: user) } + let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) } - let(:trigger_request) do - create(:ci_trigger_request).tap do |request| - user = create(:user) - project.add_developer(user) - request.trigger.update(owner: user) - end + before do + project.add_developer(user) end it 'does not create a pipeline' do @@ -431,14 +429,12 @@ describe Ci::CreatePipelineService do end context 'when trigger belongs to a master' do - let(:user) { trigger_request.trigger.owner } + let(:user) { create(:user) } + let(:trigger) { create(:ci_trigger, owner: user) } + let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) } - let(:trigger_request) do - create(:ci_trigger_request).tap do |request| - user = create(:user) - project.add_master(user) - request.trigger.update(owner: user) - end + before do + project.add_master(user) end it 'creates a pipeline' do -- cgit v1.2.1 From bed27b6a6d1fea22596ca8e643686c8aa61fa65d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 28 Aug 2017 12:46:00 -0400 Subject: Update rubocop-gitlab-security to 0.1.0 --- .rubocop.yml | 4 ++++ Gemfile | 2 +- Gemfile.lock | 6 +++--- lib/after_commit_queue.rb | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 23bb0fa8be8..abdda90a33e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1181,6 +1181,10 @@ GitlabSecurity/DeepMunge: - 'lib/**/*.rake' - 'spec/**/*' +# To be enabled by https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13610 +GitlabSecurity/JsonSerialization: + Enabled: false + GitlabSecurity/PublicSend: Enabled: true Exclude: diff --git a/Gemfile b/Gemfile index dcdaf6cde7b..782bbfab5db 100644 --- a/Gemfile +++ b/Gemfile @@ -337,7 +337,7 @@ group :development, :test do gem 'rubocop', '~> 0.49.1', require: false gem 'rubocop-rspec', '~> 1.15.1', require: false - gem 'rubocop-gitlab-security', '~> 0.0.6', require: false + gem 'rubocop-gitlab-security', '~> 0.1.0', require: false gem 'scss_lint', '~> 0.54.0', require: false gem 'haml_lint', '~> 0.26.0', require: false gem 'simplecov', '~> 0.14.0', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 0fd52337b23..404e1ec2df0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -769,7 +769,7 @@ GEM rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-gitlab-security (0.0.6) + rubocop-gitlab-security (0.1.0) rubocop (>= 0.47.1) rubocop-rspec (1.15.1) rubocop (>= 0.42.0) @@ -1125,7 +1125,7 @@ DEPENDENCIES rspec-set (~> 0.1.3) rspec_profiling (~> 0.0.5) rubocop (~> 0.49.1) - rubocop-gitlab-security (~> 0.0.6) + rubocop-gitlab-security (~> 0.1.0) rubocop-rspec (~> 1.15.1) ruby-fogbugz (~> 0.2.1) ruby-prof (~> 0.16.2) @@ -1174,4 +1174,4 @@ DEPENDENCIES wikicloth (= 0.8.1) BUNDLED WITH - 1.15.3 + 1.15.4 diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb index b67575a3ac2..4750a2c373a 100644 --- a/lib/after_commit_queue.rb +++ b/lib/after_commit_queue.rb @@ -7,7 +7,7 @@ module AfterCommitQueue end def run_after_commit(method = nil, &block) - _after_commit_queue << proc { self.send(method) } if method + _after_commit_queue << proc { self.send(method) } if method # rubocop:disable GitlabSecurity/PublicSend _after_commit_queue << block if block true end -- cgit v1.2.1 From fed2623dfdbc1fdbb922888a08a18e7b75b8cef2 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Mon, 28 Aug 2017 12:27:01 -0500 Subject: Update CHANGELOG.md for 9.5.2 [ci skip] --- CHANGELOG.md | 9 +++++++++ changelogs/unreleased/dm-ldap-adapter-attributes.yml | 6 ------ changelogs/unreleased/fix-old-mr-diffs.yml | 6 ------ changelogs/unreleased/fix-push-events-branch-removals.yml | 5 ----- .../rd-fix-broken-configuration-for-some-integrations.yml | 5 ----- changelogs/unreleased/sh-system-hooks-ldap-users.yml | 5 ----- changelogs/unreleased/zj-fix-fe-blank-button.yml | 5 ----- 7 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 changelogs/unreleased/dm-ldap-adapter-attributes.yml delete mode 100644 changelogs/unreleased/fix-old-mr-diffs.yml delete mode 100644 changelogs/unreleased/fix-push-events-branch-removals.yml delete mode 100644 changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml delete mode 100644 changelogs/unreleased/sh-system-hooks-ldap-users.yml delete mode 100644 changelogs/unreleased/zj-fix-fe-blank-button.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index d32b6989388..ac0d22ced46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ documentation](doc/development/changelog.md) for instructions on adding your own entry. +## 9.5.2 (2017-08-28) + +- [FIXED] Fix signing in using LDAP when attribute mapping uses simple strings instead of arrays. +- [FIXED] Show un-highlighted text diffs when we do not have references to the correct blobs. +- [FIXED] Fix display of push events for removed refs. +- [FIXED] Testing of some integrations were broken due to missing ServiceHook record. +- [FIXED] Fire system hooks when a user is created via LDAP. +- [FIXED] Fix new project form not resetting the template value. + ## 9.5.1 (2017-08-23) - [FIXED] Fix merge request pipeline status when pipeline has errors. !13664 diff --git a/changelogs/unreleased/dm-ldap-adapter-attributes.yml b/changelogs/unreleased/dm-ldap-adapter-attributes.yml deleted file mode 100644 index edd68ef08e7..00000000000 --- a/changelogs/unreleased/dm-ldap-adapter-attributes.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Fix signing in using LDAP when attribute mapping uses simple strings instead - of arrays -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/fix-old-mr-diffs.yml b/changelogs/unreleased/fix-old-mr-diffs.yml deleted file mode 100644 index b0a011cf354..00000000000 --- a/changelogs/unreleased/fix-old-mr-diffs.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Show un-highlighted text diffs when we do not have references to the correct - blobs -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/fix-push-events-branch-removals.yml b/changelogs/unreleased/fix-push-events-branch-removals.yml deleted file mode 100644 index 71f368db296..00000000000 --- a/changelogs/unreleased/fix-push-events-branch-removals.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fix display of push events for removed refs -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml b/changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml deleted file mode 100644 index 00528397d64..00000000000 --- a/changelogs/unreleased/rd-fix-broken-configuration-for-some-integrations.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Testing of some integrations were broken due to missing ServiceHook record. -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/sh-system-hooks-ldap-users.yml b/changelogs/unreleased/sh-system-hooks-ldap-users.yml deleted file mode 100644 index 87514ec00ea..00000000000 --- a/changelogs/unreleased/sh-system-hooks-ldap-users.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fire system hooks when a user is created via LDAP -merge_request: -author: -type: fixed diff --git a/changelogs/unreleased/zj-fix-fe-blank-button.yml b/changelogs/unreleased/zj-fix-fe-blank-button.yml deleted file mode 100644 index 2165d4186c1..00000000000 --- a/changelogs/unreleased/zj-fix-fe-blank-button.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Fix new project form not resetting the template value -merge_request: -author: -type: fixed -- cgit v1.2.1 From d7f61bae8b498a09180bb7e782a687ae2d0c3bae Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Thu, 10 Aug 2017 16:16:43 -0300 Subject: Remove locked? check when unlocking a merge request Our state machine shall have enough knowledge to not allow states other than locked from transitioning to opened (e.g. MergeRequest#unlock_mr). --- app/models/merge_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index dbc73ed3cd4..e283c3981a4 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -819,7 +819,7 @@ class MergeRequest < ActiveRecord::Base lock_mr yield ensure - unlock_mr if locked? + unlock_mr end end -- cgit v1.2.1 From 4f17c6b7633c65a9d51dbcd9193914013707e226 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Thu, 10 Aug 2017 18:01:01 -0300 Subject: Track enqueued and ongoing MRs --- .../projects/merge_requests_controller.rb | 4 +-- app/models/merge_request.rb | 12 +++++-- app/services/merge_requests/merge_service.rb | 3 ++ .../merge_when_pipeline_succeeds_service.rb | 2 +- app/services/merge_requests/update_service.rb | 2 +- app/workers/merge_worker.rb | 2 -- spec/models/merge_request_spec.rb | 39 +++++++++++----------- spec/services/merge_requests/merge_service_spec.rb | 9 +++++ 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 2a3b73577a5..6f3dcc1d6fa 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -318,14 +318,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo elsif @merge_request.head_pipeline.success? # This can be triggered when a user clicks the auto merge button while # the tests finish at about the same time - MergeWorker.perform_async(@merge_request.id, current_user.id, params) + @merge_request.async_merge(current_user.id, params) :success else :failed end else - MergeWorker.perform_async(@merge_request.id, current_user.id, params) + @merge_request.async_merge(current_user.id, params) :success end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index e283c3981a4..1e212685c71 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -241,6 +241,14 @@ class MergeRequest < ActiveRecord::Base end end + # Calls `MergeWorker` to proceed with the merge process and + # updates `merge_jid` with the MergeWorker#jid. + # This helps tracking enqueued and ongoing merge jobs. + def async_merge(user_id, params) + jid = MergeWorker.perform_async(id, user_id, params) + update_column(:merge_jid, jid) + end + def first_commit merge_request_diff ? merge_request_diff.first_commit : compare_commits.first end @@ -384,9 +392,7 @@ class MergeRequest < ActiveRecord::Base end def merge_ongoing? - return false unless merge_jid - - Gitlab::SidekiqStatus.num_running([merge_jid]) > 0 + merge_jid && !merged? end def closed_without_fork? diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 5be749cd6a0..aac1e7e19c3 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -31,6 +31,9 @@ module MergeRequests end rescue MergeError => e log_merge_error(e.message, save_message_on_model: true) + ensure + # Make sure to clean up merge_jid in the end of the merge process. + merge_request.update_column(:merge_jid, nil) end private diff --git a/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb b/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb index aed5287940e..57c82e39410 100644 --- a/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb +++ b/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb @@ -30,7 +30,7 @@ module MergeRequests next end - MergeWorker.perform_async(merge_request.id, merge_request.merge_user_id, merge_request.merge_params) + merge_request.async_merge(merge_request.merge_user_id, merge_request.merge_params) end end diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 75a65aecd1a..6563a4101a3 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -83,7 +83,7 @@ module MergeRequests if merge_request.head_pipeline && merge_request.head_pipeline.active? MergeRequests::MergeWhenPipelineSucceedsService.new(project, current_user).execute(merge_request) else - MergeWorker.perform_async(merge_request.id, current_user.id, {}) + merge_request.async_merge(current_user.id, {}) end end diff --git a/app/workers/merge_worker.rb b/app/workers/merge_worker.rb index c3b58df92c1..48e2da338f6 100644 --- a/app/workers/merge_worker.rb +++ b/app/workers/merge_worker.rb @@ -7,8 +7,6 @@ class MergeWorker current_user = User.find(current_user_id) merge_request = MergeRequest.find(merge_request_id) - merge_request.update_column(:merge_jid, jid) - MergeRequests::MergeService.new(merge_request.target_project, current_user, params) .execute(merge_request) end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 2d10c6ef1da..de2f6c2139d 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -931,6 +931,23 @@ describe MergeRequest do end end + describe '#async_merge' do + it 'enqueues MergeWorker job and updates merge_jid' do + merge_request = create(:merge_request) + user_id = double(:user_id) + params = double(:params) + merge_jid = 'hash-123' + + expect(MergeWorker).to receive(:perform_async).with(merge_request.id, user_id, params) do + merge_jid + end + + merge_request.async_merge(user_id, params) + + expect(merge_request.reload.merge_jid).to eq(merge_jid) + end + end + describe '#check_if_can_be_merged' do let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true) } @@ -1370,29 +1387,11 @@ describe MergeRequest do end describe '#merge_ongoing?' do - it 'returns true when merge process is ongoing for merge_jid' do - merge_request = create(:merge_request, merge_jid: 'foo') - - allow(Gitlab::SidekiqStatus).to receive(:num_running).with(['foo']).and_return(1) + it 'returns true when merge_id is present and MR is not merged' do + merge_request = build_stubbed(:merge_request, state: :open, merge_jid: 'foo') expect(merge_request.merge_ongoing?).to be(true) end - - it 'returns false when no merge process running for merge_jid' do - merge_request = build(:merge_request, merge_jid: 'foo') - - allow(Gitlab::SidekiqStatus).to receive(:num_running).with(['foo']).and_return(0) - - expect(merge_request.merge_ongoing?).to be(false) - end - - it 'returns false when merge_jid is nil' do - merge_request = build(:merge_request, merge_jid: nil) - - expect(Gitlab::SidekiqStatus).not_to receive(:num_running) - - expect(merge_request.merge_ongoing?).to be(false) - end end describe "#closed_without_fork?" do diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 5cfdb5372f3..0a007bdfc3b 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -12,6 +12,15 @@ describe MergeRequests::MergeService do end describe '#execute' do + it 'cleans up merge_jid from MergeRequest' do + merge_request.update_column(:merge_jid, 'hash-123') + service = described_class.new(project, user, commit_message: 'Awesome message') + + service.execute(merge_request) + + expect(merge_request.reload.merge_jid).to be_nil + end + context 'valid params' do let(:service) { described_class.new(project, user, commit_message: 'Awesome message') } -- cgit v1.2.1 From 9068083f869ff46c2bd3e206b762312150fe8c4e Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Thu, 10 Aug 2017 18:26:42 -0300 Subject: Add changelog --- app/models/merge_request.rb | 2 +- changelogs/unreleased/36114-stuck-mrs-job-follow-up.yml | 4 ++++ spec/workers/merge_worker_spec.rb | 11 ----------- 3 files changed, 5 insertions(+), 12 deletions(-) create mode 100644 changelogs/unreleased/36114-stuck-mrs-job-follow-up.yml diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 1e212685c71..8c1ea5625db 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -392,7 +392,7 @@ class MergeRequest < ActiveRecord::Base end def merge_ongoing? - merge_jid && !merged? + !!merge_jid && !merged? end def closed_without_fork? diff --git a/changelogs/unreleased/36114-stuck-mrs-job-follow-up.yml b/changelogs/unreleased/36114-stuck-mrs-job-follow-up.yml new file mode 100644 index 00000000000..1b664efb8c2 --- /dev/null +++ b/changelogs/unreleased/36114-stuck-mrs-job-follow-up.yml @@ -0,0 +1,4 @@ +--- +title: Present enqueued merge jobs as Merging as well +merge_request: +author: diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb index ee51000161a..303193bab9b 100644 --- a/spec/workers/merge_worker_spec.rb +++ b/spec/workers/merge_worker_spec.rb @@ -27,15 +27,4 @@ describe MergeWorker do expect(source_project.repository.branch_names).not_to include('markdown') end end - - it 'persists merge_jid' do - merge_request = create(:merge_request, merge_jid: nil) - user = create(:user) - worker = described_class.new - - allow(worker).to receive(:jid) { '999' } - - expect { worker.perform(merge_request.id, user.id, {}) } - .to change { merge_request.reload.merge_jid }.from(nil).to('999') - end end -- cgit v1.2.1 From ffc576d7df8d9dd53806d48b1870d11785e8d2a7 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Mon, 28 Aug 2017 15:55:25 -0300 Subject: Rename MergeRequest#async_merge to merge_async --- app/controllers/projects/merge_requests_controller.rb | 4 ++-- app/models/merge_request.rb | 2 +- app/services/merge_requests/merge_when_pipeline_succeeds_service.rb | 2 +- app/services/merge_requests/update_service.rb | 2 +- spec/models/merge_request_spec.rb | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 6f3dcc1d6fa..e3fa3736808 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -318,14 +318,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo elsif @merge_request.head_pipeline.success? # This can be triggered when a user clicks the auto merge button while # the tests finish at about the same time - @merge_request.async_merge(current_user.id, params) + @merge_request.merge_async(current_user.id, params) :success else :failed end else - @merge_request.async_merge(current_user.id, params) + @merge_request.merge_async(current_user.id, params) :success end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 8c1ea5625db..7f73de67625 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -244,7 +244,7 @@ class MergeRequest < ActiveRecord::Base # Calls `MergeWorker` to proceed with the merge process and # updates `merge_jid` with the MergeWorker#jid. # This helps tracking enqueued and ongoing merge jobs. - def async_merge(user_id, params) + def merge_async(user_id, params) jid = MergeWorker.perform_async(id, user_id, params) update_column(:merge_jid, jid) end diff --git a/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb b/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb index 57c82e39410..850deb0ac7a 100644 --- a/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb +++ b/app/services/merge_requests/merge_when_pipeline_succeeds_service.rb @@ -30,7 +30,7 @@ module MergeRequests next end - merge_request.async_merge(merge_request.merge_user_id, merge_request.merge_params) + merge_request.merge_async(merge_request.merge_user_id, merge_request.merge_params) end end diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 6563a4101a3..2832d893e95 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -83,7 +83,7 @@ module MergeRequests if merge_request.head_pipeline && merge_request.head_pipeline.active? MergeRequests::MergeWhenPipelineSucceedsService.new(project, current_user).execute(merge_request) else - merge_request.async_merge(current_user.id, {}) + merge_request.merge_async(current_user.id, {}) end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index de2f6c2139d..92cf15a5a51 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -931,7 +931,7 @@ describe MergeRequest do end end - describe '#async_merge' do + describe '#merge_async' do it 'enqueues MergeWorker job and updates merge_jid' do merge_request = create(:merge_request) user_id = double(:user_id) @@ -942,7 +942,7 @@ describe MergeRequest do merge_jid end - merge_request.async_merge(user_id, params) + merge_request.merge_async(user_id, params) expect(merge_request.reload.merge_jid).to eq(merge_jid) end -- cgit v1.2.1 From 86f43912fcb8dbf8604b0054d020acd12071d5b2 Mon Sep 17 00:00:00 2001 From: Oswaldo Ferreira Date: Mon, 28 Aug 2017 16:41:05 -0300 Subject: Cleans merge_jid when possible on MergeService --- app/services/merge_requests/merge_service.rb | 9 ++++-- spec/services/merge_requests/merge_service_spec.rb | 33 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index aac1e7e19c3..b2b6c5627fb 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -26,14 +26,13 @@ module MergeRequests merge_request.in_locked_state do if commit after_merge + clean_merge_jid success end end rescue MergeError => e + clean_merge_jid log_merge_error(e.message, save_message_on_model: true) - ensure - # Make sure to clean up merge_jid in the end of the merge process. - merge_request.update_column(:merge_jid, nil) end private @@ -73,6 +72,10 @@ module MergeRequests end end + def clean_merge_jid + merge_request.update_column(:merge_jid, nil) + end + def branch_deletion_user @merge_request.force_remove_source_branch? ? @merge_request.author : current_user end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 0a007bdfc3b..b60136064b7 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -12,13 +12,36 @@ describe MergeRequests::MergeService do end describe '#execute' do - it 'cleans up merge_jid from MergeRequest' do - merge_request.update_column(:merge_jid, 'hash-123') - service = described_class.new(project, user, commit_message: 'Awesome message') + context 'MergeRequest#merge_jid' do + before do + merge_request.update_column(:merge_jid, 'hash-123') + end + + it 'is cleaned when no error is raised' do + service = described_class.new(project, user, commit_message: 'Awesome message') + + service.execute(merge_request) + + expect(merge_request.reload.merge_jid).to be_nil + end - service.execute(merge_request) + it 'is cleaned when expected error is raised' do + service = described_class.new(project, user, commit_message: 'Awesome message') + allow(service).to receive(:commit).and_raise(described_class::MergeError) - expect(merge_request.reload.merge_jid).to be_nil + service.execute(merge_request) + + expect(merge_request.reload.merge_jid).to be_nil + end + + it 'is not cleaned when unexpected error is raised' do + service = described_class.new(project, user, commit_message: 'Awesome message') + allow(service).to receive(:commit).and_raise(StandardError) + + expect { service.execute(merge_request) }.to raise_error(StandardError) + + expect(merge_request.reload.merge_jid).to be_present + end end context 'valid params' do -- cgit v1.2.1 From 87b51c5981db3b1b9831b01ca6e74127d57dc2d9 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Tue, 29 Aug 2017 07:14:41 +0900 Subject: Move the logic to a concern --- app/models/user.rb | 3 ++- lib/gitlab/sql/pattern.rb | 39 +++++++++++++++---------------------- spec/lib/gitlab/sql/pattern_spec.rb | 16 +++++++-------- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index e5a84ce4080..70787de4b40 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,6 +5,7 @@ class User < ActiveRecord::Base include Gitlab::ConfigHelper include Gitlab::CurrentSettings + include Gitlab::SQL::Pattern include Avatarable include Referable include Sortable @@ -303,7 +304,7 @@ class User < ActiveRecord::Base # Returns an ActiveRecord::Relation. def search(query) table = arel_table - pattern = Gitlab::SQL::Pattern.new(query).to_sql + pattern = User.to_pattern(query) order = <<~SQL CASE diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb index 46c973d8a11..26bfeeeee67 100644 --- a/lib/gitlab/sql/pattern.rb +++ b/lib/gitlab/sql/pattern.rb @@ -1,33 +1,26 @@ module Gitlab module SQL - class Pattern - MIN_CHARS_FOR_PARTIAL_MATCHING = 3 - - attr_reader :query + module Pattern + extend ActiveSupport::Concern - def initialize(query) - @query = query - end + MIN_CHARS_FOR_PARTIAL_MATCHING = 3 - def to_sql - if exact_matching? - sanitized_query - else - "%#{sanitized_query}%" + class_methods do + def to_pattern(query) + if exact_matching?(query) + sanitize_sql_like(query) + else + "%#{sanitize_sql_like(query)}%" + end end - end - def exact_matching? - !partial_matching? - end - - def partial_matching? - @query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING - end + def exact_matching?(query) + query.length < MIN_CHARS_FOR_PARTIAL_MATCHING + end - def sanitized_query - # Note: ActiveRecord::Base.sanitize_sql_like is a protected method - ActiveRecord::Base.__send__(:sanitize_sql_like, query) + def partial_matching?(query) + query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING + end end end end diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb index d0412f37098..224336421be 100644 --- a/spec/lib/gitlab/sql/pattern_spec.rb +++ b/spec/lib/gitlab/sql/pattern_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' describe Gitlab::SQL::Pattern do - describe '#to_sql' do - subject(:to_sql) { described_class.new(query).to_sql } + describe '#to_pattern' do + subject(:to_pattern) { User.to_pattern(query) } context 'when a query is shorter than 3 chars' do let(:query) { '12' } it 'returns exact matching pattern' do - expect(to_sql).to eq('12') + expect(to_pattern).to eq('12') end end @@ -16,7 +16,7 @@ describe Gitlab::SQL::Pattern do let(:query) { '_2' } it 'returns sanitized exact matching pattern' do - expect(to_sql).to eq('\_2') + expect(to_pattern).to eq('\_2') end end @@ -24,7 +24,7 @@ describe Gitlab::SQL::Pattern do let(:query) { '123' } it 'returns partial matching pattern' do - expect(to_sql).to eq('%123%') + expect(to_pattern).to eq('%123%') end end @@ -32,7 +32,7 @@ describe Gitlab::SQL::Pattern do let(:query) { '_23' } it 'returns partial matching pattern' do - expect(to_sql).to eq('%\_23%') + expect(to_pattern).to eq('%\_23%') end end @@ -40,7 +40,7 @@ describe Gitlab::SQL::Pattern do let(:query) { '1234' } it 'returns partial matching pattern' do - expect(to_sql).to eq('%1234%') + expect(to_pattern).to eq('%1234%') end end @@ -48,7 +48,7 @@ describe Gitlab::SQL::Pattern do let(:query) { '_234' } it 'returns sanitized partial matching pattern' do - expect(to_sql).to eq('%\_234%') + expect(to_pattern).to eq('%\_234%') end end end -- cgit v1.2.1 From bb1a72c9cbb02eabeafed42c0ac5be992e26ae95 Mon Sep 17 00:00:00 2001 From: Fabio Busatto Date: Tue, 29 Aug 2017 07:19:06 +0000 Subject: Update doc for dind using overlay2 --- doc/ci/docker/using_docker_build.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/ci/docker/using_docker_build.md b/doc/ci/docker/using_docker_build.md index f7c2a0ef0ca..f28c9791bee 100644 --- a/doc/ci/docker/using_docker_build.md +++ b/doc/ci/docker/using_docker_build.md @@ -134,7 +134,7 @@ In order to do that, follow the steps: # When using dind, it's wise to use the overlayfs driver for # improved performance. variables: - DOCKER_DRIVER: overlay + DOCKER_DRIVER: overlay2 services: - docker:dind @@ -248,7 +248,7 @@ aware of the following implications: By default, when using `docker:dind`, Docker uses the `vfs` storage driver which copies the filesystem on every run. This is a very disk-intensive operation -which can be avoided if a different driver is used, for example `overlay`. +which can be avoided if a different driver is used, for example `overlay2`. 1. Make sure a recent kernel is used, preferably `>= 4.2`. 1. Check whether the `overlay` module is loaded: @@ -275,8 +275,12 @@ which can be avoided if a different driver is used, for example `overlay`. ``` variables: - DOCKER_DRIVER: overlay + DOCKER_DRIVER: overlay2 ``` + +> **Note:** +- For more information about using OverlayFS with Docker, you can read + [Use the OverlayFS storage driver](https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/). ## Using the GitLab Container Registry -- cgit v1.2.1 From a9e72ae3bfc732a5c012caa56cdac7f5f7de3363 Mon Sep 17 00:00:00 2001 From: winh Date: Mon, 14 Aug 2017 14:29:11 +0200 Subject: Make download dropdown on merge request page consistent --- app/assets/stylesheets/pages/merge_requests.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/pages/merge_requests.scss b/app/assets/stylesheets/pages/merge_requests.scss index d1678a17aaf..334bec8dd7e 100644 --- a/app/assets/stylesheets/pages/merge_requests.scss +++ b/app/assets/stylesheets/pages/merge_requests.scss @@ -489,6 +489,8 @@ } .mr-source-target { + @include new-style-dropdown; + display: flex; flex-wrap: wrap; justify-content: space-between; -- cgit v1.2.1 From 1335ba6935e49acee0d93dfcca3d78108f39ec8f Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Tue, 29 Aug 2017 08:05:41 +0000 Subject: Add styles for shorter code --- app/assets/stylesheets/pages/repo.scss | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 1088eca5322..efc47861768 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -99,6 +99,30 @@ .blob-viewer-container { flex: 1; overflow: auto; + + > div, + .file-content { + display: flex; + } + + > div, + .file-content, + .blob-viewer, + .line-number, + .blob-content, + .code { + min-height: 100%; + width: 100%; + } + + .line-numbers { + min-width: 44px; + } + + .blob-content { + flex: 1; + overflow-x: auto; + } } #tabs { -- cgit v1.2.1 From ee4820a5268d02fb7ed142511d1a194f06629a1e Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Mon, 28 Aug 2017 17:13:22 +0200 Subject: Add a spec when ressource is not modified --- lib/api/projects.rb | 6 ++---- spec/requests/api/projects_spec.rb | 2 ++ .../requests/api/status_shared_examples.rb | 22 ++++++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 78e25b6da03..78d900984ac 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -365,8 +365,7 @@ module API authorize! :remove_fork_project, user_project if user_project.forked? - status 204 - user_project.forked_project_link.destroy + destroy_conditionally!(user_project.forked_project_link) else not_modified! end @@ -410,8 +409,7 @@ module API link = user_project.project_group_links.find_by(group_id: params[:group_id]) not_found!('Group Link') unless link - status 204 - link.destroy + destroy_conditionally!(link) end desc 'Upload a file' diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 46550243d06..4490e50702b 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1541,6 +1541,7 @@ describe API::Projects do end it_behaves_like '412 response' do + let(:success_status) { 202 } let(:request) { api("/projects/#{project.id}", user) } end @@ -1576,6 +1577,7 @@ describe API::Projects do end it_behaves_like '412 response' do + let(:success_status) { 202 } let(:request) { api("/projects/#{project.id}", admin) } end end diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb index 1bffd1e49db..7d7f66adeab 100644 --- a/spec/support/shared_examples/requests/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -43,11 +43,25 @@ end shared_examples_for '412 response' do let(:params) { nil } - before do - delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' } + let(:success_status) { 204 } + + context 'for a modified ressource' do + before do + delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' } + end + + it 'returns 412' do + expect(response).to have_gitlab_http_status(412) + end end - it 'returns 412' do - expect(response).to have_gitlab_http_status(412) + context 'for an unmodified ressource' do + before do + delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => Time.now } + end + + it 'returns accepted' do + expect(response).to have_gitlab_http_status(success_status) + end end end -- cgit v1.2.1 From 48d3e5fac63ab7514f05b14a8645c344ba3d5f2b Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:26:24 +0300 Subject: replace `is_edited?` with `edited?` --- .rubocop_todo.yml | 4 +++- app/controllers/projects/issues_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/issuables_helper.rb | 2 +- app/models/concerns/editable.rb | 2 +- spec/models/concerns/editable_spec.rb | 6 +++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4b4f14efea4..4141d221039 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -243,7 +243,9 @@ Style/PerlBackrefs: # NamePrefixBlacklist: is_, has_, have_ # NameWhitelist: is_a? Style/PredicateName: - Enabled: false + Enabled: true + # NamePrefix: is_ + NamePrefixBlacklist: is_ # Offense count: 58 # Cop supports --auto-correct. diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 8893a514207..1afaceac567 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -202,7 +202,7 @@ class Projects::IssuesController < Projects::ApplicationController task_status: @issue.task_status } - if @issue.is_edited? + if @issue.edited? response[:updated_at] = @issue.updated_at response[:updated_by_name] = @issue.last_edited_by.name response[:updated_by_path] = user_path(@issue.last_edited_by) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bcee81bdc15..07775a8b159 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -178,7 +178,7 @@ module ApplicationHelper end def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false) - return unless object.is_edited? + return unless object.edited? content_tag :small, class: 'edited-text' do output = content_tag(:span, 'Edited ') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 197c90c4081..2a748ce0a75 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -229,7 +229,7 @@ module IssuablesHelper end def updated_at_by(issuable) - return {} unless issuable.is_edited? + return {} unless issuable.edited? { updatedAt: issuable.updated_at.to_time.iso8601, diff --git a/app/models/concerns/editable.rb b/app/models/concerns/editable.rb index 28623d257a6..c0a3099f676 100644 --- a/app/models/concerns/editable.rb +++ b/app/models/concerns/editable.rb @@ -1,7 +1,7 @@ module Editable extend ActiveSupport::Concern - def is_edited? + def edited? last_edited_at.present? && last_edited_at != created_at end diff --git a/spec/models/concerns/editable_spec.rb b/spec/models/concerns/editable_spec.rb index cd73af3b480..49a9a8ebcbc 100644 --- a/spec/models/concerns/editable_spec.rb +++ b/spec/models/concerns/editable_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe Editable do - describe '#is_edited?' do + describe '#edited?' do let(:issue) { create(:issue, last_edited_at: nil) } let(:edited_issue) { create(:issue, created_at: 3.days.ago, last_edited_at: 2.days.ago) } - it { expect(issue.is_edited?).to eq(false) } - it { expect(edited_issue.is_edited?).to eq(true) } + it { expect(issue.edited?).to eq(false) } + it { expect(edited_issue.edited?).to eq(true) } end end -- cgit v1.2.1 From 5f72aaa303aabdb2258959e84b446074bf8a6915 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:31:20 +0300 Subject: replace `is_legacy_group_milestone?` with `legacy_group_milestone?` --- app/controllers/groups/milestones_controller.rb | 6 +++--- app/helpers/milestones_helper.rb | 2 +- app/models/concerns/milestoneish.rb | 2 +- app/models/group_milestone.rb | 2 +- app/views/groups/milestones/show.html.haml | 2 +- app/views/shared/milestones/_milestone.html.haml | 2 +- app/views/shared/milestones/_top.html.haml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index 5c10d7bc261..7a7bcb1a3d2 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -35,13 +35,13 @@ class Groups::MilestonesController < Groups::ApplicationController end def edit - render_404 if @milestone.is_legacy_group_milestone? + render_404 if @milestone.legacy_group_milestone? end def update # Keep this compatible with legacy group milestones where we have to update # all projects milestones states at once. - if @milestone.is_legacy_group_milestone? + if @milestone.legacy_group_milestone? update_params = milestone_params.select { |key| key == "state_event" } milestones = @milestone.milestones else @@ -67,7 +67,7 @@ class Groups::MilestonesController < Groups::ApplicationController end def milestone_path - if @milestone.is_legacy_group_milestone? + if @milestone.legacy_group_milestone? group_milestone_path(group, @milestone.safe_title, title: @milestone.title) else group_milestone_path(group, @milestone.iid) diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb index 86666022a2a..446a59030a6 100644 --- a/app/helpers/milestones_helper.rb +++ b/app/helpers/milestones_helper.rb @@ -164,7 +164,7 @@ module MilestonesHelper def group_milestone_route(milestone, params = {}) params = nil if params.empty? - if milestone.is_legacy_group_milestone? + if milestone.legacy_group_milestone? group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: params) else group_milestone_path(@group, milestone.iid, milestone: params) diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index f0998465822..dad92413950 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -78,7 +78,7 @@ module Milestoneish false end - def is_legacy_group_milestone? + def legacy_group_milestone? false end diff --git a/app/models/group_milestone.rb b/app/models/group_milestone.rb index 65249bd7bfc..98135ee3c8b 100644 --- a/app/models/group_milestone.rb +++ b/app/models/group_milestone.rb @@ -17,7 +17,7 @@ class GroupMilestone < GlobalMilestone { group_id: group.id } end - def is_legacy_group_milestone? + def legacy_group_milestone? true end end diff --git a/app/views/groups/milestones/show.html.haml b/app/views/groups/milestones/show.html.haml index 54b1b7a734a..23b1a22240f 100644 --- a/app/views/groups/milestones/show.html.haml +++ b/app/views/groups/milestones/show.html.haml @@ -1,4 +1,4 @@ = render "header_title" = render 'shared/milestones/top', milestone: @milestone, group: @group -= render 'shared/milestones/tabs', milestone: @milestone, show_project_name: true if @milestone.is_legacy_group_milestone? += render 'shared/milestones/tabs', milestone: @milestone, show_project_name: true if @milestone.legacy_group_milestone? = render 'shared/milestones/sidebar', milestone: @milestone, affix_offset: 102 diff --git a/app/views/shared/milestones/_milestone.html.haml b/app/views/shared/milestones/_milestone.html.haml index 6a85f7d0564..168c7f911d4 100644 --- a/app/views/shared/milestones/_milestone.html.haml +++ b/app/views/shared/milestones/_milestone.html.haml @@ -21,7 +21,7 @@ - if milestone.is_a?(GlobalMilestone) || milestone.is_group_milestone? .row .col-sm-6 - - if milestone.is_legacy_group_milestone? + - if milestone.legacy_group_milestone? .expiration= render('shared/milestone_expired', milestone: milestone) .projects - milestone.milestones.each do |milestone| diff --git a/app/views/shared/milestones/_top.html.haml b/app/views/shared/milestones/_top.html.haml index 3014300fbe7..2a7b8dbb12a 100644 --- a/app/views/shared/milestones/_top.html.haml +++ b/app/views/shared/milestones/_top.html.haml @@ -44,7 +44,7 @@ - close_msg = group ? 'You may close the milestone now.' : 'Navigate to the project to close the milestone.' %span All issues for this milestone are closed. #{close_msg} -- if @milestone.is_legacy_group_milestone? || @milestone.is_dashboard_milestone? +- if @milestone.legacy_group_milestone? || @milestone.is_dashboard_milestone? .table-holder %table.table %thead -- cgit v1.2.1 From 87467127b6e0927d56e532f4d6adc4091ff9ef6f Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:35:06 +0300 Subject: replace `is_ancestor?` with `ancestor?` --- app/models/deployment.rb | 2 +- app/models/repository.rb | 6 +++--- lib/gitlab/git/repository.rb | 2 +- spec/models/repository_spec.rb | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 056c49e7162..7bcded5b5e1 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -49,7 +49,7 @@ class Deployment < ActiveRecord::Base # created before then could have a `sha` referring to a commit that no # longer exists in the repository, so just ignore those. begin - project.repository.is_ancestor?(commit.id, sha) + project.repository.ancestor?(commit.id, sha) rescue Rugged::OdbError false end diff --git a/app/models/repository.rb b/app/models/repository.rb index 9fb2e2aa306..cb7aba89020 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -944,7 +944,7 @@ class Repository if branch_commit same_head = branch_commit.id == root_ref_commit.id - !same_head && is_ancestor?(branch_commit.id, root_ref_commit.id) + !same_head && ancestor?(branch_commit.id, root_ref_commit.id) else nil end @@ -958,12 +958,12 @@ class Repository nil end - def is_ancestor?(ancestor_id, descendant_id) + def ancestor?(ancestor_id, descendant_id) return false if ancestor_id.nil? || descendant_id.nil? Gitlab::GitalyClient.migrate(:is_ancestor) do |is_enabled| if is_enabled - raw_repository.is_ancestor?(ancestor_id, descendant_id) + raw_repository.ancestor?(ancestor_id, descendant_id) else rugged_is_ancestor?(ancestor_id, descendant_id) end diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index b835dec24eb..dce3a9b2d37 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -439,7 +439,7 @@ module Gitlab end # Returns true is +from+ is direct ancestor to +to+, otherwise false - def is_ancestor?(from, to) + def ancestor?(from, to) gitaly_commit_client.is_ancestor(from, to) end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 462e92b8b62..3151649b64e 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2036,23 +2036,23 @@ describe Repository, models: true do end end - describe '#is_ancestor?' do + describe '#ancestor?' do let(:commit) { repository.commit } let(:ancestor) { commit.parents.first } context 'with Gitaly enabled' do it 'it is an ancestor' do - expect(repository.is_ancestor?(ancestor.id, commit.id)).to eq(true) + expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true) end it 'it is not an ancestor' do - expect(repository.is_ancestor?(commit.id, ancestor.id)).to eq(false) + expect(repository.ancestor?(commit.id, ancestor.id)).to eq(false) end it 'returns false on nil-values' do - expect(repository.is_ancestor?(nil, commit.id)).to eq(false) - expect(repository.is_ancestor?(ancestor.id, nil)).to eq(false) - expect(repository.is_ancestor?(nil, nil)).to eq(false) + expect(repository.ancestor?(nil, commit.id)).to eq(false) + expect(repository.ancestor?(ancestor.id, nil)).to eq(false) + expect(repository.ancestor?(nil, nil)).to eq(false) end end @@ -2063,17 +2063,17 @@ describe Repository, models: true do end it 'it is an ancestor' do - expect(repository.is_ancestor?(ancestor.id, commit.id)).to eq(true) + expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true) end it 'it is not an ancestor' do - expect(repository.is_ancestor?(commit.id, ancestor.id)).to eq(false) + expect(repository.ancestor?(commit.id, ancestor.id)).to eq(false) end it 'returns false on nil-values' do - expect(repository.is_ancestor?(nil, commit.id)).to eq(false) - expect(repository.is_ancestor?(ancestor.id, nil)).to eq(false) - expect(repository.is_ancestor?(nil, nil)).to eq(false) + expect(repository.ancestor?(nil, commit.id)).to eq(false) + expect(repository.ancestor?(ancestor.id, nil)).to eq(false) + expect(repository.ancestor?(nil, nil)).to eq(false) end end end -- cgit v1.2.1 From ac3e5a58549c3f88659cedb47df68e5e719d68f1 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:37:37 +0300 Subject: replace `is_project_milestone?` with `project_milestone?` --- app/helpers/milestones_routing_helper.rb | 4 ++-- app/models/concerns/milestoneish.rb | 2 +- app/models/milestone.rb | 2 +- app/services/milestones/close_service.rb | 2 +- app/services/milestones/create_service.rb | 2 +- app/services/milestones/destroy_service.rb | 2 +- app/services/milestones/reopen_service.rb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/helpers/milestones_routing_helper.rb b/app/helpers/milestones_routing_helper.rb index 766d5262018..fa05b081634 100644 --- a/app/helpers/milestones_routing_helper.rb +++ b/app/helpers/milestones_routing_helper.rb @@ -2,7 +2,7 @@ module MilestonesRoutingHelper def milestone_path(milestone, *args) if milestone.is_group_milestone? group_milestone_path(milestone.group, milestone, *args) - elsif milestone.is_project_milestone? + elsif milestone.project_milestone? project_milestone_path(milestone.project, milestone, *args) end end @@ -10,7 +10,7 @@ module MilestonesRoutingHelper def milestone_url(milestone, *args) if milestone.is_group_milestone? group_milestone_url(milestone.group, milestone, *args) - elsif milestone.is_project_milestone? + elsif milestone.project_milestone? project_milestone_url(milestone.project, milestone, *args) end end diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index dad92413950..6c6ceaa35c7 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -74,7 +74,7 @@ module Milestoneish false end - def is_project_milestone? + def project_milestone? false end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 01e0d0155a3..dd1f3824a98 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -211,7 +211,7 @@ class Milestone < ActiveRecord::Base group_id.present? end - def is_project_milestone? + def project_milestone? project_id.present? end diff --git a/app/services/milestones/close_service.rb b/app/services/milestones/close_service.rb index 776ec4b287b..5b06c4b601d 100644 --- a/app/services/milestones/close_service.rb +++ b/app/services/milestones/close_service.rb @@ -1,7 +1,7 @@ module Milestones class CloseService < Milestones::BaseService def execute(milestone) - if milestone.close && milestone.is_project_milestone? + if milestone.close && milestone.project_milestone? event_service.close_milestone(milestone, current_user) end diff --git a/app/services/milestones/create_service.rb b/app/services/milestones/create_service.rb index aef3124c7e3..ed2e833d833 100644 --- a/app/services/milestones/create_service.rb +++ b/app/services/milestones/create_service.rb @@ -3,7 +3,7 @@ module Milestones def execute milestone = parent.milestones.new(params) - if milestone.save && milestone.is_project_milestone? + if milestone.save && milestone.project_milestone? event_service.open_milestone(milestone, current_user) end diff --git a/app/services/milestones/destroy_service.rb b/app/services/milestones/destroy_service.rb index 600ebcfbecb..b18651476a8 100644 --- a/app/services/milestones/destroy_service.rb +++ b/app/services/milestones/destroy_service.rb @@ -1,7 +1,7 @@ module Milestones class DestroyService < Milestones::BaseService def execute(milestone) - return unless milestone.is_project_milestone? + return unless milestone.project_milestone? Milestone.transaction do update_params = { milestone: nil } diff --git a/app/services/milestones/reopen_service.rb b/app/services/milestones/reopen_service.rb index 5b8b682caaf..3efb33157c5 100644 --- a/app/services/milestones/reopen_service.rb +++ b/app/services/milestones/reopen_service.rb @@ -1,7 +1,7 @@ module Milestones class ReopenService < Milestones::BaseService def execute(milestone) - if milestone.activate && milestone.is_project_milestone? + if milestone.activate && milestone.project_milestone? event_service.reopen_milestone(milestone, current_user) end -- cgit v1.2.1 From fab7fdcf2f8b040c345d1cb0b05acd053c9af963 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:41:44 +0300 Subject: replace `is_group_milestone?` with `group_milestone?` --- app/helpers/milestones_routing_helper.rb | 4 ++-- app/models/concerns/milestoneish.rb | 2 +- app/models/milestone.rb | 4 ++-- app/services/system_note_service.rb | 2 +- app/views/shared/milestones/_milestone.html.haml | 6 +++--- app/views/shared/milestones/_top.html.haml | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/milestones_routing_helper.rb b/app/helpers/milestones_routing_helper.rb index fa05b081634..a0b2616f224 100644 --- a/app/helpers/milestones_routing_helper.rb +++ b/app/helpers/milestones_routing_helper.rb @@ -1,6 +1,6 @@ module MilestonesRoutingHelper def milestone_path(milestone, *args) - if milestone.is_group_milestone? + if milestone.group_milestone? group_milestone_path(milestone.group, milestone, *args) elsif milestone.project_milestone? project_milestone_path(milestone.project, milestone, *args) @@ -8,7 +8,7 @@ module MilestonesRoutingHelper end def milestone_url(milestone, *args) - if milestone.is_group_milestone? + if milestone.group_milestone? group_milestone_url(milestone.group, milestone, *args) elsif milestone.project_milestone? project_milestone_url(milestone.project, milestone, *args) diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index 6c6ceaa35c7..c4b79d51fe7 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -70,7 +70,7 @@ module Milestoneish due_date && due_date.past? end - def is_group_milestone? + def group_milestone? false end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index dd1f3824a98..a3070a12b7c 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -163,7 +163,7 @@ class Milestone < ActiveRecord::Base # Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1" # def to_reference(from_project = nil, format: :iid, full: false) - return if is_group_milestone? && format != :name + return if group_milestone? && format != :name format_reference = milestone_format_reference(format) reference = "#{self.class.reference_prefix}#{format_reference}" @@ -207,7 +207,7 @@ class Milestone < ActiveRecord::Base group || project end - def is_group_milestone? + def group_milestone? group_id.present? end diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 1763f64a4e4..1f66a2668f9 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -142,7 +142,7 @@ module SystemNoteService # # Returns the created Note object def change_milestone(noteable, project, author, milestone) - format = milestone&.is_group_milestone? ? :name : :iid + format = milestone&.group_milestone? ? :name : :iid body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}" create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) diff --git a/app/views/shared/milestones/_milestone.html.haml b/app/views/shared/milestones/_milestone.html.haml index 168c7f911d4..305e2542281 100644 --- a/app/views/shared/milestones/_milestone.html.haml +++ b/app/views/shared/milestones/_milestone.html.haml @@ -5,7 +5,7 @@ .row .col-sm-6 %strong= link_to truncate(milestone.title, length: 100), milestone_path - - if milestone.is_group_milestone? + - if milestone.group_milestone? %span - Group Milestone - else %span - Project Milestone @@ -18,7 +18,7 @@ · = link_to pluralize(milestone.merge_requests.size, 'Merge Request'), merge_requests_path .col-sm-6= milestone_progress_bar(milestone) - - if milestone.is_a?(GlobalMilestone) || milestone.is_group_milestone? + - if milestone.is_a?(GlobalMilestone) || milestone.group_milestone? .row .col-sm-6 - if milestone.legacy_group_milestone? @@ -31,7 +31,7 @@ - if @group .col-sm-6.milestone-actions - if can?(current_user, :admin_milestones, @group) - - if milestone.is_group_milestone? + - if milestone.group_milestone? = link_to edit_group_milestone_path(@group, milestone), class: "btn btn-xs btn-grouped" do Edit \ diff --git a/app/views/shared/milestones/_top.html.haml b/app/views/shared/milestones/_top.html.haml index 2a7b8dbb12a..05b607db488 100644 --- a/app/views/shared/milestones/_top.html.haml +++ b/app/views/shared/milestones/_top.html.haml @@ -22,7 +22,7 @@ - if group .pull-right - if can?(current_user, :admin_milestones, group) - - if milestone.is_group_milestone? + - if milestone.group_milestone? = link_to edit_group_milestone_path(group, milestone), class: "btn btn btn-grouped" do Edit - if milestone.active? @@ -33,7 +33,7 @@ .detail-page-description.milestone-detail %h2.title = markdown_field(milestone, :title) - - if @milestone.is_group_milestone? && @milestone.description.present? + - if @milestone.group_milestone? && @milestone.description.present? %div .description .wiki @@ -67,7 +67,7 @@ Open %td = ms.expires_at -- elsif @milestone.is_group_milestone? +- elsif @milestone.group_milestone? %br View = link_to 'Issues', issues_group_path(@group, milestone_title: milestone.title) -- cgit v1.2.1 From bd406ca3503a032dc8e1ff0bd88a6657292b3fff Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:42:40 +0300 Subject: replace `is_overlap?` with `overlap?` --- app/models/network/graph.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 0e5acb22d50..3845e485413 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -152,14 +152,14 @@ module Network end def find_free_parent_space(range, space_base, space_step, space_default) - if is_overlap?(range, space_default) + if overlap?(range, space_default) find_free_space(range, space_step, space_base, space_default) else space_default end end - def is_overlap?(range, overlap_space) + def overlap?(range, overlap_space) range.each do |i| if i != range.first && i != range.last && -- cgit v1.2.1 From edb14511aa9d96c41fc2dc1f6f7b0be7779149fd Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:43:47 +0300 Subject: replace `is_update?` with `update?` --- app/models/project_services/chat_notification_service.rb | 6 +++--- app/models/project_services/hipchat_service.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb index 7b15a5dd04d..818cfb01b14 100644 --- a/app/models/project_services/chat_notification_service.rb +++ b/app/models/project_services/chat_notification_service.rb @@ -101,9 +101,9 @@ class ChatNotificationService < Service when "push", "tag_push" ChatMessage::PushMessage.new(data) when "issue" - ChatMessage::IssueMessage.new(data) unless is_update?(data) + ChatMessage::IssueMessage.new(data) unless update?(data) when "merge_request" - ChatMessage::MergeMessage.new(data) unless is_update?(data) + ChatMessage::MergeMessage.new(data) unless update?(data) when "note" ChatMessage::NoteMessage.new(data) when "pipeline" @@ -136,7 +136,7 @@ class ChatNotificationService < Service project.web_url end - def is_update?(data) + def update?(data) data[:object_attributes][:action] == 'update' end diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index f422e0ea036..976d85246a8 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -85,9 +85,9 @@ class HipchatService < Service when "push", "tag_push" create_push_message(data) when "issue" - create_issue_message(data) unless is_update?(data) + create_issue_message(data) unless update?(data) when "merge_request" - create_merge_request_message(data) unless is_update?(data) + create_merge_request_message(data) unless update?(data) when "note" create_note_message(data) when "pipeline" @@ -282,7 +282,7 @@ class HipchatService < Service "#{project_name}" end - def is_update?(data) + def update?(data) data[:object_attributes][:action] == 'update' end -- cgit v1.2.1 From 9226804bf32bcecd826818eb626714b52285c5e8 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:44:36 +0300 Subject: replace `is_runner_queue_value_latest?` with `runner_queue_value_latest?` --- app/models/ci/runner.rb | 2 +- lib/api/runner.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index c6d23898560..906a76ec560 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -142,7 +142,7 @@ module Ci expire: RUNNER_QUEUE_EXPIRY_TIME, overwrite: false) end - def is_runner_queue_value_latest?(value) + def runner_queue_value_latest?(value) ensure_runner_queue_value == value if value.present? end diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 88fc62d33df..1a7ded31c91 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -78,7 +78,7 @@ module API no_content! unless current_runner.active? update_runner_info - if current_runner.is_runner_queue_value_latest?(params[:last_update]) + if current_runner.runner_queue_value_latest?(params[:last_update]) header 'X-GitLab-Last-Update', params[:last_update] Gitlab::Metrics.add_event(:build_not_found_cached) return no_content! -- cgit v1.2.1 From 48389b4e5ec251441d1b1e135fdb28fe742289d8 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:46:42 +0300 Subject: replace `is_dashboard_milestone?` with `dashboard_milestone?` --- app/models/concerns/milestoneish.rb | 2 +- app/models/dashboard_milestone.rb | 2 +- app/views/shared/milestones/_top.html.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index c4b79d51fe7..710fc1ed647 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -82,7 +82,7 @@ module Milestoneish false end - def is_dashboard_milestone? + def dashboard_milestone? false end diff --git a/app/models/dashboard_milestone.rb b/app/models/dashboard_milestone.rb index fac7c5e5c85..86eb4ec76fc 100644 --- a/app/models/dashboard_milestone.rb +++ b/app/models/dashboard_milestone.rb @@ -3,7 +3,7 @@ class DashboardMilestone < GlobalMilestone { authorized_only: true } end - def is_dashboard_milestone? + def dashboard_milestone? true end end diff --git a/app/views/shared/milestones/_top.html.haml b/app/views/shared/milestones/_top.html.haml index 05b607db488..fd0760d83a5 100644 --- a/app/views/shared/milestones/_top.html.haml +++ b/app/views/shared/milestones/_top.html.haml @@ -44,7 +44,7 @@ - close_msg = group ? 'You may close the milestone now.' : 'Navigate to the project to close the milestone.' %span All issues for this milestone are closed. #{close_msg} -- if @milestone.legacy_group_milestone? || @milestone.is_dashboard_milestone? +- if @milestone.legacy_group_milestone? || @milestone.dashboard_milestone? .table-holder %table.table %thead -- cgit v1.2.1 From 6a56bec735c7434c85e3b8776b8413d3bdcb93ec Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 19:58:09 +0300 Subject: replace `is_gitlab_user?` with `gitlab_user?` --- lib/system_check/app/git_config_check.rb | 2 +- lib/tasks/gitlab/task_helpers.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/system_check/app/git_config_check.rb b/lib/system_check/app/git_config_check.rb index 198867f7ac6..d08a81639e3 100644 --- a/lib/system_check/app/git_config_check.rb +++ b/lib/system_check/app/git_config_check.rb @@ -20,7 +20,7 @@ module SystemCheck # Returns true if all subcommands were successful (according to their exit code) # Returns false if any or all subcommands failed. def repair! - return false unless is_gitlab_user? + return false unless gitlab_user? command_success = OPTIONS.map do |name, value| system(*%W(#{Gitlab.config.git.bin_path} config --global #{name} #{value})) diff --git a/lib/tasks/gitlab/task_helpers.rb b/lib/tasks/gitlab/task_helpers.rb index d85b810ac66..8a63f486fa3 100644 --- a/lib/tasks/gitlab/task_helpers.rb +++ b/lib/tasks/gitlab/task_helpers.rb @@ -104,7 +104,7 @@ module Gitlab Gitlab.config.gitlab.user end - def is_gitlab_user? + def gitlab_user? return @is_gitlab_user unless @is_gitlab_user.nil? current_user = run_command(%w(whoami)).chomp @@ -114,7 +114,7 @@ module Gitlab def warn_user_is_not_gitlab return if @warned_user_not_gitlab - unless is_gitlab_user? + unless gitlab_user? current_user = run_command(%w(whoami)).chomp puts " Warning ".color(:black).background(:yellow) -- cgit v1.2.1 From 78c5d4ddc2af74f352d4871689c7b8451b612b13 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:01:22 +0300 Subject: replace `is_multi_check?` with `multi_check?` --- lib/system_check/base_check.rb | 2 +- lib/system_check/simple_executor.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/system_check/base_check.rb b/lib/system_check/base_check.rb index 5dcb3f0886b..7f9e2ffffc2 100644 --- a/lib/system_check/base_check.rb +++ b/lib/system_check/base_check.rb @@ -73,7 +73,7 @@ module SystemCheck self.class.instance_methods(false).include?(:skip?) end - def is_multi_check? + def multi_check? self.class.instance_methods(false).include?(:multi_check) end diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb index e5986612908..6604b1078cf 100644 --- a/lib/system_check/simple_executor.rb +++ b/lib/system_check/simple_executor.rb @@ -53,7 +53,7 @@ module SystemCheck end # When implements a multi check, we don't control the output - if check.is_multi_check? + if check.multi_check? check.multi_check return end -- cgit v1.2.1 From 622c912d5b896380a0d0a1db61bbf9d1cb990c80 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:02:27 +0300 Subject: replace `is_successful?` with `successful?` --- lib/gitlab/health_checks/db_check.rb | 2 +- lib/gitlab/health_checks/redis/cache_check.rb | 2 +- lib/gitlab/health_checks/redis/queues_check.rb | 2 +- lib/gitlab/health_checks/redis/redis_check.rb | 2 +- lib/gitlab/health_checks/redis/shared_state_check.rb | 2 +- lib/gitlab/health_checks/simple_abstract_check.rb | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/gitlab/health_checks/db_check.rb b/lib/gitlab/health_checks/db_check.rb index fd94984f8a2..e27e16ddaf6 100644 --- a/lib/gitlab/health_checks/db_check.rb +++ b/lib/gitlab/health_checks/db_check.rb @@ -10,7 +10,7 @@ module Gitlab 'db_ping' end - def is_successful?(result) + def successful?(result) result == '1' end diff --git a/lib/gitlab/health_checks/redis/cache_check.rb b/lib/gitlab/health_checks/redis/cache_check.rb index a28658d42d4..0eb9b77634a 100644 --- a/lib/gitlab/health_checks/redis/cache_check.rb +++ b/lib/gitlab/health_checks/redis/cache_check.rb @@ -15,7 +15,7 @@ module Gitlab 'redis_cache_ping' end - def is_successful?(result) + def successful?(result) result == 'PONG' end diff --git a/lib/gitlab/health_checks/redis/queues_check.rb b/lib/gitlab/health_checks/redis/queues_check.rb index f97d50d3947..f322fe831b8 100644 --- a/lib/gitlab/health_checks/redis/queues_check.rb +++ b/lib/gitlab/health_checks/redis/queues_check.rb @@ -15,7 +15,7 @@ module Gitlab 'redis_queues_ping' end - def is_successful?(result) + def successful?(result) result == 'PONG' end diff --git a/lib/gitlab/health_checks/redis/redis_check.rb b/lib/gitlab/health_checks/redis/redis_check.rb index fe4e3c4a3ab..8ceb0a0aa46 100644 --- a/lib/gitlab/health_checks/redis/redis_check.rb +++ b/lib/gitlab/health_checks/redis/redis_check.rb @@ -11,7 +11,7 @@ module Gitlab 'redis_ping' end - def is_successful?(result) + def successful?(result) result == 'PONG' end diff --git a/lib/gitlab/health_checks/redis/shared_state_check.rb b/lib/gitlab/health_checks/redis/shared_state_check.rb index e3244392902..07e6f707998 100644 --- a/lib/gitlab/health_checks/redis/shared_state_check.rb +++ b/lib/gitlab/health_checks/redis/shared_state_check.rb @@ -15,7 +15,7 @@ module Gitlab 'redis_shared_state_ping' end - def is_successful?(result) + def successful?(result) result == 'PONG' end diff --git a/lib/gitlab/health_checks/simple_abstract_check.rb b/lib/gitlab/health_checks/simple_abstract_check.rb index f5026171ba4..96945ce5b20 100644 --- a/lib/gitlab/health_checks/simple_abstract_check.rb +++ b/lib/gitlab/health_checks/simple_abstract_check.rb @@ -5,7 +5,7 @@ module Gitlab def readiness check_result = check - if is_successful?(check_result) + if successful?(check_result) HealthChecks::Result.new(true) elsif check_result.is_a?(Timeout::Error) HealthChecks::Result.new(false, "#{human_name} check timed out") @@ -16,10 +16,10 @@ module Gitlab def metrics result, elapsed = with_timing(&method(:check)) - Rails.logger.error("#{human_name} check returned unexpected result #{result}") unless is_successful?(result) + Rails.logger.error("#{human_name} check returned unexpected result #{result}") unless successful?(result) [ metric("#{metric_prefix}_timeout", result.is_a?(Timeout::Error) ? 1 : 0), - metric("#{metric_prefix}_success", is_successful?(result) ? 1 : 0), + metric("#{metric_prefix}_success", successful?(result) ? 1 : 0), metric("#{metric_prefix}_latency_seconds", elapsed) ] end @@ -30,7 +30,7 @@ module Gitlab raise NotImplementedError end - def is_successful?(result) + def successful?(result) raise NotImplementedError end -- cgit v1.2.1 From 1c0def2a769befa3f0e3c8654e723645b8625117 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:03:50 +0300 Subject: replace `is_default_branch?` with `default_branch?` --- app/services/git_push_service.rb | 10 +++++----- spec/services/git_push_service_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index e81a56672e2..bb61136e33b 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -30,7 +30,7 @@ class GitPushService < BaseService @project.repository.after_create_branch # Re-find the pushed commits. - if is_default_branch? + if default_branch? # Initial push to the default branch. Take the full history of that branch as "newly pushed". process_default_branch else @@ -50,7 +50,7 @@ class GitPushService < BaseService # Update the bare repositories info/attributes file using the contents of the default branches # .gitattributes file - update_gitattributes if is_default_branch? + update_gitattributes if default_branch? end execute_related_hooks @@ -66,7 +66,7 @@ class GitPushService < BaseService end def update_caches - if is_default_branch? + if default_branch? if push_to_new_branch? # If this is the initial push into the default branch, the file type caches # will already be reset as a result of `Project#change_head`. @@ -108,7 +108,7 @@ class GitPushService < BaseService # Schedules processing of commit messages. def process_commit_messages - default = is_default_branch? + default = default_branch? @push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit| if commit.matches_cross_reference_regex? @@ -202,7 +202,7 @@ class GitPushService < BaseService Gitlab::Git.branch_ref?(params[:ref]) end - def is_default_branch? + def default_branch? Gitlab::Git.branch_ref?(params[:ref]) && (Gitlab::Git.ref_name(params[:ref]) == project.default_branch || project.default_branch.nil?) end diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index e3c1bdce300..cc3d4e7da49 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -617,7 +617,7 @@ describe GitPushService, services: true do context 'on the default branch' do before do - allow(service).to receive(:is_default_branch?).and_return(true) + allow(service).to receive(:default_branch?).and_return(true) end it 'flushes the caches of any special files that have been changed' do @@ -638,7 +638,7 @@ describe GitPushService, services: true do context 'on a non-default branch' do before do - allow(service).to receive(:is_default_branch?).and_return(false) + allow(service).to receive(:default_branch?).and_return(false) end it 'does not flush any conditional caches' do -- cgit v1.2.1 From fa030cbc85470edbff8e8c225a9fc7d6e52bfa9b Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:05:02 +0300 Subject: replace `is_spam?` with `spam?` --- app/services/akismet_service.rb | 2 +- app/services/spam_service.rb | 2 +- spec/controllers/projects/issues_controller_spec.rb | 8 ++++---- spec/controllers/projects/snippets_controller_spec.rb | 4 ++-- spec/controllers/snippets_controller_spec.rb | 4 ++-- spec/requests/api/issues_spec.rb | 4 ++-- spec/requests/api/project_snippets_spec.rb | 4 ++-- spec/requests/api/snippets_spec.rb | 4 ++-- spec/requests/api/v3/issues_spec.rb | 4 ++-- spec/requests/api/v3/project_snippets_spec.rb | 4 ++-- spec/requests/api/v3/snippets_spec.rb | 2 +- spec/services/issues/create_service_spec.rb | 4 ++-- spec/services/spam_service_spec.rb | 6 +++--- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/app/services/akismet_service.rb b/app/services/akismet_service.rb index 59153cbbc0a..7b5482b3cd1 100644 --- a/app/services/akismet_service.rb +++ b/app/services/akismet_service.rb @@ -7,7 +7,7 @@ class AkismetService @options = options end - def is_spam? + def spam? return false unless akismet_enabled? params = { diff --git a/app/services/spam_service.rb b/app/services/spam_service.rb index 3e65b7d31a3..73ea3018fbd 100644 --- a/app/services/spam_service.rb +++ b/app/services/spam_service.rb @@ -45,7 +45,7 @@ class SpamService def check(api) return false unless request && check_for_spam? - return false unless akismet.is_spam? + return false unless akismet.spam? create_spam_log(api) true diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index b571b11dcac..da8f9e8376e 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -268,7 +268,7 @@ describe Projects::IssuesController do context 'when an issue is not identified as spam' do before do allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false) - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false) end it 'normally updates the issue' do @@ -278,7 +278,7 @@ describe Projects::IssuesController do context 'when an issue is identified as spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when captcha is not verified' do @@ -672,7 +672,7 @@ describe Projects::IssuesController do context 'when an issue is not identified as spam' do before do allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false) - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false) end it 'does not create an issue' do @@ -682,7 +682,7 @@ describe Projects::IssuesController do context 'when an issue is identified as spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when captcha is not verified' do diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index cc444f31797..3a1550aa730 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -98,7 +98,7 @@ describe Projects::SnippetsController do context 'when the snippet is spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do @@ -176,7 +176,7 @@ describe Projects::SnippetsController do context 'when the snippet is spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 7c5d059760f..be273acb69b 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -217,7 +217,7 @@ describe SnippetsController do context 'when the snippet is spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do @@ -289,7 +289,7 @@ describe SnippetsController do context 'when the snippet is spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 7d120e4a234..47f781eab4d 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -984,7 +984,7 @@ describe API::Issues, :mailer do describe 'POST /projects/:id/issues with spam filtering' do before do allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true) - allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true) + allow_any_instance_of(AkismetService).to receive_messages(spam?: true) end let(:params) do @@ -1114,7 +1114,7 @@ describe API::Issues, :mailer do it "does not create a new project issue" do allow_any_instance_of(SpamService).to receive_messages(check_for_spam?: true) - allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true) + allow_any_instance_of(AkismetService).to receive_messages(spam?: true) put api("/projects/#{project.id}/issues/#{issue.iid}", user), params diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 2b541f5719e..b64d8b1bb63 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -117,7 +117,7 @@ describe API::ProjectSnippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do @@ -179,7 +179,7 @@ describe API::ProjectSnippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index d09b8bc42f1..68ab406770c 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -137,7 +137,7 @@ describe API::Snippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do @@ -209,7 +209,7 @@ describe API::Snippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 9eb538c4b09..9a0e6647ebf 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -884,7 +884,7 @@ describe API::V3::Issues, :mailer do describe 'POST /projects/:id/issues with spam filtering' do before do allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true) - allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true) + allow_any_instance_of(AkismetService).to receive_messages(spam?: true) end let(:params) do @@ -1016,7 +1016,7 @@ describe API::V3::Issues, :mailer do it "does not create a new project issue" do allow_any_instance_of(SpamService).to receive_messages(check_for_spam?: true) - allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true) + allow_any_instance_of(AkismetService).to receive_messages(spam?: true) put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), params diff --git a/spec/requests/api/v3/project_snippets_spec.rb b/spec/requests/api/v3/project_snippets_spec.rb index 3963924a066..7e88489082a 100644 --- a/spec/requests/api/v3/project_snippets_spec.rb +++ b/spec/requests/api/v3/project_snippets_spec.rb @@ -80,7 +80,7 @@ describe API::ProjectSnippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do @@ -140,7 +140,7 @@ describe API::ProjectSnippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/requests/api/v3/snippets_spec.rb b/spec/requests/api/v3/snippets_spec.rb index 9ead3cad8bb..79860725634 100644 --- a/spec/requests/api/v3/snippets_spec.rb +++ b/spec/requests/api/v3/snippets_spec.rb @@ -107,7 +107,7 @@ describe API::V3::Snippets do end before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end context 'when the snippet is private' do diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 78b11cd7991..cc3d648c340 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -370,7 +370,7 @@ describe Issues::CreateService do context 'when recaptcha was not verified' do context 'when akismet detects spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true) end it 'marks an issue as a spam ' do @@ -392,7 +392,7 @@ describe Issues::CreateService do context 'when akismet does not detect spam' do before do - allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false) + allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false) end it 'does not mark an issue as a spam ' do diff --git a/spec/services/spam_service_spec.rb b/spec/services/spam_service_spec.rb index a14dfa3f01f..61312d55b84 100644 --- a/spec/services/spam_service_spec.rb +++ b/spec/services/spam_service_spec.rb @@ -23,7 +23,7 @@ describe SpamService do before do issue.closed_at = Time.zone.now - allow(AkismetService).to receive(:new).and_return(double(is_spam?: true)) + allow(AkismetService).to receive(:new).and_return(double(spam?: true)) end it 'returns false' do @@ -43,7 +43,7 @@ describe SpamService do context 'when indicated as spam by akismet' do before do - allow(AkismetService).to receive(:new).and_return(double(is_spam?: true)) + allow(AkismetService).to receive(:new).and_return(double(spam?: true)) end it 'doesnt check as spam when request is missing' do @@ -71,7 +71,7 @@ describe SpamService do context 'when not indicated as spam by akismet' do before do - allow(AkismetService).to receive(:new).and_return(double(is_spam?: false)) + allow(AkismetService).to receive(:new).and_return(double(spam?: false)) end it 'returns false' do -- cgit v1.2.1 From eb0a17ba4bf05b7bcefb31755381d08fd689b818 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:06:04 +0300 Subject: replace `is_team_member?` with `team_member?` --- app/policies/project_policy.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 0133091db57..a925fac7d3e 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -17,13 +17,13 @@ class ProjectPolicy < BasePolicy desc "Project has public builds enabled" condition(:public_builds, scope: :subject) { project.public_builds? } - # For guest access we use #is_team_member? so we can use + # For guest access we use #team_member? so we can use # project.members, which gets cached in subject scope. # This is safe because team_access_level is guaranteed # by ProjectAuthorization's validation to be at minimum # GUEST desc "User has guest access" - condition(:guest) { is_team_member? } + condition(:guest) { team_member? } desc "User has reporter access" condition(:reporter) { team_access_level >= Gitlab::Access::REPORTER } @@ -293,7 +293,7 @@ class ProjectPolicy < BasePolicy private - def is_team_member? + def team_member? return false if @user.nil? greedy_load_subject = false -- cgit v1.2.1 From e6c7c11a5bb2656c2be997368b62aca61bb1f485 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:16:31 +0300 Subject: replace `has_matching_label` with `has_matching_label?` --- .rubocop_todo.yml | 3 +++ lib/gitlab/prometheus/queries/matched_metrics_query.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4141d221039..f51228180c8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -244,8 +244,11 @@ Style/PerlBackrefs: # NameWhitelist: is_a? Style/PredicateName: Enabled: true + Exclude: + - 'features/*' # NamePrefix: is_ NamePrefixBlacklist: is_ + NameWhitelist: has_n_stars # Offense count: 58 # Cop supports --auto-correct. diff --git a/lib/gitlab/prometheus/queries/matched_metrics_query.rb b/lib/gitlab/prometheus/queries/matched_metrics_query.rb index d4894c87f8d..4c3edccc71a 100644 --- a/lib/gitlab/prometheus/queries/matched_metrics_query.rb +++ b/lib/gitlab/prometheus/queries/matched_metrics_query.rb @@ -42,13 +42,13 @@ module Gitlab lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map do |batched_series| client_series(*batched_series, start: timeframe_start, stop: timeframe_end) - .select(&method(:has_matching_label)) + .select(&method(:has_matching_label?)) .map { |series_info| [series_info['__name__'], true] } end lookup.to_h end - def has_matching_label(series_info) + def has_matching_label?(series_info) series_info.key?('environment') end -- cgit v1.2.1 From 81061aef62e603aa122c5c3a58ca8cfd9341a59b Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:17:21 +0300 Subject: replace `has_n_stars` with `has_n_stars?` --- features/steps/project/star.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/steps/project/star.rb b/features/steps/project/star.rb index 9f7c748a3b7..2e7eb65901a 100644 --- a/features/steps/project/star.rb +++ b/features/steps/project/star.rb @@ -9,15 +9,15 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps end step "The project has 0 stars" do - has_n_stars(0) + has_n_stars?(0) end step "The project has 1 star" do - has_n_stars(1) + has_n_stars?(1) end step "The project has 2 stars" do - has_n_stars(2) + has_n_stars?(2) end # Requires @javascript @@ -31,7 +31,7 @@ class Spinach::Features::ProjectStar < Spinach::FeatureSteps protected - def has_n_stars(n) + def has_n_stars?(n) expect(page).to have_css(".star-count", text: n, visible: true) end end -- cgit v1.2.1 From 90112f57d26a21a6c219e24367b7ef91d93858ad Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:46:41 +0300 Subject: replace `is_member_of` with `member_of?` --- .rubocop_todo.yml | 6 +++--- features/steps/shared/group.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f51228180c8..9186501ca96 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -244,11 +244,11 @@ Style/PerlBackrefs: # NameWhitelist: is_a? Style/PredicateName: Enabled: true - Exclude: - - 'features/*' + # Exclude: + # - 'features/*' # NamePrefix: is_ NamePrefixBlacklist: is_ - NameWhitelist: has_n_stars + NameWhitelist: have_visible_content # Offense count: 58 # Cop supports --auto-correct. diff --git a/features/steps/shared/group.rb b/features/steps/shared/group.rb index de119f2c6c0..45fad83e8bb 100644 --- a/features/steps/shared/group.rb +++ b/features/steps/shared/group.rb @@ -2,27 +2,27 @@ module SharedGroup include Spinach::DSL step 'current user is developer of group "Owned"' do - is_member_of(current_user.name, "Owned", Gitlab::Access::DEVELOPER) + member_of?(current_user.name, "Owned", Gitlab::Access::DEVELOPER) end step '"John Doe" is owner of group "Owned"' do - is_member_of("John Doe", "Owned", Gitlab::Access::OWNER) + member_of?("John Doe", "Owned", Gitlab::Access::OWNER) end step '"John Doe" is guest of group "Guest"' do - is_member_of("John Doe", "Guest", Gitlab::Access::GUEST) + member_of?("John Doe", "Guest", Gitlab::Access::GUEST) end step '"Mary Jane" is owner of group "Owned"' do - is_member_of("Mary Jane", "Owned", Gitlab::Access::OWNER) + member_of?("Mary Jane", "Owned", Gitlab::Access::OWNER) end step '"Mary Jane" is guest of group "Owned"' do - is_member_of("Mary Jane", "Owned", Gitlab::Access::GUEST) + member_of?("Mary Jane", "Owned", Gitlab::Access::GUEST) end step '"Mary Jane" is guest of group "Guest"' do - is_member_of("Mary Jane", "Guest", Gitlab::Access::GUEST) + member_of?("Mary Jane", "Guest", Gitlab::Access::GUEST) end step 'I should see group "TestGroup"' do @@ -35,7 +35,7 @@ module SharedGroup protected - def is_member_of(username, groupname, role) + def member_of?(username, groupname, role) @project_count ||= 0 user = User.find_by(name: username) || create(:user, name: username) group = Group.find_by(name: groupname) || create(:group, name: groupname) -- cgit v1.2.1 From 10ae0d8316bd9ae5aa1ce46fcea3ec8f01a3b336 Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 20:52:43 +0300 Subject: replace `is_ancestor` with `ancestor?` --- lib/gitlab/checks/force_push.rb | 2 +- lib/gitlab/git/repository.rb | 2 +- lib/gitlab/gitaly_client/commit_service.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/checks/force_push.rb b/lib/gitlab/checks/force_push.rb index 714464fd5e7..dc5d285ea65 100644 --- a/lib/gitlab/checks/force_push.rb +++ b/lib/gitlab/checks/force_push.rb @@ -12,7 +12,7 @@ module Gitlab !project .repository .gitaly_commit_client - .is_ancestor(oldrev, newrev) + .ancestor?(oldrev, newrev) else Gitlab::Git::RevList.new( path_to_repo: project.repository.path_to_repo, diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index dce3a9b2d37..03e2bec84dd 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -440,7 +440,7 @@ module Gitlab # Returns true is +from+ is direct ancestor to +to+, otherwise false def ancestor?(from, to) - gitaly_commit_client.is_ancestor(from, to) + gitaly_commit_client.ancestor?(from, to) end # Return an array of Diff objects that represent the diff diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 57f42bd35ee..21a32a7e0db 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -22,7 +22,7 @@ module Gitlab end end - def is_ancestor(ancestor_id, child_id) + def ancestor?(ancestor_id, child_id) request = Gitaly::CommitIsAncestorRequest.new( repository: @gitaly_repo, ancestor_id: ancestor_id, -- cgit v1.2.1 From e637f802431bc3d9b289299c1d5d4d2a6127cf6b Mon Sep 17 00:00:00 2001 From: Maxim Rydkin Date: Thu, 24 Aug 2017 21:02:37 +0300 Subject: add changelog --- .rubocop_todo.yml | 3 --- changelogs/unreleased/35793_fix_predicate_names.yml | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/35793_fix_predicate_names.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9186501ca96..9e6412a436d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -244,9 +244,6 @@ Style/PerlBackrefs: # NameWhitelist: is_a? Style/PredicateName: Enabled: true - # Exclude: - # - 'features/*' - # NamePrefix: is_ NamePrefixBlacklist: is_ NameWhitelist: have_visible_content diff --git a/changelogs/unreleased/35793_fix_predicate_names.yml b/changelogs/unreleased/35793_fix_predicate_names.yml new file mode 100644 index 00000000000..d4da177dc2e --- /dev/null +++ b/changelogs/unreleased/35793_fix_predicate_names.yml @@ -0,0 +1,5 @@ +--- +title: Remove `is_` prefix from predicate method names +merge_request: 13810 +author: Maxim Rydkin +type: other -- cgit v1.2.1 From 596fe67a0370f985ee08b3c8ef01fee6e4aaf045 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Tue, 29 Aug 2017 08:29:11 +0000 Subject: Resolve "Monitoring graph date formatting is wrong" --- .../monitoring/components/monitoring_column.vue | 2 ++ .../monitoring/components/monitoring_deployment.vue | 9 +++------ .../javascripts/monitoring/components/monitoring_flag.vue | 7 ++----- app/assets/javascripts/monitoring/constants.js | 4 ---- .../javascripts/monitoring/utils/date_time_formatters.js | 15 +++++++++++++++ changelogs/unreleased/37104-fix-graph-date-format.yml | 5 +++++ 6 files changed, 27 insertions(+), 15 deletions(-) delete mode 100644 app/assets/javascripts/monitoring/constants.js create mode 100644 app/assets/javascripts/monitoring/utils/date_time_formatters.js create mode 100644 changelogs/unreleased/37104-fix-graph-date-format.yml diff --git a/app/assets/javascripts/monitoring/components/monitoring_column.vue b/app/assets/javascripts/monitoring/components/monitoring_column.vue index 407af51cb7a..c0abb436e43 100644 --- a/app/assets/javascripts/monitoring/components/monitoring_column.vue +++ b/app/assets/javascripts/monitoring/components/monitoring_column.vue @@ -7,6 +7,7 @@ import eventHub from '../event_hub'; import measurements from '../utils/measurements'; import { formatRelevantDigits } from '../../lib/utils/number_utils'; + import { timeScaleFormat } from '../utils/date_time_formatters'; import bp from '../../breakpoints'; const bisectDate = d3.bisector(d => d.time).left; @@ -159,6 +160,7 @@ const xAxis = d3.svg.axis() .scale(axisXScale) .ticks(measurements.xTicks) + .tickFormat(timeScaleFormat) .orient('bottom'); const yAxis = d3.svg.axis() diff --git a/app/assets/javascripts/monitoring/components/monitoring_deployment.vue b/app/assets/javascripts/monitoring/components/monitoring_deployment.vue index e6432ba3191..dadbcd1aaa6 100644 --- a/app/assets/javascripts/monitoring/components/monitoring_deployment.vue +++ b/app/assets/javascripts/monitoring/components/monitoring_deployment.vue @@ -1,8 +1,5 @@