summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml103
-rw-r--r--CHANGELOG.md25
-rw-r--r--app/assets/javascripts/boards/services/board_service.js2
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js18
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_manager.js3
-rw-r--r--app/assets/javascripts/ide/components/resizable_panel.vue109
-rw-r--r--app/assets/javascripts/jobs/components/sidebar_details_block.vue2
-rw-r--r--app/assets/javascripts/milestone_select.js8
-rw-r--r--app/assets/javascripts/pages/groups/issues/index.js1
-rw-r--r--app/assets/javascripts/pages/groups/merge_requests/index.js1
-rw-r--r--app/controllers/projects/labels_controller.rb3
-rw-r--r--app/controllers/projects/lfs_api_controller.rb2
-rw-r--r--app/finders/labels_finder.rb35
-rw-r--r--app/helpers/boards_helper.rb6
-rw-r--r--app/helpers/labels_helper.rb10
-rw-r--r--app/helpers/services_helper.rb25
-rw-r--r--app/helpers/tree_helper.rb2
-rw-r--r--app/models/ci/build.rb1
-rw-r--r--app/models/commit.rb3
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/hooks/project_hook.rb1
-rw-r--r--app/models/note.rb4
-rw-r--r--app/models/project.rb10
-rw-r--r--app/models/project_services/chat_notification_service.rb14
-rw-r--r--app/models/project_services/hipchat_service.rb2
-rw-r--r--app/models/service.rb8
-rw-r--r--app/serializers/build_metadata_entity.rb5
-rw-r--r--app/services/boards/issues/move_service.rb5
-rw-r--r--app/services/boards/lists/create_service.rb8
-rw-r--r--app/services/issuable_base_service.rb2
-rw-r--r--app/services/issues/update_service.rb17
-rw-r--r--app/services/notes/post_process_service.rb6
-rw-r--r--app/services/projects/autocomplete_service.rb3
-rw-r--r--app/services/projects/import_export/export_service.rb6
-rw-r--r--app/services/quick_actions/interpret_service.rb5
-rw-r--r--app/views/admin/application_settings/_email.html.haml26
-rw-r--r--app/views/admin/application_settings/_form.html.haml173
-rw-r--r--app/views/admin/application_settings/_gitaly.html.haml27
-rw-r--r--app/views/admin/application_settings/_koding.html.haml24
-rw-r--r--app/views/admin/application_settings/_performance.html.haml19
-rw-r--r--app/views/admin/application_settings/_plantuml.html.haml20
-rw-r--r--app/views/admin/application_settings/_realtime.html.haml19
-rw-r--r--app/views/admin/application_settings/_registry.html.haml10
-rw-r--r--app/views/admin/application_settings/_terminal.html.haml13
-rw-r--r--app/views/admin/application_settings/_usage.html.haml37
-rw-r--r--app/views/admin/application_settings/show.html.haml108
-rw-r--r--app/views/email_rejection_mailer/rejection.text.haml3
-rw-r--r--app/views/projects/_export.html.haml2
-rw-r--r--app/views/projects/commit/_commit_box.html.haml4
-rw-r--r--app/views/projects/commits/_commit.atom.builder2
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml2
-rw-r--r--app/views/shared/web_hooks/_form.html.haml7
-rw-r--r--changelogs/unreleased/42028-xss-diffs.yml5
-rw-r--r--changelogs/unreleased/bvl-export-import-lfs.yml5
-rw-r--r--changelogs/unreleased/dm-flatten-tree-plus-chars.yml5
-rw-r--r--changelogs/unreleased/feature_detect_co_authored_commits.yml6
-rw-r--r--changelogs/unreleased/issue_40915.yml5
-rw-r--r--changelogs/unreleased/issue_44551.yml5
-rw-r--r--changelogs/unreleased/jej-mattermost-notification-confidentiality.yml5
-rw-r--r--changelogs/unreleased/osw-41401-render-mr-commit-sha-instead-diffs.yml5
-rw-r--r--changelogs/unreleased/sh-gitlab-sidekiq-logger.yml5
-rw-r--r--changelogs/unreleased/zj-feature-gate-remove-http-api.yml5
-rw-r--r--changelogs/unreleased/zj-opt-out-delete-refs.yml5
-rw-r--r--changelogs/unreleased/zj-opt-out-list-commits-by-oid.yml5
-rw-r--r--config/gitlab.yml.example4
-rw-r--r--config/initializers/1_settings.rb6
-rw-r--r--config/initializers/sidekiq.rb9
-rw-r--r--db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb15
-rw-r--r--db/migrate/20180103123548_add_confidential_note_events_to_services.rb16
-rw-r--r--db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb23
-rw-r--r--db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb23
-rw-r--r--db/schema.rb2
-rw-r--r--doc/administration/index.md1
-rw-r--r--doc/administration/logs.md22
-rw-r--r--doc/api/features.md8
-rw-r--r--doc/ci/examples/laravel_with_gitlab_and_envoy/index.md2
-rw-r--r--doc/user/admin_area/settings/email.md5
-rw-r--r--doc/user/project/labels.md6
-rw-r--r--doc/user/project/settings/import_export.md2
-rw-r--r--lib/api/entities.rb4
-rw-r--r--lib/api/features.rb7
-rw-r--r--lib/api/helpers.rb13
-rw-r--r--lib/api/project_hooks.rb1
-rw-r--r--lib/banzai/filter/abstract_reference_filter.rb4
-rw-r--r--lib/banzai/filter/commit_range_reference_filter.rb2
-rw-r--r--lib/banzai/filter/commit_trailers_filter.rb152
-rw-r--r--lib/banzai/filter/label_reference_filter.rb4
-rw-r--r--lib/banzai/filter/merge_request_reference_filter.rb39
-rw-r--r--lib/banzai/filter/milestone_reference_filter.rb2
-rw-r--r--lib/banzai/pipeline/commit_description_pipeline.rb11
-rw-r--r--lib/gitlab/background_migration/set_confidential_note_events_on_services.rb26
-rw-r--r--lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb26
-rw-r--r--lib/gitlab/checks/lfs_integrity.rb3
-rw-r--r--lib/gitlab/data_builder/note.rb4
-rw-r--r--lib/gitlab/database/migration_helpers.rb2
-rw-r--r--lib/gitlab/diff/inline_diff_marker.rb7
-rw-r--r--lib/gitlab/git/commit.rb3
-rw-r--r--lib/gitlab/git/hook.rb4
-rw-r--r--lib/gitlab/git/repository.rb3
-rw-r--r--lib/gitlab/hook_data/issuable_builder.rb15
-rw-r--r--lib/gitlab/import_export/importer.rb11
-rw-r--r--lib/gitlab/import_export/lfs_restorer.rb43
-rw-r--r--lib/gitlab/import_export/lfs_saver.rb55
-rw-r--r--lib/gitlab/sidekiq_logging/json_formatter.rb21
-rw-r--r--lib/gitlab/sidekiq_logging/structured_logger.rb96
-rw-r--r--lib/gitlab/utils.rb5
-rw-r--r--locale/gitlab.pot192
-rw-r--r--spec/factories/ci/build_metadata.rb9
-rw-r--r--spec/factories/project_hooks.rb1
-rw-r--r--spec/features/admin/admin_settings_spec.rb24
-rw-r--r--spec/features/issues/filtered_search/filter_issues_spec.rb9
-rw-r--r--spec/features/issues/form_spec.rb17
-rw-r--r--spec/features/labels_hierarchy_spec.rb305
-rw-r--r--spec/features/projects/issues/user_sorts_issues_spec.rb3
-rw-r--r--spec/finders/labels_finder_spec.rb34
-rw-r--r--spec/fixtures/exported-project.gzbin0 -> 2306 bytes
-rw-r--r--spec/helpers/diff_helper_spec.rb30
-rw-r--r--spec/helpers/tree_helper_spec.rb10
-rw-r--r--spec/lib/banzai/filter/commit_trailers_filter_spec.rb171
-rw-r--r--spec/lib/banzai/filter/merge_request_reference_filter_spec.rb35
-rw-r--r--spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb31
-rw-r--r--spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb31
-rw-r--r--spec/lib/gitlab/data_builder/note_spec.rb8
-rw-r--r--spec/lib/gitlab/import_export/importer_spec.rb64
-rw-r--r--spec/lib/gitlab/import_export/lfs_restorer_spec.rb75
-rw-r--r--spec/lib/gitlab/import_export/lfs_saver_spec.rb62
-rw-r--r--spec/lib/gitlab/import_export/safe_model_attributes.yml2
-rw-r--r--spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb31
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb101
-rw-r--r--spec/mailers/previews/email_rejection_mailer_preview.rb5
-rw-r--r--spec/mailers/previews/notify_preview.rb83
-rw-r--r--spec/mailers/previews/repository_check_mailer_preview.rb5
-rw-r--r--spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb44
-rw-r--r--spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb20
-rw-r--r--spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb44
-rw-r--r--spec/models/ci/build_metadata_spec.rb2
-rw-r--r--spec/models/commit_status_spec.rb4
-rw-r--r--spec/models/note_spec.rb15
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb15
-rw-r--r--spec/models/project_spec.rb16
-rw-r--r--spec/models/service_spec.rb16
-rw-r--r--spec/requests/api/boards_spec.rb31
-rw-r--r--spec/requests/api/features_spec.rb43
-rw-r--r--spec/requests/api/project_hooks_spec.rb4
-rw-r--r--spec/services/boards/issues/move_service_spec.rb2
-rw-r--r--spec/services/issues/update_service_spec.rb31
-rw-r--r--spec/services/notes/post_process_service_spec.rb18
-rw-r--r--spec/services/projects/import_export/export_service_spec.rb43
-rw-r--r--spec/support/commit_trailers_spec_helper.rb41
-rw-r--r--spec/support/filtered_search_helpers.rb23
-rw-r--r--spec/support/shared_examples/services/boards/issues_move_service.rb15
-rw-r--r--spec/support/slack_mattermost_notifications_shared_examples.rb62
152 files changed, 3146 insertions, 402 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 86bdb7a4643..433487877c0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -78,6 +78,19 @@ stages:
- mysql:latest
- redis:alpine
+.rails5-variables: &rails5-variables
+ script:
+ - export RAILS5=${RAILS5}
+ - export BUNDLE_GEMFILE=${BUNDLE_GEMFILE}
+
+.rails5: &rails5
+ allow_failure: true
+ only:
+ - /rails5/
+ variables:
+ BUNDLE_GEMFILE: "Gemfile.rails5"
+ RAILS5: "true"
+
# 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
@@ -118,6 +131,7 @@ stages:
<<: *dedicated-runner
<<: *except-docs-and-qa
<<: *pull-cache
+ <<: *rails5-variables
stage: test
script:
- JOB_NAME=( $CI_JOB_NAME )
@@ -148,14 +162,23 @@ stages:
<<: *rspec-metadata
<<: *use-pg
+.rspec-metadata-pg-rails5: &rspec-metadata-pg-rails5
+ <<: *rspec-metadata-pg
+ <<: *rails5
+
.rspec-metadata-mysql: &rspec-metadata-mysql
<<: *rspec-metadata
<<: *use-mysql
+.rspec-metadata-mysql-rails5: &rspec-metadata-mysql-rails5
+ <<: *rspec-metadata-mysql
+ <<: *rails5
+
.spinach-metadata: &spinach-metadata
<<: *dedicated-runner
<<: *except-docs-and-qa
<<: *pull-cache
+ <<: *rails5-variables
stage: test
script:
- JOB_NAME=( $CI_JOB_NAME )
@@ -179,10 +202,18 @@ stages:
<<: *spinach-metadata
<<: *use-pg
+.spinach-metadata-pg-rails5: &spinach-metadata-pg-rails5
+ <<: *spinach-metadata-pg
+ <<: *rails5
+
.spinach-metadata-mysql: &spinach-metadata-mysql
<<: *spinach-metadata
<<: *use-mysql
+.spinach-metadata-mysql-rails5: &spinach-metadata-mysql-rails5
+ <<: *spinach-metadata-mysql
+ <<: *rails5
+
.only-canonical-masters: &only-canonical-masters
only:
- master@gitlab-org/gitlab-ce
@@ -468,6 +499,70 @@ spinach-pg 1 2: *spinach-metadata-pg
spinach-mysql 0 2: *spinach-metadata-mysql
spinach-mysql 1 2: *spinach-metadata-mysql
+rspec-pg-rails5 0 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 1 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 2 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 3 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 4 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 5 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 6 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 7 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 8 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 9 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 10 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 11 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 12 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 13 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 14 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 15 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 16 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 17 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 18 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 19 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 20 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 21 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 22 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 23 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 24 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 25 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 26 28: *rspec-metadata-pg-rails5
+rspec-pg-rails5 27 28: *rspec-metadata-pg-rails5
+
+rspec-mysql-rails5 0 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 1 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 2 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 3 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 4 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 5 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 6 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 7 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 8 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 9 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 10 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 11 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 12 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 13 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 14 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 15 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 16 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 17 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 18 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 19 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 20 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 21 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 22 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 23 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 24 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 25 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 26 28: *rspec-metadata-mysql-rails5
+rspec-mysql-rails5 27 28: *rspec-metadata-mysql-rails5
+
+spinach-pg-rails5 0 2: *spinach-metadata-pg-rails5
+spinach-pg-rails5 1 2: *spinach-metadata-pg-rails5
+
+spinach-mysql-rails5 0 2: *spinach-metadata-mysql-rails5
+spinach-mysql-rails5 1 2: *spinach-metadata-mysql-rails5
+
static-analysis:
<<: *dedicated-no-docs-no-db-pull-cache-job
dependencies:
@@ -670,7 +765,13 @@ qa:selectors:
- bundle exec bin/qa Test::Sanity::Selectors
coverage:
- <<: *dedicated-no-docs-no-db-pull-cache-job
+ # Don't include dedicated-no-docs-no-db-pull-cache-job here since we need to
+ # download artifacts from all the rspec jobs instead of from setup-test-env only
+ <<: *dedicated-runner
+ <<: *except-docs-and-qa
+ <<: *pull-cache
+ variables:
+ SETUP_DB: "false"
stage: post-test
script:
- bundle exec scripts/merge-simplecov
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a90a7fcdc2..9109f04fb17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
documentation](doc/development/changelog.md) for instructions on adding your own
entry.
+## 10.6.3 (2018-04-03)
+
+### Security (2 changes)
+
+- Fix XSS on diff view stored on filenames.
+- Adds confidential notes channel for Slack/Mattermost.
+
+
## 10.6.2 (2018-03-29)
### Fixed (2 changes, 1 of them is from the community)
@@ -191,7 +199,6 @@ entry.
- Enable privileged mode for GitLab Runner. !17528
- Expose GITLAB_FEATURES as CI/CD variable (fixes #40994).
- Upgrade GitLab Workhorse to 4.0.0.
-- Allow CI/CD Jobs being grouped on version strings.
- Add discussions API for Issues and Snippets.
- Add one group board to Libre.
- Add support for filtering by source and target branch to merge requests API.
@@ -218,6 +225,14 @@ entry.
- Use host URL to build JIRA remote link icon.
+## 10.5.7 (2018-04-03)
+
+### Security (2 changes)
+
+- Fix XSS on diff view stored on filenames.
+- Adds confidential notes channel for Slack/Mattermost.
+
+
## 10.5.6 (2018-03-16)
### Security (2 changes)
@@ -485,6 +500,14 @@ entry.
- Adds empty state illustration for pending job.
+## 10.4.7 (2018-04-03)
+
+### Security (2 changes)
+
+- Fix XSS on diff view stored on filenames.
+- Adds confidential notes channel for Slack/Mattermost.
+
+
## 10.4.6 (2018-03-16)
### Security (2 changes)
diff --git a/app/assets/javascripts/boards/services/board_service.js b/app/assets/javascripts/boards/services/board_service.js
index d78d4701974..7c90597f77c 100644
--- a/app/assets/javascripts/boards/services/board_service.js
+++ b/app/assets/javascripts/boards/services/board_service.js
@@ -19,7 +19,7 @@ export default class BoardService {
}
static generateIssuePath(boardId, id) {
- return `${gon.relative_url_root}/-/boards/${boardId ? `/${boardId}` : ''}/issues${id ? `/${id}` : ''}`;
+ return `${gon.relative_url_root}/-/boards/${boardId ? `${boardId}` : ''}/issues${id ? `/${id}` : ''}`;
}
all() {
diff --git a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
index e6390f0855b..d7e1de18d09 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
+++ b/app/assets/javascripts/filtered_search/filtered_search_dropdown_manager.js
@@ -26,8 +26,8 @@ export default class FilteredSearchDropdownManager {
this.filteredSearchInput = this.container.querySelector('.filtered-search');
this.page = page;
this.groupsOnly = isGroup;
- this.groupAncestor = isGroupAncestor;
- this.isGroupDecendent = isGroupDecendent;
+ this.includeAncestorGroups = isGroupAncestor;
+ this.includeDescendantGroups = isGroupDecendent;
this.setupMapping();
@@ -108,7 +108,19 @@ export default class FilteredSearchDropdownManager {
}
getLabelsEndpoint() {
- const endpoint = `${this.baseEndpoint}/labels.json`;
+ let endpoint = `${this.baseEndpoint}/labels.json?`;
+
+ if (this.groupsOnly) {
+ endpoint = `${endpoint}only_group_labels=true&`;
+ }
+
+ if (this.includeAncestorGroups) {
+ endpoint = `${endpoint}include_ancestor_groups=true&`;
+ }
+
+ if (this.includeDescendantGroups) {
+ endpoint = `${endpoint}include_descendant_groups=true`;
+ }
return endpoint;
}
diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js b/app/assets/javascripts/filtered_search/filtered_search_manager.js
index 71b7e80335b..cf5ba1e1771 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_manager.js
+++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js
@@ -21,7 +21,7 @@ export default class FilteredSearchManager {
constructor({
page,
isGroup = false,
- isGroupAncestor = false,
+ isGroupAncestor = true,
isGroupDecendent = false,
filteredSearchTokenKeys = FilteredSearchTokenKeys,
stateFiltersSelector = '.issues-state-filters',
@@ -86,6 +86,7 @@ export default class FilteredSearchManager {
page: this.page,
isGroup: this.isGroup,
isGroupAncestor: this.isGroupAncestor,
+ isGroupDecendent: this.isGroupDecendent,
filteredSearchTokenKeys: this.filteredSearchTokenKeys,
});
diff --git a/app/assets/javascripts/ide/components/resizable_panel.vue b/app/assets/javascripts/ide/components/resizable_panel.vue
index faa690ecba0..5ea2a2f6825 100644
--- a/app/assets/javascripts/ide/components/resizable_panel.vue
+++ b/app/assets/javascripts/ide/components/resizable_panel.vue
@@ -1,67 +1,64 @@
<script>
- import { mapActions, mapState } from 'vuex';
- import PanelResizer from '~/vue_shared/components/panel_resizer.vue';
+import { mapActions, mapState } from 'vuex';
+import PanelResizer from '~/vue_shared/components/panel_resizer.vue';
- export default {
- components: {
- PanelResizer,
+export default {
+ components: {
+ PanelResizer,
+ },
+ props: {
+ collapsible: {
+ type: Boolean,
+ required: true,
},
- props: {
- collapsible: {
- type: Boolean,
- required: true,
- },
- initialWidth: {
- type: Number,
- required: true,
- },
- minSize: {
- type: Number,
- required: false,
- default: 200,
- },
- side: {
- type: String,
- required: true,
- },
+ initialWidth: {
+ type: Number,
+ required: true,
},
- data() {
- return {
- width: this.initialWidth,
- };
+ minSize: {
+ type: Number,
+ required: false,
+ default: 340,
},
- computed: {
- ...mapState({
- collapsed(state) {
- return state[`${this.side}PanelCollapsed`];
- },
- }),
- panelStyle() {
- if (!this.collapsed) {
- return {
- width: `${this.width}px`,
- };
- }
-
- return {};
- },
+ side: {
+ type: String,
+ required: true,
},
- methods: {
- ...mapActions([
- 'setPanelCollapsedStatus',
- 'setResizingStatus',
- ]),
- toggleFullbarCollapsed() {
- if (this.collapsed && this.collapsible) {
- this.setPanelCollapsedStatus({
- side: this.side,
- collapsed: !this.collapsed,
- });
- }
+ },
+ data() {
+ return {
+ width: this.initialWidth,
+ };
+ },
+ computed: {
+ ...mapState({
+ collapsed(state) {
+ return state[`${this.side}PanelCollapsed`];
},
+ }),
+ panelStyle() {
+ if (!this.collapsed) {
+ return {
+ width: `${this.width}px`,
+ };
+ }
+
+ return {};
+ },
+ },
+ methods: {
+ ...mapActions(['setPanelCollapsedStatus', 'setResizingStatus']),
+ toggleFullbarCollapsed() {
+ if (this.collapsed && this.collapsible) {
+ this.setPanelCollapsedStatus({
+ side: this.side,
+ collapsed: !this.collapsed,
+ });
+ }
},
- maxSize: (window.innerWidth / 2),
- };
+ },
+ maxSize: window.innerWidth / 2,
+};
</script>
<template>
diff --git a/app/assets/javascripts/jobs/components/sidebar_details_block.vue b/app/assets/javascripts/jobs/components/sidebar_details_block.vue
index 172de6b3679..af47056d98f 100644
--- a/app/assets/javascripts/jobs/components/sidebar_details_block.vue
+++ b/app/assets/javascripts/jobs/components/sidebar_details_block.vue
@@ -45,7 +45,7 @@
return `#${this.job.runner.id}`;
},
hasTimeout() {
- return this.job.metadata != null && this.job.metadata.timeout_human_readable !== '';
+ return this.job.metadata != null && this.job.metadata.timeout_human_readable !== null;
},
timeout() {
if (this.job.metadata == null) {
diff --git a/app/assets/javascripts/milestone_select.js b/app/assets/javascripts/milestone_select.js
index add07c156a4..c749042a14a 100644
--- a/app/assets/javascripts/milestone_select.js
+++ b/app/assets/javascripts/milestone_select.js
@@ -94,10 +94,10 @@ export default class MilestoneSelect {
if (showMenuAbove) {
$dropdown.data('glDropdown').positionMenuAbove();
}
- $(`[data-milestone-id="${selectedMilestone}"] > a`).addClass('is-active');
+ $(`[data-milestone-id="${_.escape(selectedMilestone)}"] > a`).addClass('is-active');
}),
renderRow: milestone => `
- <li data-milestone-id="${milestone.name}">
+ <li data-milestone-id="${_.escape(milestone.name)}">
<a href='#' class='dropdown-menu-milestone-link'>
${_.escape(milestone.title)}
</a>
@@ -125,7 +125,6 @@ export default class MilestoneSelect {
return milestone.id;
}
},
- isSelected: milestone => milestone.name === selectedMilestone,
hidden: () => {
$selectBox.hide();
// display:block overrides the hide-collapse rule
@@ -137,7 +136,7 @@ export default class MilestoneSelect {
selectedMilestone = $dropdown[0].dataset.selected || selectedMilestoneDefault;
}
$('a.is-active', $el).removeClass('is-active');
- $(`[data-milestone-id="${selectedMilestone}"] > a`, $el).addClass('is-active');
+ $(`[data-milestone-id="${_.escape(selectedMilestone)}"] > a`, $el).addClass('is-active');
},
vue: $dropdown.hasClass('js-issue-board-sidebar'),
clicked: (clickEvent) => {
@@ -158,6 +157,7 @@ export default class MilestoneSelect {
const isMRIndex = (page === page && page === 'projects:merge_requests:index');
const isSelecting = (selected.name !== selectedMilestone);
selectedMilestone = isSelecting ? selected.name : selectedMilestoneDefault;
+
if ($dropdown.hasClass('js-filter-bulk-update') || $dropdown.hasClass('js-issuable-form-dropdown')) {
e.preventDefault();
return;
diff --git a/app/assets/javascripts/pages/groups/issues/index.js b/app/assets/javascripts/pages/groups/issues/index.js
index d149b307e7f..914f804fdd3 100644
--- a/app/assets/javascripts/pages/groups/issues/index.js
+++ b/app/assets/javascripts/pages/groups/issues/index.js
@@ -5,6 +5,7 @@ import { FILTERED_SEARCH } from '~/pages/constants';
document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
+ isGroupDecendent: true,
});
projectSelect();
});
diff --git a/app/assets/javascripts/pages/groups/merge_requests/index.js b/app/assets/javascripts/pages/groups/merge_requests/index.js
index a5cc1f34b63..1600faa3611 100644
--- a/app/assets/javascripts/pages/groups/merge_requests/index.js
+++ b/app/assets/javascripts/pages/groups/merge_requests/index.js
@@ -5,6 +5,7 @@ import { FILTERED_SEARCH } from '~/pages/constants';
document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({
page: FILTERED_SEARCH.MERGE_REQUESTS,
+ isGroupDecendent: true,
});
projectSelect();
});
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 516198b1b8a..91016f6494e 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -150,7 +150,8 @@ class Projects::LabelsController < Projects::ApplicationController
end
def find_labels
- @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
+ @available_labels ||=
+ LabelsFinder.new(current_user, project_id: @project.id, include_ancestor_groups: params[:include_ancestor_groups]).execute
end
def authorize_admin_labels!
diff --git a/app/controllers/projects/lfs_api_controller.rb b/app/controllers/projects/lfs_api_controller.rb
index c77f10ef1dd..ee4ed674110 100644
--- a/app/controllers/projects/lfs_api_controller.rb
+++ b/app/controllers/projects/lfs_api_controller.rb
@@ -41,7 +41,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController
def existing_oids
@existing_oids ||= begin
- storage_project.lfs_objects.where(oid: objects.map { |o| o['oid'].to_s }).pluck(:oid)
+ project.all_lfs_objects.where(oid: objects.map { |o| o['oid'].to_s }).pluck(:oid)
end
end
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index 780c0fdb03e..afd1f824b32 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -28,9 +28,10 @@ class LabelsFinder < UnionFinder
if project
if project.group.present?
labels_table = Label.arel_table
+ group_ids = group_ids_for(project.group)
label_ids << Label.where(
- labels_table[:type].eq('GroupLabel').and(labels_table[:group_id].eq(project.group.id)).or(
+ labels_table[:type].eq('GroupLabel').and(labels_table[:group_id].in(group_ids)).or(
labels_table[:type].eq('ProjectLabel').and(labels_table[:project_id].eq(project.id))
)
)
@@ -38,11 +39,14 @@ class LabelsFinder < UnionFinder
label_ids << project.labels
end
end
- elsif only_group_labels?
- label_ids << Label.where(group_id: group_ids)
else
+ if group?
+ group = Group.find(params[:group_id])
+ label_ids << Label.where(group_id: group_ids_for(group))
+ end
+
label_ids << Label.where(group_id: projects.group_ids)
- label_ids << Label.where(project_id: projects.select(:id))
+ label_ids << Label.where(project_id: projects.select(:id)) unless only_group_labels?
end
label_ids
@@ -59,22 +63,33 @@ class LabelsFinder < UnionFinder
items.where(title: title)
end
- def group_ids
+ # Gets redacted array of group ids
+ # which can include the ancestors and descendants of the requested group.
+ def group_ids_for(group)
strong_memoize(:group_ids) do
- groups_user_can_read_labels(groups_to_include).map(&:id)
+ groups = groups_to_include(group)
+
+ groups_user_can_read_labels(groups).map(&:id)
end
end
- def groups_to_include
- group = Group.find(params[:group_id])
+ def groups_to_include(group)
groups = [group]
- groups += group.ancestors if params[:include_ancestor_groups].present?
- groups += group.descendants if params[:include_descendant_groups].present?
+ groups += group.ancestors if include_ancestor_groups?
+ groups += group.descendants if include_descendant_groups?
groups
end
+ def include_ancestor_groups?
+ params[:include_ancestor_groups]
+ end
+
+ def include_descendant_groups?
+ params[:include_descendant_groups]
+ end
+
def group?
params[:group_id].present?
end
diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb
index 275e892b2e6..af878bcf9a0 100644
--- a/app/helpers/boards_helper.rb
+++ b/app/helpers/boards_helper.rb
@@ -53,10 +53,12 @@ module BoardsHelper
end
def board_list_data
+ include_descendant_groups = @group&.present?
+
{
toggle: "dropdown",
- list_labels_path: labels_filter_path(true),
- labels: labels_filter_path(true),
+ list_labels_path: labels_filter_path(true, include_ancestor_groups: true),
+ labels: labels_filter_path(true, include_descendant_groups: include_descendant_groups),
labels_endpoint: @labels_endpoint,
namespace_path: @namespace_path,
project_path: @project&.path,
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index 87ff607dc3f..c4a6a1e4bb3 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -129,13 +129,17 @@ module LabelsHelper
end
end
- def labels_filter_path(only_group_labels = false)
+ def labels_filter_path(only_group_labels = false, include_ancestor_groups: true, include_descendant_groups: false)
project = @target_project || @project
+ options = {}
+ options[:include_ancestor_groups] = include_ancestor_groups if include_ancestor_groups
+ options[:include_descendant_groups] = include_descendant_groups if include_descendant_groups
+
if project
- project_labels_path(project, :json)
+ project_labels_path(project, :json, options)
elsif @group
- options = { only_group_labels: only_group_labels } if only_group_labels
+ options[:only_group_labels] = only_group_labels if only_group_labels
group_labels_path(@group, :json, options)
else
dashboard_labels_path(:json)
diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb
index f435c80c656..f872990122e 100644
--- a/app/helpers/services_helper.rb
+++ b/app/helpers/services_helper.rb
@@ -1,4 +1,29 @@
module ServicesHelper
+ def service_event_description(event)
+ case event
+ when "push", "push_events"
+ "Event will be triggered by a push to the repository"
+ when "tag_push", "tag_push_events"
+ "Event will be triggered when a new tag is pushed to the repository"
+ when "note", "note_events"
+ "Event will be triggered when someone adds a comment"
+ when "confidential_note", "confidential_note_events"
+ "Event will be triggered when someone adds a comment on a confidential issue"
+ when "issue", "issue_events"
+ "Event will be triggered when an issue is created/updated/closed"
+ when "confidential_issue", "confidential_issues_events"
+ "Event will be triggered when a confidential issue is created/updated/closed"
+ when "merge_request", "merge_request_events"
+ "Event will be triggered when a merge request is created/updated/merged"
+ when "pipeline", "pipeline_events"
+ "Event will be triggered when a pipeline status changes"
+ when "wiki_page", "wiki_page_events"
+ "Event will be triggered when a wiki page is created/updated"
+ when "commit", "commit_events"
+ "Event will be triggered when a commit is created/updated"
+ end
+ end
+
def service_event_field_name(event)
event = event.pluralize if %w[merge_request issue confidential_issue].include?(event)
"#{event}_events"
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index b64be89c181..5e7c20ef51e 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -123,7 +123,7 @@ module TreeHelper
# returns the relative path of the first subdir that doesn't have only one directory descendant
def flatten_tree(root_path, tree)
- return tree.flat_path.sub(%r{\A#{root_path}/}, '') if tree.flat_path.present?
+ return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present?
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 18e96389199..4aa65bf4273 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -90,6 +90,7 @@ module Ci
before_save :ensure_token
before_destroy { unscoped_project }
+ before_create :ensure_metadata
after_create unless: :importing? do |build|
run_after_commit { BuildHooksWorker.perform_async(build.id) }
end
diff --git a/app/models/commit.rb b/app/models/commit.rb
index b64462fb768..3f7f36e83c0 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -32,7 +32,8 @@ class Commit
COMMIT_SHA_PATTERN = /\h{#{MIN_SHA_LENGTH},40}/.freeze
def banzai_render_context(field)
- context = { pipeline: :single_line, project: self.project }
+ pipeline = field == :description ? :commit_description : :single_line
+ context = { pipeline: pipeline, project: self.project }
context[:author] = self.author if self.author
context
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 9fb5b7efec6..3469d5d795c 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -141,7 +141,7 @@ class CommitStatus < ActiveRecord::Base
end
def group_name
- name.to_s.gsub(%r{\d+[\.\s:/\\]+\d+\s*}, '').strip
+ name.to_s.gsub(%r{\d+[\s:/\\]+\d+\s*}, '').strip
end
def failed_but_allowed?
diff --git a/app/models/hooks/project_hook.rb b/app/models/hooks/project_hook.rb
index b6dd39b860b..ec072882cc9 100644
--- a/app/models/hooks/project_hook.rb
+++ b/app/models/hooks/project_hook.rb
@@ -7,6 +7,7 @@ class ProjectHook < WebHook
:issue_hooks,
:confidential_issue_hooks,
:note_hooks,
+ :confidential_note_hooks,
:merge_request_hooks,
:job_hooks,
:pipeline_hooks,
diff --git a/app/models/note.rb b/app/models/note.rb
index 0f5fb529a87..109405d3f17 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -268,6 +268,10 @@ class Note < ActiveRecord::Base
self.special_role = Note::SpecialRole::FIRST_TIME_CONTRIBUTOR
end
+ def confidential?
+ noteable.try(:confidential?)
+ end
+
def editable?
!system?
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 714a15ade9c..32289106f28 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1066,6 +1066,16 @@ class Project < ActiveRecord::Base
end
end
+ # This will return all `lfs_objects` that are accessible to the project.
+ # So this might be `self.lfs_objects` if the project is not part of a fork
+ # network, or it is the base of the fork network.
+ #
+ # TODO: refactor this to get the correct lfs objects when implementing
+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
+ def all_lfs_objects
+ lfs_storage_project.lfs_objects
+ end
+
def personal?
!group
end
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb
index dab0ea1a681..7591ab4f478 100644
--- a/app/models/project_services/chat_notification_service.rb
+++ b/app/models/project_services/chat_notification_service.rb
@@ -21,8 +21,16 @@ class ChatNotificationService < Service
end
end
+ def confidential_issue_channel
+ properties['confidential_issue_channel'].presence || properties['issue_channel']
+ end
+
+ def confidential_note_channel
+ properties['confidential_note_channel'].presence || properties['note_channel']
+ end
+
def self.supported_events
- %w[push issue confidential_issue merge_request note tag_push
+ %w[push issue confidential_issue merge_request note confidential_note tag_push
pipeline wiki_page]
end
@@ -55,7 +63,9 @@ class ChatNotificationService < Service
return false unless message
- channel_name = get_channel_field(object_kind).presence || channel
+ event_type = data[:event_type] || object_kind
+
+ channel_name = get_channel_field(event_type).presence || channel
opts = {}
opts[:channel] = channel_name if channel_name
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index f31c3f02af2..dce878e485f 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -46,7 +46,7 @@ class HipchatService < Service
end
def self.supported_events
- %w(push issue confidential_issue merge_request note tag_push pipeline)
+ %w(push issue confidential_issue merge_request note confidential_note tag_push pipeline)
end
def execute(data)
diff --git a/app/models/service.rb b/app/models/service.rb
index 7424cef0fc0..e9b6f005aec 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -14,6 +14,7 @@ class Service < ActiveRecord::Base
default_value_for :merge_requests_events, true
default_value_for :tag_push_events, true
default_value_for :note_events, true
+ default_value_for :confidential_note_events, true
default_value_for :job_events, true
default_value_for :pipeline_events, true
default_value_for :wiki_page_events, true
@@ -42,6 +43,7 @@ class Service < ActiveRecord::Base
scope :confidential_issue_hooks, -> { where(confidential_issues_events: true, active: true) }
scope :merge_request_hooks, -> { where(merge_requests_events: true, active: true) }
scope :note_hooks, -> { where(note_events: true, active: true) }
+ scope :confidential_note_hooks, -> { where(confidential_note_events: true, active: true) }
scope :job_hooks, -> { where(job_events: true, active: true) }
scope :pipeline_hooks, -> { where(pipeline_events: true, active: true) }
scope :wiki_page_hooks, -> { where(wiki_page_events: true, active: true) }
@@ -168,8 +170,10 @@ class Service < ActiveRecord::Base
def self.prop_accessor(*args)
args.each do |arg|
class_eval %{
- def #{arg}
- properties['#{arg}']
+ unless method_defined?(arg)
+ def #{arg}
+ properties['#{arg}']
+ end
end
def #{arg}=(value)
diff --git a/app/serializers/build_metadata_entity.rb b/app/serializers/build_metadata_entity.rb
index 39f429aa6c3..f16f3badffa 100644
--- a/app/serializers/build_metadata_entity.rb
+++ b/app/serializers/build_metadata_entity.rb
@@ -1,8 +1,5 @@
class BuildMetadataEntity < Grape::Entity
- expose :timeout_human_readable do |metadata|
- metadata.timeout_human_readable unless metadata.timeout.nil?
- end
-
+ expose :timeout_human_readable
expose :timeout_source do |metadata|
metadata.present.timeout_source
end
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 15fed7d17c1..3ceab209f3f 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -42,7 +42,10 @@ module Boards
)
end
- attrs[:move_between_ids] = move_between_ids if move_between_ids
+ if move_between_ids
+ attrs[:move_between_ids] = move_between_ids
+ attrs[:board_group_id] = board.group&.id
+ end
attrs
end
diff --git a/app/services/boards/lists/create_service.rb b/app/services/boards/lists/create_service.rb
index bebc90c7a8d..02f1c709374 100644
--- a/app/services/boards/lists/create_service.rb
+++ b/app/services/boards/lists/create_service.rb
@@ -12,11 +12,15 @@ module Boards
private
def available_labels_for(board)
+ options = { include_ancestor_groups: true }
+
if board.group_board?
- parent.labels
+ options.merge!(group_id: parent.id, only_group_labels: true)
else
- LabelsFinder.new(current_user, project_id: parent.id).execute
+ options[:project_id] = parent.id
end
+
+ LabelsFinder.new(current_user, options).execute
end
def next_position(board)
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index 02fb48108fb..91ec702fbc6 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -106,7 +106,7 @@ class IssuableBaseService < BaseService
end
def available_labels
- @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id).execute
+ @available_labels ||= LabelsFinder.new(current_user, project_id: @project.id, include_ancestor_groups: true).execute
end
def handle_quick_actions_on_create(issuable)
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index d7aa7e2347e..4161932ad2a 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -55,9 +55,10 @@ module Issues
return unless params[:move_between_ids]
after_id, before_id = params.delete(:move_between_ids)
+ board_group_id = params.delete(:board_group_id)
- issue_before = get_issue_if_allowed(issue.project, before_id) if before_id
- issue_after = get_issue_if_allowed(issue.project, after_id) if after_id
+ issue_before = get_issue_if_allowed(before_id, board_group_id)
+ issue_after = get_issue_if_allowed(after_id, board_group_id)
issue.move_between(issue_before, issue_after)
end
@@ -84,8 +85,16 @@ module Issues
private
- def get_issue_if_allowed(project, id)
- issue = project.issues.find(id)
+ def get_issue_if_allowed(id, board_group_id = nil)
+ return unless id
+
+ issue =
+ if board_group_id
+ IssuesFinder.new(current_user, group_id: board_group_id).find_by(id: id)
+ else
+ project.issues.find(id)
+ end
+
issue if can?(current_user, :update_issue, issue)
end
diff --git a/app/services/notes/post_process_service.rb b/app/services/notes/post_process_service.rb
index ad3dcc5010b..f0cab2ade6d 100644
--- a/app/services/notes/post_process_service.rb
+++ b/app/services/notes/post_process_service.rb
@@ -24,8 +24,10 @@ module Notes
def execute_note_hooks
note_data = hook_data
- @note.project.execute_hooks(note_data, :note_hooks)
- @note.project.execute_services(note_data, :note_hooks)
+ hooks_scope = @note.confidential? ? :confidential_note_hooks : :note_hooks
+
+ @note.project.execute_hooks(note_data, hooks_scope)
+ @note.project.execute_services(note_data, hooks_scope)
end
end
end
diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb
index e61ecb696d0..346971138b1 100644
--- a/app/services/projects/autocomplete_service.rb
+++ b/app/services/projects/autocomplete_service.rb
@@ -21,7 +21,8 @@ module Projects
end
def labels(target = nil)
- labels = LabelsFinder.new(current_user, project_id: project.id).execute.select([:color, :title])
+ labels = LabelsFinder.new(current_user, project_id: project.id, include_ancestor_groups: true)
+ .execute.select([:color, :title])
return labels unless target&.respond_to?(:labels)
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index 402cddd3ec1..7bf0b90b491 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -28,7 +28,7 @@ module Projects
end
def save_services
- [version_saver, avatar_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver].all?(&:save)
+ [version_saver, avatar_saver, project_tree_saver, uploads_saver, repo_saver, wiki_repo_saver, lfs_saver].all?(&:save)
end
def version_saver
@@ -55,6 +55,10 @@ module Projects
Gitlab::ImportExport::WikiRepoSaver.new(project: project, shared: @shared)
end
+ def lfs_saver
+ Gitlab::ImportExport::LfsSaver.new(project: project, shared: @shared)
+ end
+
def cleanup_and_notify_error
Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{@shared.errors.join(', ')}")
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index cba49faac31..6cc51b6ee1b 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -200,7 +200,7 @@ module QuickActions
end
params '~label1 ~"label 2"'
condition do
- available_labels = LabelsFinder.new(current_user, project_id: project.id).execute
+ available_labels = LabelsFinder.new(current_user, project_id: project.id, include_ancestor_groups: true).execute
current_user.can?(:"admin_#{issuable.to_ability_name}", project) &&
available_labels.any?
@@ -562,7 +562,7 @@ module QuickActions
def find_labels(labels_param)
extract_references(labels_param, :label) |
- LabelsFinder.new(current_user, project_id: project.id, name: labels_param.split).execute
+ LabelsFinder.new(current_user, project_id: project.id, name: labels_param.split, include_ancestor_groups: true).execute
end
def find_label_references(labels_param)
@@ -593,6 +593,7 @@ module QuickActions
def extract_references(arg, type)
ext = Gitlab::ReferenceExtractor.new(project, current_user)
+
ext.analyze(arg, author: current_user)
ext.references(type)
diff --git a/app/views/admin/application_settings/_email.html.haml b/app/views/admin/application_settings/_email.html.haml
new file mode 100644
index 00000000000..6c89f1c4e98
--- /dev/null
+++ b/app/views/admin/application_settings/_email.html.haml
@@ -0,0 +1,26 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :email_author_in_body do
+ = f.check_box :email_author_in_body
+ Include author name in notification email body
+ .help-block
+ Some email servers do not support overriding the email sender name.
+ Enable this option to include the name of the author of the issue,
+ merge request or comment in the email body instead.
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :html_emails_enabled do
+ = f.check_box :html_emails_enabled
+ Enable HTML emails
+ .help-block
+ By default GitLab sends emails in HTML and plain text formats so mail
+ clients can choose what format to use. Disable this option if you only
+ want to send emails in plain text format.
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
deleted file mode 100644
index 9ab2c2892b2..00000000000
--- a/app/views/admin/application_settings/_form.html.haml
+++ /dev/null
@@ -1,173 +0,0 @@
-= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
- = form_errors(@application_setting)
-
- - if Gitlab.config.registry.enabled
- %fieldset
- %legend Container Registry
- .form-group
- = f.label :container_registry_token_expire_delay, 'Authorization token duration (minutes)', class: 'control-label col-sm-2'
- .col-sm-10
- = f.number_field :container_registry_token_expire_delay, class: 'form-control'
-
- - if koding_enabled?
- %fieldset
- %legend Koding
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :koding_enabled do
- = f.check_box :koding_enabled
- Enable Koding
- .help-block
- Koding integration has been deprecated since GitLab 10.0. If you disable your Koding integration, you will not be able to enable it again.
- .form-group
- = f.label :koding_url, 'Koding URL', class: 'control-label col-sm-2'
- .col-sm-10
- = f.text_field :koding_url, class: 'form-control', placeholder: 'http://gitlab.your-koding-instance.com:8090'
- .help-block
- Koding has integration enabled out of the box for the
- %strong gitlab
- team, and you need to provide that team's URL here. Learn more in the
- = succeed "." do
- = link_to "Koding administration documentation", help_page_path("administration/integration/koding")
-
- %fieldset
- %legend PlantUML
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :plantuml_enabled do
- = f.check_box :plantuml_enabled
- Enable PlantUML
- .form-group
- = f.label :plantuml_url, 'PlantUML URL', class: 'control-label col-sm-2'
- .col-sm-10
- = f.text_field :plantuml_url, class: 'form-control', placeholder: 'http://gitlab.your-plantuml-instance.com:8080'
- .help-block
- Allow rendering of
- = link_to "PlantUML", "http://plantuml.com"
- diagrams in Asciidoc documents using an external PlantUML service.
-
- %fieldset
- %legend#usage-statistics Usage statistics
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :version_check_enabled do
- = f.check_box :version_check_enabled
- Enable version check
- .help-block
- GitLab will inform you if a new version is available.
- = link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "version-check")
- about what information is shared with GitLab Inc.
- .form-group
- .col-sm-offset-2.col-sm-10
- - can_be_configured = @application_setting.usage_ping_can_be_configured?
- .checkbox
- = f.label :usage_ping_enabled do
- = f.check_box :usage_ping_enabled, disabled: !can_be_configured
- Enable usage ping
- .help-block
- - if can_be_configured
- To help improve GitLab and its user experience, GitLab will
- periodically collect usage information.
- = link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-ping")
- about what information is shared with GitLab Inc. Visit
- = link_to 'Cohorts', admin_cohorts_path(anchor: 'usage-ping')
- to see the JSON payload sent.
- - else
- The usage ping is disabled, and cannot be configured through this
- form. For more information, see the documentation on
- = succeed '.' do
- = link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping')
-
- %fieldset
- %legend Email
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :email_author_in_body do
- = f.check_box :email_author_in_body
- Include author name in notification email body
- .help-block
- Some email servers do not support overriding the email sender name.
- Enable this option to include the name of the author of the issue,
- merge request or comment in the email body instead.
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :html_emails_enabled do
- = f.check_box :html_emails_enabled
- Enable HTML emails
- .help-block
- By default GitLab sends emails in HTML and plain text formats so mail
- clients can choose what format to use. Disable this option if you only
- want to send emails in plain text format.
-
- %fieldset
- %legend Gitaly Timeouts
- .form-group
- = f.label :gitaly_timeout_default, 'Default Timeout Period', class: 'control-label col-sm-2'
- .col-sm-10
- = f.number_field :gitaly_timeout_default, class: 'form-control'
- .help-block
- Timeout for Gitaly calls from the GitLab application (in seconds). This timeout is not enforced
- for git fetch/push operations or Sidekiq jobs.
- .form-group
- = f.label :gitaly_timeout_fast, 'Fast Timeout Period', class: 'control-label col-sm-2'
- .col-sm-10
- = f.number_field :gitaly_timeout_fast, class: 'form-control'
- .help-block
- Fast operation timeout (in seconds). Some Gitaly operations are expected to be fast.
- If they exceed this threshold, there may be a problem with a storage shard and 'failing fast'
- can help maintain the stability of the GitLab instance.
- .form-group
- = f.label :gitaly_timeout_medium, 'Medium Timeout Period', class: 'control-label col-sm-2'
- .col-sm-10
- = f.number_field :gitaly_timeout_medium, class: 'form-control'
- .help-block
- Medium operation timeout (in seconds). This should be a value between the Fast and the Default timeout.
-
- %fieldset
- %legend Web terminal
- .form-group
- = f.label :terminal_max_session_time, 'Max session time', class: 'control-label col-sm-2'
- .col-sm-10
- = f.number_field :terminal_max_session_time, class: 'form-control'
- .help-block
- Maximum time for web terminal websocket connection (in seconds).
- 0 for unlimited.
-
- %fieldset
- %legend Real-time features
- .form-group
- = f.label :polling_interval_multiplier, 'Polling interval multiplier', class: 'control-label col-sm-2'
- .col-sm-10
- = f.text_field :polling_interval_multiplier, class: 'form-control'
- .help-block
- Change this value to influence how frequently the GitLab UI polls for updates.
- If you set the value to 2 all polling intervals are multiplied
- by 2, which means that polling happens half as frequently.
- The multiplier can also have a decimal value.
- The default value (1) is a reasonable choice for the majority of GitLab
- installations. Set to 0 to completely disable polling.
- = link_to icon('question-circle'), help_page_path('administration/polling')
-
- %fieldset
- %legend Performance optimization
- .form-group
- .col-sm-offset-2.col-sm-10
- .checkbox
- = f.label :authorized_keys_enabled do
- = f.check_box :authorized_keys_enabled
- Write to "authorized_keys" file
- .help-block
- By default, we write to the "authorized_keys" file to support Git
- over SSH without additional configuration. GitLab can be optimized
- to authenticate SSH keys via the database file. Only uncheck this
- if you have configured your OpenSSH server to use the
- AuthorizedKeysCommand. Click on the help icon for more details.
- = link_to icon('question-circle'), help_page_path('administration/operations/fast_ssh_key_lookup')
-
- .form-actions
- = f.submit 'Save', class: 'btn btn-save'
diff --git a/app/views/admin/application_settings/_gitaly.html.haml b/app/views/admin/application_settings/_gitaly.html.haml
new file mode 100644
index 00000000000..4acc5b3a0c5
--- /dev/null
+++ b/app/views/admin/application_settings/_gitaly.html.haml
@@ -0,0 +1,27 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ = f.label :gitaly_timeout_default, 'Default Timeout Period', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.number_field :gitaly_timeout_default, class: 'form-control'
+ .help-block
+ Timeout for Gitaly calls from the GitLab application (in seconds). This timeout is not enforced
+ for git fetch/push operations or Sidekiq jobs.
+ .form-group
+ = f.label :gitaly_timeout_fast, 'Fast Timeout Period', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.number_field :gitaly_timeout_fast, class: 'form-control'
+ .help-block
+ Fast operation timeout (in seconds). Some Gitaly operations are expected to be fast.
+ If they exceed this threshold, there may be a problem with a storage shard and 'failing fast'
+ can help maintain the stability of the GitLab instance.
+ .form-group
+ = f.label :gitaly_timeout_medium, 'Medium Timeout Period', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.number_field :gitaly_timeout_medium, class: 'form-control'
+ .help-block
+ Medium operation timeout (in seconds). This should be a value between the Fast and the Default timeout.
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_koding.html.haml b/app/views/admin/application_settings/_koding.html.haml
new file mode 100644
index 00000000000..17358cf775b
--- /dev/null
+++ b/app/views/admin/application_settings/_koding.html.haml
@@ -0,0 +1,24 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :koding_enabled do
+ = f.check_box :koding_enabled
+ Enable Koding
+ .help-block
+ Koding integration has been deprecated since GitLab 10.0. If you disable your Koding integration, you will not be able to enable it again.
+ .form-group
+ = f.label :koding_url, 'Koding URL', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.text_field :koding_url, class: 'form-control', placeholder: 'http://gitlab.your-koding-instance.com:8090'
+ .help-block
+ Koding has integration enabled out of the box for the
+ %strong gitlab
+ team, and you need to provide that team's URL here. Learn more in the
+ = succeed "." do
+ = link_to "Koding administration documentation", help_page_path("administration/integration/koding")
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_performance.html.haml b/app/views/admin/application_settings/_performance.html.haml
new file mode 100644
index 00000000000..01d5a31aa9f
--- /dev/null
+++ b/app/views/admin/application_settings/_performance.html.haml
@@ -0,0 +1,19 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :authorized_keys_enabled do
+ = f.check_box :authorized_keys_enabled
+ Write to "authorized_keys" file
+ .help-block
+ By default, we write to the "authorized_keys" file to support Git
+ over SSH without additional configuration. GitLab can be optimized
+ to authenticate SSH keys via the database file. Only uncheck this
+ if you have configured your OpenSSH server to use the
+ AuthorizedKeysCommand. Click on the help icon for more details.
+ = link_to icon('question-circle'), help_page_path('administration/operations/fast_ssh_key_lookup')
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_plantuml.html.haml b/app/views/admin/application_settings/_plantuml.html.haml
new file mode 100644
index 00000000000..56764b3fb81
--- /dev/null
+++ b/app/views/admin/application_settings/_plantuml.html.haml
@@ -0,0 +1,20 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :plantuml_enabled do
+ = f.check_box :plantuml_enabled
+ Enable PlantUML
+ .form-group
+ = f.label :plantuml_url, 'PlantUML URL', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.text_field :plantuml_url, class: 'form-control', placeholder: 'http://gitlab.your-plantuml-instance.com:8080'
+ .help-block
+ Allow rendering of
+ = link_to "PlantUML", "http://plantuml.com"
+ diagrams in Asciidoc documents using an external PlantUML service.
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_realtime.html.haml b/app/views/admin/application_settings/_realtime.html.haml
new file mode 100644
index 00000000000..0a53a75119e
--- /dev/null
+++ b/app/views/admin/application_settings/_realtime.html.haml
@@ -0,0 +1,19 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ = f.label :polling_interval_multiplier, 'Polling interval multiplier', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.text_field :polling_interval_multiplier, class: 'form-control'
+ .help-block
+ Change this value to influence how frequently the GitLab UI polls for updates.
+ If you set the value to 2 all polling intervals are multiplied
+ by 2, which means that polling happens half as frequently.
+ The multiplier can also have a decimal value.
+ The default value (1) is a reasonable choice for the majority of GitLab
+ installations. Set to 0 to completely disable polling.
+ = link_to icon('question-circle'), help_page_path('administration/polling')
+
+ = f.submit 'Save changes', class: "btn btn-success"
+
diff --git a/app/views/admin/application_settings/_registry.html.haml b/app/views/admin/application_settings/_registry.html.haml
new file mode 100644
index 00000000000..3451ef62458
--- /dev/null
+++ b/app/views/admin/application_settings/_registry.html.haml
@@ -0,0 +1,10 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ = f.label :container_registry_token_expire_delay, 'Authorization token duration (minutes)', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.number_field :container_registry_token_expire_delay, class: 'form-control'
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_terminal.html.haml b/app/views/admin/application_settings/_terminal.html.haml
new file mode 100644
index 00000000000..36d8838803f
--- /dev/null
+++ b/app/views/admin/application_settings/_terminal.html.haml
@@ -0,0 +1,13 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ = f.label :terminal_max_session_time, 'Max session time', class: 'control-label col-sm-2'
+ .col-sm-10
+ = f.number_field :terminal_max_session_time, class: 'form-control'
+ .help-block
+ Maximum time for web terminal websocket connection (in seconds).
+ 0 for unlimited.
+
+ = f.submit 'Save changes', class: "btn btn-success"
diff --git a/app/views/admin/application_settings/_usage.html.haml b/app/views/admin/application_settings/_usage.html.haml
new file mode 100644
index 00000000000..7684e2cfdd1
--- /dev/null
+++ b/app/views/admin/application_settings/_usage.html.haml
@@ -0,0 +1,37 @@
+= form_for @application_setting, url: admin_application_settings_path, html: { class: 'form-horizontal fieldset-form' } do |f|
+ = form_errors(@application_setting)
+
+ %fieldset
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :version_check_enabled do
+ = f.check_box :version_check_enabled
+ Enable version check
+ .help-block
+ GitLab will inform you if a new version is available.
+ = link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "version-check")
+ about what information is shared with GitLab Inc.
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ - can_be_configured = @application_setting.usage_ping_can_be_configured?
+ .checkbox
+ = f.label :usage_ping_enabled do
+ = f.check_box :usage_ping_enabled, disabled: !can_be_configured
+ Enable usage ping
+ .help-block
+ - if can_be_configured
+ To help improve GitLab and its user experience, GitLab will
+ periodically collect usage information.
+ = link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-ping")
+ about what information is shared with GitLab Inc. Visit
+ = link_to 'Cohorts', admin_cohorts_path(anchor: 'usage-ping')
+ to see the JSON payload sent.
+ - else
+ The usage ping is disabled, and cannot be configured through this
+ form. For more information, see the documentation on
+ = succeed '.' do
+ = link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping')
+
+ = f.submit 'Save changes', class: "btn btn-success"
+
diff --git a/app/views/admin/application_settings/show.html.haml b/app/views/admin/application_settings/show.html.haml
index f4320513aff..caaa93aa1e2 100644
--- a/app/views/admin/application_settings/show.html.haml
+++ b/app/views/admin/application_settings/show.html.haml
@@ -76,7 +76,7 @@
%button.btn.js-settings-toggle{ type: 'button' }
= expanded ? 'Collapse' : 'Expand'
%p
- = _('Auto DevOps, runners amd job artifacts')
+ = _('Auto DevOps, runners and job artifacts')
.settings-content
= render 'ci_cd'
@@ -102,7 +102,7 @@
.settings-content
= render 'prometheus'
-%section.settings.as-performance.no-animate#js-performance-settings{ class: ('expanded' if expanded) }
+%section.settings.as-performance-bar.no-animate#js-performance-bar-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _('Profiling - Performance bar')
@@ -180,6 +180,107 @@
.settings-content
= render 'repository_check'
+- if Gitlab.config.registry.enabled
+ %section.settings.as-registry.no-animate#js-registry-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Container Registry')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Various container registry settings.')
+ .settings-content
+ = render 'registry'
+
+- if koding_enabled?
+ %section.settings.as-koding.no-animate#js-koding-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Koding')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Online IDE integration settings.')
+ .settings-content
+ = render 'koding'
+
+%section.settings.as-plantuml.no-animate#js-plantuml-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('PlantUML')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Allow rendering of PlantUML diagrams in Asciidoc documents.')
+ .settings-content
+ = render 'plantuml'
+
+%section.settings.as-usage.no-animate#js-usage-settings{ class: ('expanded' if expanded) }
+ .settings-header#usage-statistics
+ %h4
+ = _('Usage statistics')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Enable or disable version check and usage ping.')
+ .settings-content
+ = render 'usage'
+
+%section.settings.as-email.no-animate#js-email-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Email')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Various email settings.')
+ .settings-content
+ = render 'email'
+
+%section.settings.as-gitaly.no-animate#js-gitaly-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Gitaly')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Configure Gitaly timeouts.')
+ .settings-content
+ = render 'gitaly'
+
+%section.settings.as-terminal.no-animate#js-terminal-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Web terminal')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Set max session time for web terminal.')
+ .settings-content
+ = render 'terminal'
+
+%section.settings.as-realtime.no-animate#js-realtime-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Real-time features')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Change this value to influence how frequently the GitLab UI polls for updates.')
+ .settings-content
+ = render 'realtime'
+
+%section.settings.as-performance.no-animate#js-performance-settings{ class: ('expanded' if expanded) }
+ .settings-header
+ %h4
+ = _('Performance optimization')
+ %button.btn.js-settings-toggle{ type: 'button' }
+ = expanded ? 'Collapse' : 'Expand'
+ %p
+ = _('Various settings that affect GitLab performance.')
+ .settings-content
+ = render 'performance'
+
%section.settings.as-ip-limits.no-animate#js-ip-limits-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
@@ -201,6 +302,3 @@
= _('Allow requests to the local network from hooks and services.')
.settings-content
= render 'outbound'
-
-.prepend-top-20
- = render 'form'
diff --git a/app/views/email_rejection_mailer/rejection.text.haml b/app/views/email_rejection_mailer/rejection.text.haml
index 6693e6f90e8..af518b5b583 100644
--- a/app/views/email_rejection_mailer/rejection.text.haml
+++ b/app/views/email_rejection_mailer/rejection.text.haml
@@ -1,4 +1,3 @@
Unfortunately, your email message to GitLab could not be processed.
-
-
+\
= @reason
diff --git a/app/views/projects/_export.html.haml b/app/views/projects/_export.html.haml
index 825bfd0707f..1e7d9444986 100644
--- a/app/views/projects/_export.html.haml
+++ b/app/views/projects/_export.html.haml
@@ -21,11 +21,11 @@
%li Project uploads
%li Project configuration including web hooks and services
%li Issues with comments, merge requests with diffs and comments, labels, milestones, snippets, and other project entities
+ %li LFS objects
%p
The following items will NOT be exported:
%ul
%li Job traces and artifacts
- %li LFS objects
%li Container registry images
%li CI variables
%li Any encrypted tokens
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml
index 461129a3e0e..74c5317428c 100644
--- a/app/views/projects/commit/_commit_box.html.haml
+++ b/app/views/projects/commit/_commit_box.html.haml
@@ -49,10 +49,10 @@
.commit-box{ data: { project_path: project_path(@project) } }
%h3.commit-title
- = markdown(@commit.title, pipeline: :single_line, author: @commit.author)
+ = markdown_field(@commit, :title)
- if @commit.description.present?
%pre.commit-description
- = preserve(markdown(@commit.description, pipeline: :single_line, author: @commit.author))
+ = preserve(markdown_field(@commit, :description))
.info-well
.well-segment.branch-info
diff --git a/app/views/projects/commits/_commit.atom.builder b/app/views/projects/commits/_commit.atom.builder
index 50f7e7a3a33..640b5ecf99e 100644
--- a/app/views/projects/commits/_commit.atom.builder
+++ b/app/views/projects/commits/_commit.atom.builder
@@ -10,5 +10,5 @@ xml.entry do
xml.email commit.author_email
end
- xml.summary markdown(commit.description, pipeline: :single_line), type: 'html'
+ xml.summary markdown_field(commit, :description), type: 'html'
end
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index 6afcd447f28..975b9cb4729 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -107,7 +107,7 @@
- selected_labels.each do |label|
= hidden_field_tag "#{issuable.to_ability_name}[label_names][]", label.id, id: nil
.dropdown
- %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{ type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", namespace_path: @project.try(:namespace).try(:full_path), project_path: @project.try(:path), issue_update: issuable_json_path(issuable), labels: (project_labels_path(@project, :json) if @project) } }
+ %button.dropdown-menu-toggle.js-label-select.js-multiselect.js-label-sidebar-dropdown{ type: "button", data: {toggle: "dropdown", default_label: "Labels", field_name: "#{issuable.to_ability_name}[label_names][]", ability_name: issuable.to_ability_name, show_no: "true", show_any: "true", namespace_path: @project.try(:namespace).try(:full_path), project_path: @project.try(:path), issue_update: issuable_json_path(issuable), labels: (labels_filter_path(false) if @project) } }
%span.dropdown-toggle-text{ class: ("is-default" if selected_labels.empty?) }
= multi_label_name(selected_labels, "Labels")
= icon('chevron-down', 'aria-hidden': 'true')
diff --git a/app/views/shared/web_hooks/_form.html.haml b/app/views/shared/web_hooks/_form.html.haml
index ad4d39b4aa1..d36ca032558 100644
--- a/app/views/shared/web_hooks/_form.html.haml
+++ b/app/views/shared/web_hooks/_form.html.haml
@@ -33,6 +33,13 @@
%p.light
This URL will be triggered when someone adds a comment
%li
+ = form.check_box :confidential_note_events, class: 'pull-left'
+ .prepend-left-20
+ = form.label :confidential_note_events, class: 'list-label' do
+ %strong Confidential Comments
+ %p.light
+ This URL will be triggered when someone adds a comment on a confidential issue
+ %li
= form.check_box :issues_events, class: 'pull-left'
.prepend-left-20
= form.label :issues_events, class: 'list-label' do
diff --git a/changelogs/unreleased/42028-xss-diffs.yml b/changelogs/unreleased/42028-xss-diffs.yml
new file mode 100644
index 00000000000..a05f9d3c78d
--- /dev/null
+++ b/changelogs/unreleased/42028-xss-diffs.yml
@@ -0,0 +1,5 @@
+---
+title: Fix XSS on diff view stored on filenames
+merge_request:
+author:
+type: security
diff --git a/changelogs/unreleased/bvl-export-import-lfs.yml b/changelogs/unreleased/bvl-export-import-lfs.yml
new file mode 100644
index 00000000000..dd1f499c3a3
--- /dev/null
+++ b/changelogs/unreleased/bvl-export-import-lfs.yml
@@ -0,0 +1,5 @@
+---
+title: Support LFS objects when importing/exporting GitLab project archives
+merge_request: 18115
+author:
+type: added
diff --git a/changelogs/unreleased/dm-flatten-tree-plus-chars.yml b/changelogs/unreleased/dm-flatten-tree-plus-chars.yml
new file mode 100644
index 00000000000..23f1b30d8fa
--- /dev/null
+++ b/changelogs/unreleased/dm-flatten-tree-plus-chars.yml
@@ -0,0 +1,5 @@
+---
+title: Fix links to subdirectories of a directory with a plus character in its path
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/feature_detect_co_authored_commits.yml b/changelogs/unreleased/feature_detect_co_authored_commits.yml
new file mode 100644
index 00000000000..7b1269ed982
--- /dev/null
+++ b/changelogs/unreleased/feature_detect_co_authored_commits.yml
@@ -0,0 +1,6 @@
+---
+title: Detect commit message trailers and link users properly to their accounts
+ on Gitlab
+merge_request: 17919
+author: cousine
+type: added
diff --git a/changelogs/unreleased/issue_40915.yml b/changelogs/unreleased/issue_40915.yml
new file mode 100644
index 00000000000..2b6d98e69a6
--- /dev/null
+++ b/changelogs/unreleased/issue_40915.yml
@@ -0,0 +1,5 @@
+---
+title: Allow assigning and filtering issuables by ancestor group labels
+merge_request:
+author:
+type: added
diff --git a/changelogs/unreleased/issue_44551.yml b/changelogs/unreleased/issue_44551.yml
new file mode 100644
index 00000000000..d5265667b00
--- /dev/null
+++ b/changelogs/unreleased/issue_44551.yml
@@ -0,0 +1,5 @@
+---
+title: Fix 404 in group boards when moving issue between lists
+merge_request:
+author:
+type: fixed
diff --git a/changelogs/unreleased/jej-mattermost-notification-confidentiality.yml b/changelogs/unreleased/jej-mattermost-notification-confidentiality.yml
new file mode 100644
index 00000000000..d5219b5d019
--- /dev/null
+++ b/changelogs/unreleased/jej-mattermost-notification-confidentiality.yml
@@ -0,0 +1,5 @@
+---
+title: Adds confidential notes channel for Slack/Mattermost
+merge_request:
+author:
+type: security
diff --git a/changelogs/unreleased/osw-41401-render-mr-commit-sha-instead-diffs.yml b/changelogs/unreleased/osw-41401-render-mr-commit-sha-instead-diffs.yml
new file mode 100644
index 00000000000..44973641325
--- /dev/null
+++ b/changelogs/unreleased/osw-41401-render-mr-commit-sha-instead-diffs.yml
@@ -0,0 +1,5 @@
+---
+title: Render MR commit SHA instead "diffs" when viable
+merge_request:
+author:
+type: added
diff --git a/changelogs/unreleased/sh-gitlab-sidekiq-logger.yml b/changelogs/unreleased/sh-gitlab-sidekiq-logger.yml
new file mode 100644
index 00000000000..f68d45d2f38
--- /dev/null
+++ b/changelogs/unreleased/sh-gitlab-sidekiq-logger.yml
@@ -0,0 +1,5 @@
+---
+title: Add support for Sidekiq JSON logging
+merge_request:
+author:
+type: added
diff --git a/changelogs/unreleased/zj-feature-gate-remove-http-api.yml b/changelogs/unreleased/zj-feature-gate-remove-http-api.yml
new file mode 100644
index 00000000000..2095f60146c
--- /dev/null
+++ b/changelogs/unreleased/zj-feature-gate-remove-http-api.yml
@@ -0,0 +1,5 @@
+---
+title: Allow feature gates to be removed through the API
+merge_request:
+author:
+type: added
diff --git a/changelogs/unreleased/zj-opt-out-delete-refs.yml b/changelogs/unreleased/zj-opt-out-delete-refs.yml
new file mode 100644
index 00000000000..b02a45eee17
--- /dev/null
+++ b/changelogs/unreleased/zj-opt-out-delete-refs.yml
@@ -0,0 +1,5 @@
+---
+title: Bulk deleting refs is handled by Gitaly by default
+merge_request:
+author:
+type: performance
diff --git a/changelogs/unreleased/zj-opt-out-list-commits-by-oid.yml b/changelogs/unreleased/zj-opt-out-list-commits-by-oid.yml
new file mode 100644
index 00000000000..3871293ee04
--- /dev/null
+++ b/changelogs/unreleased/zj-opt-out-list-commits-by-oid.yml
@@ -0,0 +1,5 @@
+---
+title: ListCommitsByOid is executed by Gitaly by default
+merge_request:
+author:
+type: performance
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index 8db66037d61..126a9b8b803 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -226,6 +226,10 @@ production: &base
# plain_url: "http://..." # default: https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon
# ssl_url: "https://..." # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon
+ ## Sidekiq
+ sidekiq:
+ log_format: default # (json is also supported)
+
## Auxiliary jobs
# Periodically executed jobs, to self-heal GitLab, do external synchronizations, etc.
# Please read here for more information: https://github.com/ondrejbartas/sidekiq-cron#adding-cron-job
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 69b59b26d8c..187e70868ea 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -454,6 +454,12 @@ Settings.cron_jobs['pages_domain_verification_cron_worker']['cron'] ||= '*/15 *
Settings.cron_jobs['pages_domain_verification_cron_worker']['job_class'] = 'PagesDomainVerificationCronWorker'
#
+# Sidekiq
+#
+Settings['sidekiq'] ||= Settingslogic.new({})
+Settings['sidekiq']['log_format'] ||= 'default'
+
+#
# GitLab Shell
#
Settings['gitlab_shell'] ||= Settingslogic.new({})
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 161fb185c9b..f6803eb0b5a 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -5,16 +5,23 @@ queues_config_hash[:namespace] = Gitlab::Redis::Queues::SIDEKIQ_NAMESPACE
# Default is to retry 25 times with exponential backoff. That's too much.
Sidekiq.default_worker_options = { retry: 3 }
+enable_json_logs = Gitlab.config.sidekiq.log_format == 'json'
+
Sidekiq.configure_server do |config|
config.redis = queues_config_hash
config.server_middleware do |chain|
- chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS']
+ chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs
chain.add Gitlab::SidekiqMiddleware::Shutdown
chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0'
chain.add Gitlab::SidekiqStatus::ServerMiddleware
end
+ if enable_json_logs
+ Sidekiq.logger.formatter = Gitlab::SidekiqLogging::JSONFormatter.new
+ config.options[:job_logger] = Gitlab::SidekiqLogging::StructuredLogger
+ end
+
config.client_middleware do |chain|
chain.add Gitlab::SidekiqStatus::ClientMiddleware
end
diff --git a/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb
new file mode 100644
index 00000000000..900a6386922
--- /dev/null
+++ b/db/migrate/20171222115326_add_confidential_note_events_to_web_hooks.rb
@@ -0,0 +1,15 @@
+class AddConfidentialNoteEventsToWebHooks < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column :web_hooks, :confidential_note_events, :boolean
+ end
+
+ def down
+ remove_column :web_hooks, :confidential_note_events
+ end
+end
diff --git a/db/migrate/20180103123548_add_confidential_note_events_to_services.rb b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb
new file mode 100644
index 00000000000..b54ad88df43
--- /dev/null
+++ b/db/migrate/20180103123548_add_confidential_note_events_to_services.rb
@@ -0,0 +1,16 @@
+class AddConfidentialNoteEventsToServices < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column :services, :confidential_note_events, :boolean
+ change_column_default :services, :confidential_note_events, true
+ end
+
+ def down
+ remove_column :services, :confidential_note_events
+ end
+end
diff --git a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb
new file mode 100644
index 00000000000..fa51ac83619
--- /dev/null
+++ b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb
@@ -0,0 +1,23 @@
+class ScheduleSetConfidentialNoteEventsOnWebhooks < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 1_000
+ INTERVAL = 5.minutes
+
+ disable_ddl_transaction!
+
+ def up
+ migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks
+ migration_name = migration.to_s.demodulize
+ relation = migration::WebHook.hooks_to_update
+
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ migration_name,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
+ end
+
+ def down
+ end
+end
diff --git a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb
new file mode 100644
index 00000000000..a3ff9f1719e
--- /dev/null
+++ b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb
@@ -0,0 +1,23 @@
+class ScheduleSetConfidentialNoteEventsOnServices < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 1_000
+ INTERVAL = 20.minutes
+
+ disable_ddl_transaction!
+
+ def up
+ migration = Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices
+ migration_name = migration.to_s.demodulize
+ relation = migration::Service.services_to_update
+
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ migration_name,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 06fc1a9d7e9..25e7d720761 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1684,6 +1684,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t.boolean "confidential_issues_events", default: true, null: false
t.boolean "commit_events", default: true, null: false
t.boolean "job_events", default: false, null: false
+ t.boolean "confidential_note_events", default: true
end
add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree
@@ -2022,6 +2023,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t.boolean "confidential_issues_events", default: false, null: false
t.boolean "repository_update_events", default: false, null: false
t.boolean "job_events", default: false, null: false
+ t.boolean "confidential_note_events"
end
add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree
diff --git a/doc/administration/index.md b/doc/administration/index.md
index 60a45426636..c8f27719ce9 100644
--- a/doc/administration/index.md
+++ b/doc/administration/index.md
@@ -85,7 +85,6 @@ created in snippets, wikis, and repos.
- [Postfix for incoming email](reply_by_email_postfix_setup.md): Set up a
basic Postfix mail server with IMAP authentication on Ubuntu for incoming
emails.
-server with IMAP authentication on Ubuntu, to be used with Reply by email.
- [User Cohorts](../user/admin_area/user_cohorts.md): Display the monthly cohorts of new users and their activities over time.
[reply by email]: reply_by_email.md
diff --git a/doc/administration/logs.md b/doc/administration/logs.md
index cd107a5b39c..c8a3ef80e8f 100644
--- a/doc/administration/logs.md
+++ b/doc/administration/logs.md
@@ -146,6 +146,28 @@ this file. For example:
2014-06-10T18:18:26Z 14299 TID-55uqo INFO: Booting Sidekiq 3.0.0 with redis options {:url=>"redis://localhost:6379/0", :namespace=>"sidekiq"}
```
+Instead of the format above, you can opt to generate JSON logs for
+Sidekiq. For example:
+
+```json
+{"severity":"INFO","time":"2018-04-03T22:57:22.071Z","queue":"cronjob:update_all_mirrors","args":[],"class":"UpdateAllMirrorsWorker","retry":false,"queue_namespace":"cronjob","jid":"06aeaa3b0aadacf9981f368e","created_at":"2018-04-03T22:57:21.930Z","enqueued_at":"2018-04-03T22:57:21.931Z","pid":10077,"message":"UpdateAllMirrorsWorker JID-06aeaa3b0aadacf9981f368e: done: 0.139 sec","job_status":"done","duration":0.139,"completed_at":"2018-04-03T22:57:22.071Z"}
+```
+
+For Omnibus GitLab installations, add the configuration option:
+
+```ruby
+sidekiq['log_format'] = 'json'
+```
+
+For source installations, edit the `gitlab.yml` and set the Sidekiq
+`log_format` configuration option:
+
+```yaml
+ ## Sidekiq
+ sidekiq:
+ log_format: json
+```
+
## `gitlab-shell.log`
This file lives in `/var/log/gitlab/gitlab-shell/gitlab-shell.log` for
diff --git a/doc/api/features.md b/doc/api/features.md
index 6861dbf00a2..6ee1c36ef5b 100644
--- a/doc/api/features.md
+++ b/doc/api/features.md
@@ -86,3 +86,11 @@ Example response:
]
}
```
+
+## Delete a feature
+
+Removes a feature gate. Response is equal when the gate exists, or doesn't.
+
+```
+DELETE /features/:name
+```
diff --git a/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md b/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md
index b62874ef029..1f9b9d53fc1 100644
--- a/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md
+++ b/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md
@@ -190,7 +190,7 @@ To start, we create an `Envoy.blade.php` in the root of our app with a simple ta
```php
@servers(['web' => 'remote_username@remote_host'])
-@task('list', [on => 'web'])
+@task('list', ['on' => 'web'])
ls -l
@endtask
```
diff --git a/doc/user/admin_area/settings/email.md b/doc/user/admin_area/settings/email.md
new file mode 100644
index 00000000000..7c9e5bf882e
--- /dev/null
+++ b/doc/user/admin_area/settings/email.md
@@ -0,0 +1,5 @@
+# Email
+
+## Custom logo
+
+The logo in the header of some emails can be customized, see the [logo customization section](../../../customization/branded_page_and_email_header.md).
diff --git a/doc/user/project/labels.md b/doc/user/project/labels.md
index dabffaec5fa..a89a1206170 100644
--- a/doc/user/project/labels.md
+++ b/doc/user/project/labels.md
@@ -9,7 +9,7 @@ Labels allow you to categorize issues or merge requests using descriptive titles
In GitLab, you can create project and group labels:
- **Project labels** can be assigned to issues or merge requests in that project only.
-- **Group labels** can be assigned to any issue or merge request of any project in that group.
+- **Group labels** can be assigned to any issue or merge request of any project in that group or subgroup.
- In the [future](https://gitlab.com/gitlab-org/gitlab-ce/issues/40915), you will be able to assign group labels to issues and merge reqeusts of projects in [subgroups](../group/subgroups/index.md).
## Creating labels
@@ -74,9 +74,9 @@ Every issue and merge request can be assigned any number of labels. The labels a
### Filtering in list pages
-From the project issue list page and the project merge request list page, you can [filter](../search/index.md#issues-and-merge-requests) by both group labels and project labels.
+From the project issue list page and the project merge request list page, you can [filter](../search/index.md#issues-and-merge-requests) by both group (including subgroup ancestors) labels and project labels.
-From the group issue list page and the group merge request list page, you can [filter](../search/index.md#issues-and-merge-requests) by both group labels and project labels.
+From the group issue list page and the group merge request list page, you can [filter](../search/index.md#issues-and-merge-requests) by both group labels (including subgroup ancestors and subgroup descendants) and project labels.
![Labels group issues](img/labels_group_issues.png)
diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md
index dedf102fc37..eb0ac221e30 100644
--- a/doc/user/project/settings/import_export.md
+++ b/doc/user/project/settings/import_export.md
@@ -57,11 +57,11 @@ The following items will be exported:
- Project configuration including web hooks and services
- Issues with comments, merge requests with diffs and comments, labels, milestones, snippets,
and other project entities
+- LFS objects
The following items will NOT be exported:
- Build traces and artifacts
-- LFS objects
- Container registry images
- CI variables
- Any encrypted tokens
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index e5ecd37e473..e35b1a0ff63 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -72,7 +72,7 @@ module API
class ProjectHook < Hook
expose :project_id, :issues_events, :confidential_issues_events
- expose :note_events, :pipeline_events, :wiki_page_events
+ expose :note_events, :confidential_note_events, :pipeline_events, :wiki_page_events
expose :job_events
end
@@ -794,7 +794,7 @@ module API
expose :id, :title, :created_at, :updated_at, :active
expose :push_events, :issues_events, :confidential_issues_events
expose :merge_requests_events, :tag_push_events, :note_events
- expose :pipeline_events, :wiki_page_events
+ expose :confidential_note_events, :pipeline_events, :wiki_page_events
expose :job_events
# Expose serialized properties
expose :properties do |service, options|
diff --git a/lib/api/features.rb b/lib/api/features.rb
index 9385c6ca174..11d848584d9 100644
--- a/lib/api/features.rb
+++ b/lib/api/features.rb
@@ -65,6 +65,13 @@ module API
present feature, with: Entities::Feature, current_user: current_user
end
+
+ desc 'Remove the gate value for the given feature'
+ delete ':name' do
+ Feature.get(params[:name]).remove
+
+ status 204
+ end
end
end
end
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index e59e8a45908..61c138a7dec 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -83,12 +83,13 @@ module API
end
def available_labels_for(label_parent)
- search_params =
- if label_parent.is_a?(Project)
- { project_id: label_parent.id }
- else
- { group_id: label_parent.id, only_group_labels: true }
- end
+ search_params = { include_ancestor_groups: true }
+
+ if label_parent.is_a?(Project)
+ search_params[:project_id] = label_parent.id
+ else
+ search_params.merge!(group_id: label_parent.id, only_group_labels: true)
+ end
LabelsFinder.new(current_user, search_params).execute
end
diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb
index f82241058e5..68921ae439b 100644
--- a/lib/api/project_hooks.rb
+++ b/lib/api/project_hooks.rb
@@ -14,6 +14,7 @@ module API
optional :merge_requests_events, type: Boolean, desc: "Trigger hook on merge request events"
optional :tag_push_events, type: Boolean, desc: "Trigger hook on tag push events"
optional :note_events, type: Boolean, desc: "Trigger hook on note(comment) events"
+ optional :confidential_note_events, type: Boolean, desc: "Trigger hook on confidential note(comment) events"
optional :job_events, type: Boolean, desc: "Trigger hook on job events"
optional :pipeline_events, type: Boolean, desc: "Trigger hook on pipeline events"
optional :wiki_page_events, type: Boolean, desc: "Trigger hook on wiki events"
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb
index c9e3f8ce42b..c3a03f13306 100644
--- a/lib/banzai/filter/abstract_reference_filter.rb
+++ b/lib/banzai/filter/abstract_reference_filter.rb
@@ -171,7 +171,7 @@ module Banzai
end
if object
- title = object_link_title(object)
+ title = object_link_title(object, matches)
klass = reference_class(object_sym)
data = data_attributes_for(link_content || match, parent, object,
@@ -216,7 +216,7 @@ module Banzai
extras
end
- def object_link_title(object)
+ def object_link_title(object, matches)
object.title
end
diff --git a/lib/banzai/filter/commit_range_reference_filter.rb b/lib/banzai/filter/commit_range_reference_filter.rb
index 21bcb1c5ca8..99fa2d9d8fb 100644
--- a/lib/banzai/filter/commit_range_reference_filter.rb
+++ b/lib/banzai/filter/commit_range_reference_filter.rb
@@ -34,7 +34,7 @@ module Banzai
range.to_param.merge(only_path: context[:only_path]))
end
- def object_link_title(range)
+ def object_link_title(range, matches)
nil
end
end
diff --git a/lib/banzai/filter/commit_trailers_filter.rb b/lib/banzai/filter/commit_trailers_filter.rb
new file mode 100644
index 00000000000..ef16df1f3ae
--- /dev/null
+++ b/lib/banzai/filter/commit_trailers_filter.rb
@@ -0,0 +1,152 @@
+module Banzai
+ module Filter
+ # HTML filter that replaces users' names and emails in commit trailers
+ # with links to their GitLab accounts or mailto links to their mentioned
+ # emails.
+ #
+ # Commit trailers are special labels in the form of `*-by:` and fall on a
+ # single line, ex:
+ #
+ # Reported-By: John S. Doe <john.doe@foo.bar>
+ #
+ # More info about this can be found here:
+ # * https://git.wiki.kernel.org/index.php/CommitMessageConventions
+ class CommitTrailersFilter < HTML::Pipeline::Filter
+ include ActionView::Helpers::TagHelper
+ include ApplicationHelper
+ include AvatarsHelper
+
+ TRAILER_REGEXP = /(?<label>[[:alpha:]-]+-by:)/i.freeze
+ AUTHOR_REGEXP = /(?<author_name>.+)/.freeze
+ # Devise.email_regexp wouldn't work here since its designed to match
+ # against strings that only contains email addresses; the \A and \z
+ # around the expression will only match if the string being matched
+ # contains just the email nothing else.
+ MAIL_REGEXP = /&lt;(?<author_email>[^@\s]+@[^@\s]+)&gt;/.freeze
+ FILTER_REGEXP = /(?<trailer>^\s*#{TRAILER_REGEXP}\s*#{AUTHOR_REGEXP}\s+#{MAIL_REGEXP}$)/mi.freeze
+
+ def call
+ doc.xpath('descendant-or-self::text()').each do |node|
+ content = node.to_html
+
+ next unless content.match(FILTER_REGEXP)
+
+ html = trailer_filter(content)
+
+ next if html == content
+
+ node.replace(html)
+ end
+
+ doc
+ end
+
+ private
+
+ # Replace trailer lines with links to GitLab users or mailto links to
+ # non GitLab users.
+ #
+ # text - String text to replace trailers in.
+ #
+ # Returns a String with all trailer lines replaced with links to GitLab
+ # users and mailto links to non GitLab users. All links have `data-trailer`
+ # and `data-user` attributes attached.
+ def trailer_filter(text)
+ text.gsub(FILTER_REGEXP) do |author_match|
+ label = $~[:label]
+ "#{label} #{parse_user($~[:author_name], $~[:author_email], label)}"
+ end
+ end
+
+ # Find a GitLab user using the supplied email and generate
+ # a valid link to them, otherwise, generate a mailto link.
+ #
+ # name - String name used in the commit message for the user
+ # email - String email used in the commit message for the user
+ # trailer - String trailer used in the commit message
+ #
+ # Returns a String with a link to the user.
+ def parse_user(name, email, trailer)
+ link_to_user User.find_by_any_email(email),
+ name: name,
+ email: email,
+ trailer: trailer
+ end
+
+ def urls
+ Gitlab::Routing.url_helpers
+ end
+
+ def link_to_user(user, name:, email:, trailer:)
+ wrapper = link_wrapper(data: {
+ trailer: trailer,
+ user: user.try(:id)
+ })
+
+ avatar = user_avatar_without_link(
+ user: user,
+ user_email: email,
+ css_class: 'avatar-inline',
+ has_tooltip: false
+ )
+
+ link_href = user.nil? ? "mailto:#{email}" : urls.user_url(user)
+
+ avatar_link = link_tag(
+ link_href,
+ content: avatar,
+ title: email
+ )
+
+ name_link = link_tag(
+ link_href,
+ content: name,
+ title: email
+ )
+
+ email_link = link_tag(
+ "mailto:#{email}",
+ content: email,
+ title: email
+ )
+
+ wrapper << "#{avatar_link}#{name_link} <#{email_link}>"
+ end
+
+ def link_wrapper(data: {})
+ data_attributes = data_attributes_from_hash(data)
+
+ doc.document.create_element(
+ 'span',
+ data_attributes
+ )
+ end
+
+ def link_tag(url, title: "", content: "", data: {})
+ data_attributes = data_attributes_from_hash(data)
+
+ attributes = data_attributes.merge(
+ href: url,
+ title: title
+ )
+
+ link = doc.document.create_element('a', attributes)
+
+ if content.html_safe?
+ link << content
+ else
+ link.content = content # make sure we escape content using nokogiri's #content=
+ end
+
+ link
+ end
+
+ def data_attributes_from_hash(data = {})
+ data.reject! {|_, value| value.nil?}
+ data.map do |key, value|
+ [%(data-#{key.to_s.dasherize}), value]
+ end.to_h
+ end
+ end
+ end
+end
diff --git a/lib/banzai/filter/label_reference_filter.rb b/lib/banzai/filter/label_reference_filter.rb
index d5360ad8f68..faa5b344e6f 100644
--- a/lib/banzai/filter/label_reference_filter.rb
+++ b/lib/banzai/filter/label_reference_filter.rb
@@ -41,7 +41,7 @@ module Banzai
end
def find_labels(project)
- LabelsFinder.new(nil, project_id: project.id).execute(skip_authorization: true)
+ LabelsFinder.new(nil, project_id: project.id, include_ancestor_groups: true).execute(skip_authorization: true)
end
# Parameters to pass to `Label.find_by` based on the given arguments
@@ -77,7 +77,7 @@ module Banzai
CGI.unescapeHTML(text.to_s)
end
- def object_link_title(object)
+ def object_link_title(object, matches)
# use title of wrapped element instead
nil
end
diff --git a/lib/banzai/filter/merge_request_reference_filter.rb b/lib/banzai/filter/merge_request_reference_filter.rb
index b3cfa97d0e0..5cbdb01c130 100644
--- a/lib/banzai/filter/merge_request_reference_filter.rb
+++ b/lib/banzai/filter/merge_request_reference_filter.rb
@@ -17,10 +17,19 @@ module Banzai
only_path: context[:only_path])
end
+ def object_link_title(object, matches)
+ object_link_commit_title(object, matches) || super
+ end
+
def object_link_text_extras(object, matches)
extras = super
+ if commit_ref = object_link_commit_ref(object, matches)
+ return extras.unshift(commit_ref)
+ end
+
path = matches[:path] if matches.names.include?("path")
+
case path
when '/diffs'
extras.unshift "diffs"
@@ -38,6 +47,36 @@ module Banzai
.where(iid: ids.to_a)
.includes(target_project: :namespace)
end
+
+ private
+
+ def object_link_commit_title(object, matches)
+ object_link_commit(object, matches)&.title
+ end
+
+ def object_link_commit_ref(object, matches)
+ object_link_commit(object, matches)&.short_id
+ end
+
+ def object_link_commit(object, matches)
+ return unless matches.names.include?('query') && query = matches[:query]
+
+ # Removes leading "?". CGI.parse expects "arg1&arg2&arg3"
+ params = CGI.parse(query.sub(/^\?/, ''))
+
+ return unless commit_sha = params['commit_id']&.first
+
+ if commit = find_commit_by_sha(object, commit_sha)
+ Commit.from_hash(commit.to_hash, object.project)
+ end
+ end
+
+ def find_commit_by_sha(object, commit_sha)
+ @all_commits ||= {}
+ @all_commits[object.id] ||= object.all_commits
+
+ @all_commits[object.id].find { |commit| commit.sha == commit_sha }
+ end
end
end
end
diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb
index 8ec696ce5fc..1a1d7dbeb3d 100644
--- a/lib/banzai/filter/milestone_reference_filter.rb
+++ b/lib/banzai/filter/milestone_reference_filter.rb
@@ -84,7 +84,7 @@ module Banzai
end
end
- def object_link_title(object)
+ def object_link_title(object, matches)
nil
end
end
diff --git a/lib/banzai/pipeline/commit_description_pipeline.rb b/lib/banzai/pipeline/commit_description_pipeline.rb
new file mode 100644
index 00000000000..607c2731ed3
--- /dev/null
+++ b/lib/banzai/pipeline/commit_description_pipeline.rb
@@ -0,0 +1,11 @@
+module Banzai
+ module Pipeline
+ class CommitDescriptionPipeline < SingleLinePipeline
+ def self.filters
+ @filters ||= super.concat FilterArray[
+ Filter::CommitTrailersFilter,
+ ]
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb
new file mode 100644
index 00000000000..e5e8837221e
--- /dev/null
+++ b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ # Ensures services which previously recieved all notes events continue
+ # to recieve confidential ones.
+ class SetConfidentialNoteEventsOnServices
+ class Service < ActiveRecord::Base
+ self.table_name = 'services'
+
+ include ::EachBatch
+
+ def self.services_to_update
+ where(confidential_note_events: nil, note_events: true)
+ end
+ end
+
+ def perform(start_id, stop_id)
+ Service.services_to_update
+ .where(id: start_id..stop_id)
+ .update_all(confidential_note_events: true)
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb
new file mode 100644
index 00000000000..171c8ef21b7
--- /dev/null
+++ b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+# rubocop:disable Style/Documentation
+
+module Gitlab
+ module BackgroundMigration
+ # Ensures hooks which previously recieved all notes events continue
+ # to recieve confidential ones.
+ class SetConfidentialNoteEventsOnWebhooks
+ class WebHook < ActiveRecord::Base
+ self.table_name = 'web_hooks'
+
+ include ::EachBatch
+
+ def self.hooks_to_update
+ where(confidential_note_events: nil, note_events: true)
+ end
+ end
+
+ def perform(start_id, stop_id)
+ WebHook.hooks_to_update
+ .where(id: start_id..stop_id)
+ .update_all(confidential_note_events: true)
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/checks/lfs_integrity.rb b/lib/gitlab/checks/lfs_integrity.rb
index f7276a380dc..f0e5773ec3c 100644
--- a/lib/gitlab/checks/lfs_integrity.rb
+++ b/lib/gitlab/checks/lfs_integrity.rb
@@ -15,8 +15,7 @@ module Gitlab
return false unless new_lfs_pointers.present?
- existing_count = @project.lfs_storage_project
- .lfs_objects
+ existing_count = @project.all_lfs_objects
.where(oid: new_lfs_pointers.map(&:lfs_oid))
.count
diff --git a/lib/gitlab/data_builder/note.rb b/lib/gitlab/data_builder/note.rb
index 50fea1232af..f573368e572 100644
--- a/lib/gitlab/data_builder/note.rb
+++ b/lib/gitlab/data_builder/note.rb
@@ -9,6 +9,7 @@ module Gitlab
#
# data = {
# object_kind: "note",
+ # event_type: "confidential_note",
# user: {
# name: String,
# username: String,
@@ -51,8 +52,11 @@ module Gitlab
end
def build_base_data(project, user, note)
+ event_type = note.confidential? ? 'confidential_note' : 'note'
+
base_data = {
object_kind: "note",
+ event_type: event_type,
user: user.hook_attrs,
project_id: project.id,
project: project.hook_attrs,
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 1634fe4e9cb..77079e5e72b 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -860,7 +860,7 @@ into similar problems in the future (e.g. when new tables are created).
# Each job is scheduled with a `delay_interval` in between.
# If you use a small interval, then some jobs may run at the same time.
#
- # model_class - The table being iterated over
+ # model_class - The table or relation being iterated over
# job_class_name - The background migration job class as a string
# delay_interval - The duration between each job's scheduled time (must respond to `to_f`)
# batch_size - The maximum number of rows per job
diff --git a/lib/gitlab/diff/inline_diff_marker.rb b/lib/gitlab/diff/inline_diff_marker.rb
index 010b4be7b40..81e91ea0ab7 100644
--- a/lib/gitlab/diff/inline_diff_marker.rb
+++ b/lib/gitlab/diff/inline_diff_marker.rb
@@ -1,11 +1,14 @@
module Gitlab
module Diff
class InlineDiffMarker < Gitlab::StringRangeMarker
+ def initialize(line, rich_line = nil)
+ super(line, rich_line || line)
+ end
+
def mark(line_inline_diffs, mode: nil)
- mark = super(line_inline_diffs) do |text, left:, right:|
+ super(line_inline_diffs) do |text, left:, right:|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
end
- mark.html_safe
end
private
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 93037ed8d90..0fb82441bf8 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -231,7 +231,8 @@ module Gitlab
# relation to each other. The last 10 commits for a branch for example,
# should go through .where
def batch_by_oid(repo, oids)
- repo.gitaly_migrate(:list_commits_by_oid) do |is_enabled|
+ repo.gitaly_migrate(:list_commits_by_oid,
+ status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
repo.gitaly_commit_client.list_commits_by_oid(oids)
else
diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb
index 24f027d8da4..7c201c6169b 100644
--- a/lib/gitlab/git/hook.rb
+++ b/lib/gitlab/git/hook.rb
@@ -95,13 +95,13 @@ module Gitlab
args = [ref, oldrev, newrev]
stdout, stderr, status = Open3.capture3(env, path, *args, options)
- [status.success?, (stderr.presence || stdout).gsub(/\R/, "<br>").html_safe]
+ [status.success?, Gitlab::Utils.nlbr(stderr.presence || stdout)]
end
def retrieve_error_message(stderr, stdout)
err_message = stderr.read
err_message = err_message.blank? ? stdout.read : err_message
- err_message.gsub(/\R/, "<br>").html_safe
+ Gitlab::Utils.nlbr(err_message)
end
end
end
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index d16a096ffb9..8d97bfb0e6a 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -885,7 +885,8 @@ module Gitlab
end
def delete_refs(*ref_names)
- gitaly_migrate(:delete_refs) do |is_enabled|
+ gitaly_migrate(:delete_refs,
+ status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled|
if is_enabled
gitaly_delete_refs(*ref_names)
else
diff --git a/lib/gitlab/hook_data/issuable_builder.rb b/lib/gitlab/hook_data/issuable_builder.rb
index 4febb0ab430..6ab36676127 100644
--- a/lib/gitlab/hook_data/issuable_builder.rb
+++ b/lib/gitlab/hook_data/issuable_builder.rb
@@ -11,7 +11,8 @@ module Gitlab
def build(user: nil, changes: {})
hook_data = {
- object_kind: issuable.class.name.underscore,
+ object_kind: object_kind,
+ event_type: event_type,
user: user.hook_attrs,
project: issuable.project.hook_attrs,
object_attributes: issuable.hook_attrs,
@@ -36,6 +37,18 @@ module Gitlab
private
+ def object_kind
+ issuable.class.name.underscore
+ end
+
+ def event_type
+ if issuable.try(:confidential?)
+ "confidential_#{object_kind}"
+ else
+ object_kind
+ end
+ end
+
def issuable_builder
case issuable
when Issue
diff --git a/lib/gitlab/import_export/importer.rb b/lib/gitlab/import_export/importer.rb
index c38df9102eb..c490bf059d2 100644
--- a/lib/gitlab/import_export/importer.rb
+++ b/lib/gitlab/import_export/importer.rb
@@ -13,7 +13,7 @@ module Gitlab
end
def execute
- if import_file && check_version! && [repo_restorer, wiki_restorer, project_tree, avatar_restorer, uploads_restorer].all?(&:restore)
+ if import_file && check_version! && restorers.all?(&:restore)
project_tree.restored_project
else
raise Projects::ImportService::Error.new(@shared.errors.join(', '))
@@ -24,6 +24,11 @@ module Gitlab
private
+ def restorers
+ [repo_restorer, wiki_restorer, project_tree, avatar_restorer,
+ uploads_restorer, lfs_restorer]
+ end
+
def import_file
Gitlab::ImportExport::FileImporter.import(archive_file: @archive_file,
shared: @shared)
@@ -60,6 +65,10 @@ module Gitlab
Gitlab::ImportExport::UploadsRestorer.new(project: project_tree.restored_project, shared: @shared)
end
+ def lfs_restorer
+ Gitlab::ImportExport::LfsRestorer.new(project: project_tree.restored_project, shared: @shared)
+ end
+
def path_with_namespace
File.join(@project.namespace.full_path, @project.path)
end
diff --git a/lib/gitlab/import_export/lfs_restorer.rb b/lib/gitlab/import_export/lfs_restorer.rb
new file mode 100644
index 00000000000..b28c3c161b7
--- /dev/null
+++ b/lib/gitlab/import_export/lfs_restorer.rb
@@ -0,0 +1,43 @@
+module Gitlab
+ module ImportExport
+ class LfsRestorer
+ def initialize(project:, shared:)
+ @project = project
+ @shared = shared
+ end
+
+ def restore
+ return true if lfs_file_paths.empty?
+
+ lfs_file_paths.each do |file_path|
+ link_or_create_lfs_object!(file_path)
+ end
+
+ true
+ rescue => e
+ @shared.error(e)
+ false
+ end
+
+ private
+
+ def link_or_create_lfs_object!(path)
+ size = File.size(path)
+ oid = LfsObject.calculate_oid(path)
+
+ lfs_object = LfsObject.find_or_initialize_by(oid: oid, size: size)
+ lfs_object.file = File.open(path) unless lfs_object.file&.exists?
+
+ @project.all_lfs_objects << lfs_object
+ end
+
+ def lfs_file_paths
+ @lfs_file_paths ||= Dir.glob("#{lfs_storage_path}/*")
+ end
+
+ def lfs_storage_path
+ File.join(@shared.export_path, 'lfs-objects')
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/import_export/lfs_saver.rb b/lib/gitlab/import_export/lfs_saver.rb
new file mode 100644
index 00000000000..29410e2331c
--- /dev/null
+++ b/lib/gitlab/import_export/lfs_saver.rb
@@ -0,0 +1,55 @@
+module Gitlab
+ module ImportExport
+ class LfsSaver
+ include Gitlab::ImportExport::CommandLineUtil
+
+ def initialize(project:, shared:)
+ @project = project
+ @shared = shared
+ end
+
+ def save
+ @project.all_lfs_objects.each do |lfs_object|
+ save_lfs_object(lfs_object)
+ end
+
+ true
+ rescue => e
+ @shared.error(e)
+
+ false
+ end
+
+ private
+
+ def save_lfs_object(lfs_object)
+ if lfs_object.local_store?
+ copy_file_for_lfs_object(lfs_object)
+ else
+ download_file_for_lfs_object(lfs_object)
+ end
+ end
+
+ def download_file_for_lfs_object(lfs_object)
+ destination = destination_path_for_object(lfs_object)
+ mkdir_p(File.dirname(destination))
+
+ File.open(destination, 'w') do |file|
+ IO.copy_stream(URI.parse(lfs_object.file.url).open, file)
+ end
+ end
+
+ def copy_file_for_lfs_object(lfs_object)
+ copy_files(lfs_object.file.path, destination_path_for_object(lfs_object))
+ end
+
+ def destination_path_for_object(lfs_object)
+ File.join(lfs_export_path, lfs_object.oid)
+ end
+
+ def lfs_export_path
+ File.join(@shared.export_path, 'lfs-objects')
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/sidekiq_logging/json_formatter.rb b/lib/gitlab/sidekiq_logging/json_formatter.rb
new file mode 100644
index 00000000000..98f8222fd03
--- /dev/null
+++ b/lib/gitlab/sidekiq_logging/json_formatter.rb
@@ -0,0 +1,21 @@
+module Gitlab
+ module SidekiqLogging
+ class JSONFormatter
+ def call(severity, timestamp, progname, data)
+ output = {
+ severity: severity,
+ time: timestamp.utc.iso8601(3)
+ }
+
+ case data
+ when String
+ output[:message] = data
+ when Hash
+ output.merge!(data)
+ end
+
+ output.to_json + "\n"
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/sidekiq_logging/structured_logger.rb b/lib/gitlab/sidekiq_logging/structured_logger.rb
new file mode 100644
index 00000000000..9a89ae70b98
--- /dev/null
+++ b/lib/gitlab/sidekiq_logging/structured_logger.rb
@@ -0,0 +1,96 @@
+module Gitlab
+ module SidekiqLogging
+ class StructuredLogger
+ START_TIMESTAMP_FIELDS = %w[created_at enqueued_at].freeze
+ DONE_TIMESTAMP_FIELDS = %w[started_at retried_at failed_at completed_at].freeze
+
+ def call(job, queue)
+ started_at = current_time
+ base_payload = parse_job(job)
+
+ Sidekiq.logger.info log_job_start(started_at, base_payload)
+
+ yield
+
+ Sidekiq.logger.info log_job_done(started_at, base_payload)
+ rescue => job_exception
+ Sidekiq.logger.warn log_job_done(started_at, base_payload, job_exception)
+
+ raise
+ end
+
+ private
+
+ def base_message(payload)
+ "#{payload['class']} JID-#{payload['jid']}"
+ end
+
+ def log_job_start(started_at, payload)
+ payload['message'] = "#{base_message(payload)}: start"
+ payload['job_status'] = 'start'
+
+ payload
+ end
+
+ def log_job_done(started_at, payload, job_exception = nil)
+ payload = payload.dup
+ payload['duration'] = elapsed(started_at)
+ payload['completed_at'] = Time.now.utc
+
+ message = base_message(payload)
+
+ if job_exception
+ payload['message'] = "#{message}: fail: #{payload['duration']} sec"
+ payload['job_status'] = 'fail'
+ payload['error_message'] = job_exception.message
+ payload['error'] = job_exception.class
+ payload['error_backtrace'] = backtrace_cleaner.clean(job_exception.backtrace)
+ else
+ payload['message'] = "#{message}: done: #{payload['duration']} sec"
+ payload['job_status'] = 'done'
+ end
+
+ convert_to_iso8601(payload, DONE_TIMESTAMP_FIELDS)
+
+ payload
+ end
+
+ def parse_job(job)
+ job = job.dup
+
+ # Add process id params
+ job['pid'] = ::Process.pid
+
+ job.delete('args') unless ENV['SIDEKIQ_LOG_ARGUMENTS']
+
+ convert_to_iso8601(job, START_TIMESTAMP_FIELDS)
+
+ job
+ end
+
+ def convert_to_iso8601(payload, keys)
+ keys.each do |key|
+ payload[key] = format_time(payload[key]) if payload[key]
+ end
+ end
+
+ def elapsed(start)
+ (current_time - start).round(3)
+ end
+
+ def current_time
+ Gitlab::Metrics::System.monotonic_time
+ end
+
+ def backtrace_cleaner
+ @backtrace_cleaner ||= ActiveSupport::BacktraceCleaner.new
+ end
+
+ def format_time(timestamp)
+ return timestamp if timestamp.is_a?(String)
+
+ Time.at(timestamp).utc.iso8601(3)
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index dc9391f32cf..b0a492eaa58 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -27,6 +27,11 @@ module Gitlab
.gsub(/(\A-+|-+\z)/, '')
end
+ # Converts newlines into HTML line break elements
+ def nlbr(str)
+ ActionView::Base.full_sanitizer.sanitize(str, tags: []).gsub(/\r?\n/, '<br>').html_safe
+ end
+
def remove_line_breaks(str)
str.gsub(/\r?\n/, '')
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 68d0c0c8854..d7eb123b48b 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: 2018-03-27 14:40+0300\n"
-"PO-Revision-Date: 2018-03-27 14:40+0300\n"
+"POT-Creation-Date: 2018-04-04 18:02+0200\n"
+"PO-Revision-Date: 2018-04-04 18:02+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
@@ -133,6 +133,9 @@ msgstr ""
msgid "Abuse Reports"
msgstr ""
+msgid "Abuse reports"
+msgstr ""
+
msgid "Access Tokens"
msgstr ""
@@ -142,6 +145,9 @@ msgstr ""
msgid "Account"
msgstr ""
+msgid "Account and limit settings"
+msgstr ""
+
msgid "Active"
msgstr ""
@@ -235,6 +241,9 @@ msgstr ""
msgid "Allow edits from maintainers."
msgstr ""
+msgid "Allow requests to the local network from hooks and services."
+msgstr ""
+
msgid "Allows you to add and manage Kubernetes clusters."
msgstr ""
@@ -343,6 +352,12 @@ msgstr ""
msgid "Assign to"
msgstr ""
+msgid "Assigned Issues"
+msgstr ""
+
+msgid "Assigned Merge Requests"
+msgstr ""
+
msgid "Assigned to :name"
msgstr ""
@@ -370,6 +385,9 @@ msgstr ""
msgid "Auto DevOps enabled"
msgstr ""
+msgid "Auto DevOps, runners and job artifacts"
+msgstr ""
+
msgid "Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly."
msgstr ""
@@ -412,6 +430,9 @@ msgstr ""
msgid "Average per day: %{average}"
msgstr ""
+msgid "Background jobs"
+msgstr ""
+
msgid "Begin with the selected commit"
msgstr ""
@@ -1102,6 +1123,9 @@ msgstr ""
msgid "Compare changes with the last commit"
msgstr ""
+msgid "Compare changes with the merge request target branch"
+msgstr ""
+
msgid "CompareBranches|%{source_branch} and %{target_branch} are the same."
msgstr ""
@@ -1123,6 +1147,21 @@ msgstr ""
msgid "Confidentiality"
msgstr ""
+msgid "Configure Sidekiq job throttling."
+msgstr ""
+
+msgid "Configure automatic git checks and housekeeping on repositories."
+msgstr ""
+
+msgid "Configure limits for web and API requests."
+msgstr ""
+
+msgid "Configure storage path and circuit breaker settings."
+msgstr ""
+
+msgid "Configure the way a user creates a new account."
+msgstr ""
+
msgid "Connect"
msgstr ""
@@ -1174,6 +1213,9 @@ msgstr ""
msgid "ContainerRegistry|With the Docker Container Registry integrated into GitLab, every project can have its own space to store its Docker images."
msgstr ""
+msgid "Continuous Integration and Deployment"
+msgstr ""
+
msgid "Contribution"
msgstr ""
@@ -1419,6 +1461,21 @@ msgstr ""
msgid "Enable Auto DevOps"
msgstr ""
+msgid "Enable Sentry for error reporting and logging."
+msgstr ""
+
+msgid "Enable and configure InfluxDB metrics."
+msgstr ""
+
+msgid "Enable and configure Prometheus metrics."
+msgstr ""
+
+msgid "Enable reCAPTCHA or Akismet and set IP limits."
+msgstr ""
+
+msgid "Enable the Performance Bar for a given group."
+msgstr ""
+
msgid "Environments|An error occurred while fetching the environments."
msgstr ""
@@ -1467,6 +1524,9 @@ msgstr ""
msgid "Environments|You don't have any environments right now."
msgstr ""
+msgid "Error Reporting and Logging"
+msgstr ""
+
msgid "Error checking branch data. Please try again."
msgstr ""
@@ -1637,6 +1697,9 @@ msgstr ""
msgid "GitHub import"
msgstr ""
+msgid "GitLab CI Linter has been moved"
+msgstr ""
+
msgid "GitLab Runner section"
msgstr ""
@@ -1742,6 +1805,12 @@ msgstr ""
msgid "Help"
msgstr ""
+msgid "Help page"
+msgstr ""
+
+msgid "Help page text and support page url."
+msgstr ""
+
msgid "Hide value"
msgid_plural "Hide values"
msgstr[0] ""
@@ -1879,10 +1948,10 @@ msgstr ""
msgid "Labels can be applied to issues and merge requests to categorize them."
msgstr ""
-msgid "Labels|Promote Label"
+msgid "Labels|<span>Promote label</span> %{labelTitle} <span>to Group Label?</span>"
msgstr ""
-msgid "Labels|Promote label %{labelTitle} to Group Label?"
+msgid "Labels|Promote Label"
msgstr ""
msgid "Last %d day"
@@ -1950,9 +2019,6 @@ msgstr ""
msgid "Lock %{issuableDisplayName}"
msgstr ""
-msgid "Lock this %{issuableDisplayName}? Only <strong>project members</strong> will be able to comment."
-msgstr ""
-
msgid "Locked"
msgstr ""
@@ -2010,6 +2076,12 @@ msgstr ""
msgid "Messages"
msgstr ""
+msgid "Metrics - Influx"
+msgstr ""
+
+msgid "Metrics - Prometheus"
+msgstr ""
+
msgid "Milestone"
msgstr ""
@@ -2264,12 +2336,18 @@ msgstr ""
msgid "Otherwise it is recommended you start with one of the options below."
msgstr ""
+msgid "Outbound requests"
+msgstr ""
+
msgid "Overview"
msgstr ""
msgid "Owner"
msgstr ""
+msgid "Pages"
+msgstr ""
+
msgid "Pagination|Last »"
msgstr ""
@@ -2282,6 +2360,9 @@ msgstr ""
msgid "Pagination|« First"
msgstr ""
+msgid "Part of merge request changes"
+msgstr ""
+
msgid "Password"
msgstr ""
@@ -2492,6 +2573,9 @@ msgstr ""
msgid "Profiles|your account"
msgstr ""
+msgid "Profiling - Performance bar"
+msgstr ""
+
msgid "Programming languages used in this repository"
msgstr ""
@@ -2723,6 +2807,12 @@ msgstr ""
msgid "Repository"
msgstr ""
+msgid "Repository maintenance"
+msgstr ""
+
+msgid "Repository storage"
+msgstr ""
+
msgid "Request Access"
msgstr ""
@@ -2752,6 +2842,9 @@ msgstr ""
msgid "Reviewing"
msgstr ""
+msgid "Reviewing (merge request !%{mergeRequestId})"
+msgstr ""
+
msgid "Runners"
msgstr ""
@@ -2839,9 +2932,21 @@ msgstr ""
msgid "Service Templates"
msgstr ""
+msgid "Session expiration, projects limit and attachment size."
+msgstr ""
+
msgid "Set a password on your account to pull or push via %{protocol}."
msgstr ""
+msgid "Set default and restrict visibility levels. Configure import sources and git access protocol."
+msgstr ""
+
+msgid "Set notification email for abuse reports."
+msgstr ""
+
+msgid "Set requirements for a user to sign-in. Enable mandatory two-factor authentication."
+msgstr ""
+
msgid "Set up CI/CD"
msgstr ""
@@ -2871,19 +2976,22 @@ msgid_plural "Showing %d events"
msgstr[0] ""
msgstr[1] ""
-msgid "Snippets"
+msgid "Sign-in restrictions"
msgstr ""
-msgid "Something went wrong on our end"
+msgid "Sign-up restrictions"
msgstr ""
-msgid "Something went wrong on our end."
+msgid "Size and domain settings for static websites"
+msgstr ""
+
+msgid "Snippets"
msgstr ""
-msgid "Something went wrong trying to change the confidentiality of this issue"
+msgid "Something went wrong on our end"
msgstr ""
-msgid "Something went wrong trying to change the locked state of this ${this.issuableDisplayName}"
+msgid "Something went wrong on our end."
msgstr ""
msgid "Something went wrong when toggling the button"
@@ -3003,12 +3111,21 @@ msgstr ""
msgid "Spam Logs"
msgstr ""
+msgid "Spam and Anti-bot Protection"
+msgstr ""
+
msgid "Specify the following URL during the Runner setup:"
msgstr ""
msgid "StarProject|Star"
msgstr ""
+msgid "Starred Projects"
+msgstr ""
+
+msgid "Starred Projects' Activity"
+msgstr ""
+
msgid "Starred projects"
msgstr ""
@@ -3456,6 +3573,9 @@ msgstr ""
msgid "To import an SVN repository, check out %{svn_link}."
msgstr ""
+msgid "To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button."
+msgstr ""
+
msgid "Todo"
msgstr ""
@@ -3486,9 +3606,6 @@ msgstr ""
msgid "Unlock"
msgstr ""
-msgid "Unlock this %{issuableDisplayName}? <strong>Everyone</strong> will be able to comment."
-msgstr ""
-
msgid "Unlocked"
msgstr ""
@@ -3522,6 +3639,9 @@ msgstr ""
msgid "Use your global notification setting"
msgstr ""
+msgid "User and IP Rate Limits"
+msgstr ""
+
msgid "Variables are applied to environments via the runner. They can be protected by only exposing them to protected branches or tags. You can use variables for passwords, secret keys, or whatever you want."
msgstr ""
@@ -3546,6 +3666,9 @@ msgstr ""
msgid "View replaced file @ "
msgstr ""
+msgid "Visibility and access controls"
+msgstr ""
+
msgid "VisibilityLevel|Internal"
msgstr ""
@@ -3762,9 +3885,21 @@ msgstr ""
msgid "You're receiving this email because of your account on %{host}. %{manage_notifications_link} &middot; %{help_link}"
msgstr ""
+msgid "Your Groups"
+msgstr ""
+
msgid "Your Kubernetes cluster information on this page is still editable, but you are advised to disable and reconfigure"
msgstr ""
+msgid "Your Projects (default)"
+msgstr ""
+
+msgid "Your Projects' Activity"
+msgstr ""
+
+msgid "Your Todos"
+msgstr ""
+
msgid "Your changes can be committed to %{branch_name} because a merge request is open."
msgstr ""
@@ -3795,12 +3930,6 @@ msgstr ""
msgid "command line instructions"
msgstr ""
-msgid "confidentiality|You are going to turn off the confidentiality. This means <strong>everyone</strong> will be able to see and leave a comment on this issue."
-msgstr ""
-
-msgid "confidentiality|You are going to turn on the confidentiality. This means that only team members with <strong>at least Reporter access</strong> are able to see and leave comments on the issue."
-msgstr ""
-
msgid "connecting"
msgstr ""
@@ -3823,6 +3952,15 @@ msgstr[1] ""
msgid "mrWidget| Please restore it or use a different %{missingBranchName} branch"
msgstr ""
+msgid "mrWidget|%{metricsLinkStart} Memory %{metricsLinkEnd} usage %{emphasisStart} decreased %{emphasisEnd} from %{memoryFrom}MB to %{memoryTo}MB"
+msgstr ""
+
+msgid "mrWidget|%{metricsLinkStart} Memory %{metricsLinkEnd} usage %{emphasisStart} increased %{emphasisEnd} from %{memoryFrom}MB to %{memoryTo}MB"
+msgstr ""
+
+msgid "mrWidget|%{metricsLinkStart} Memory %{metricsLinkEnd} usage is %{emphasisStart} unchanged %{emphasisEnd} at %{memoryFrom}MB"
+msgstr ""
+
msgid "mrWidget|Allows edits from maintainers"
msgstr ""
@@ -3850,18 +3988,27 @@ msgstr ""
msgid "mrWidget|Closes"
msgstr ""
+msgid "mrWidget|Deployment statistics are not available currently"
+msgstr ""
+
msgid "mrWidget|Did not close"
msgstr ""
msgid "mrWidget|Email patches"
msgstr ""
+msgid "mrWidget|Failed to load deployment statistics"
+msgstr ""
+
msgid "mrWidget|If the %{branch} branch exists in your local repository, you can merge this merge request manually using the"
msgstr ""
msgid "mrWidget|If the %{missingBranchName} branch exists in your local repository, you can merge this merge request manually using the command line"
msgstr ""
+msgid "mrWidget|Loading deployment statistics"
+msgstr ""
+
msgid "mrWidget|Mentions"
msgstr ""
@@ -3943,6 +4090,9 @@ msgstr ""
msgid "mrWidget|This project is archived, write access has been disabled"
msgstr ""
+msgid "mrWidget|Web IDE"
+msgstr ""
+
msgid "mrWidget|You can merge this merge request manually using the"
msgstr ""
diff --git a/spec/factories/ci/build_metadata.rb b/spec/factories/ci/build_metadata.rb
deleted file mode 100644
index 66bbd977b88..00000000000
--- a/spec/factories/ci/build_metadata.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-FactoryBot.define do
- factory :ci_build_metadata, class: Ci::BuildMetadata do
- build factory: :ci_build
-
- after(:build) do |build_metadata, _|
- build_metadata.project ||= build_metadata.build.project
- end
- end
-end
diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb
index 493b7bc021c..a448d565e4b 100644
--- a/spec/factories/project_hooks.rb
+++ b/spec/factories/project_hooks.rb
@@ -15,6 +15,7 @@ FactoryBot.define do
issues_events true
confidential_issues_events true
note_events true
+ confidential_note_events true
job_events true
pipeline_events true
wiki_page_events true
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 3005d74c3cf..846b8040be6 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -123,7 +123,7 @@ feature 'Admin updates settings' do
scenario 'Change Performance bar settings' do
group = create(:group)
- page.within('.as-performance') do
+ page.within('.as-performance-bar') do
check 'Enable the Performance Bar'
fill_in 'Allowed group', with: group.path
click_on 'Save changes'
@@ -133,7 +133,7 @@ feature 'Admin updates settings' do
expect(find_field('Enable the Performance Bar')).to be_checked
expect(find_field('Allowed group').value).to eq group.path
- page.within('.as-performance') do
+ page.within('.as-performance-bar') do
uncheck 'Enable the Performance Bar'
click_on 'Save changes'
end
@@ -167,6 +167,26 @@ feature 'Admin updates settings' do
expect(Gitlab::CurrentSettings.unique_ips_limit_per_user).to eq(15)
end
+ scenario 'Configure web terminal' do
+ page.within('.as-terminal') do
+ fill_in 'Max session time', with: 15
+ click_button 'Save changes'
+ end
+
+ expect(page).to have_content "Application settings saved successfully"
+ expect(Gitlab::CurrentSettings.terminal_max_session_time).to eq(15)
+ end
+
+ scenario 'Enable outbound requests' do
+ page.within('.as-outbound') do
+ check 'Allow requests to the local network from hooks and services'
+ click_button 'Save changes'
+ end
+
+ expect(page).to have_content "Application settings saved successfully"
+ expect(Gitlab::CurrentSettings.allow_local_requests_from_hooks_and_services).to be true
+ end
+
scenario 'Change Slack Notifications Service template settings' do
first(:link, 'Service Templates').click
click_link 'Slack notifications'
diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb
index b3c50964810..08ba91a2682 100644
--- a/spec/features/issues/filtered_search/filter_issues_spec.rb
+++ b/spec/features/issues/filtered_search/filter_issues_spec.rb
@@ -22,15 +22,6 @@ describe 'Filter issues', :js do
end
end
- def expect_issues_list_count(open_count, closed_count = 0)
- all_count = open_count + closed_count
-
- expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count)
- page.within '.issues-list' do
- expect(page).to have_selector('.issue', count: open_count)
- end
- end
-
before do
project.add_master(user)
diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb
index 38c618d300e..4625a50b8d9 100644
--- a/spec/features/issues/form_spec.rb
+++ b/spec/features/issues/form_spec.rb
@@ -226,6 +226,23 @@ describe 'New/edit issue', :js do
expect(page).to have_selector('.atwho-view')
end
+
+ describe 'milestone' do
+ let!(:milestone) { create(:milestone, title: '">&lt;img src=x onerror=alert(document.domain)&gt;', project: project) }
+
+ it 'escapes milestone' do
+ click_button 'Milestone'
+
+ page.within '.issue-milestone' do
+ click_link milestone.title
+ end
+
+ page.within '.js-milestone-select' do
+ expect(page).to have_content milestone.title
+ expect(page).not_to have_selector 'img'
+ end
+ end
+ end
end
context 'edit issue' do
diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb
new file mode 100644
index 00000000000..99e1fb30d5b
--- /dev/null
+++ b/spec/features/labels_hierarchy_spec.rb
@@ -0,0 +1,305 @@
+require 'spec_helper'
+
+feature 'Labels Hierarchy', :js, :nested_groups do
+ include FilteredSearchHelpers
+
+ let!(:user) { create(:user) }
+ let!(:grandparent) { create(:group) }
+ let!(:parent) { create(:group, parent: grandparent) }
+ let!(:child) { create(:group, parent: parent) }
+ let!(:project_1) { create(:project, namespace: parent) }
+
+ let!(:grandparent_group_label) { create(:group_label, group: grandparent, title: 'Label_1') }
+ let!(:parent_group_label) { create(:group_label, group: parent, title: 'Label_2') }
+ let!(:child_group_label) { create(:group_label, group: child, title: 'Label_3') }
+ let!(:project_label_1) { create(:label, project: project_1, title: 'Label_4') }
+
+ before do
+ grandparent.add_owner(user)
+
+ sign_in(user)
+ end
+
+ shared_examples 'assigning labels from sidebar' do
+ it 'can assign all ancestors labels' do
+ [grandparent_group_label, parent_group_label, project_label_1].each do |label|
+ page.within('.block.labels') do
+ find('.edit-link').click
+ end
+
+ wait_for_requests
+
+ find('a.label-item', text: label.title).click
+ find('.dropdown-menu-close-icon').click
+
+ wait_for_requests
+
+ expect(page).to have_selector('span.label', text: label.title)
+ end
+ end
+
+ it 'does not find child group labels on dropdown' do
+ page.within('.block.labels') do
+ find('.edit-link').click
+ end
+
+ wait_for_requests
+
+ expect(page).not_to have_selector('span.label', text: child_group_label.title)
+ end
+ end
+
+ shared_examples 'filtering by ancestor labels for projects' do |board = false|
+ it 'filters by ancestor labels' do
+ [grandparent_group_label, parent_group_label, project_label_1].each do |label|
+ select_label_on_dropdown(label.title)
+
+ wait_for_requests
+
+ if board
+ expect(page).to have_selector('.card-title') do |card|
+ expect(card).to have_selector('a', text: labeled_issue.title)
+ end
+ else
+ expect_issues_list_count(1)
+ expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
+ end
+ end
+ end
+
+ it 'does not filter by descendant group labels' do
+ filtered_search.set("label:")
+
+ wait_for_requests
+
+ expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
+ end
+ end
+
+ shared_examples 'filtering by ancestor labels for groups' do |board = false|
+ let(:project_2) { create(:project, namespace: parent) }
+ let!(:project_label_2) { create(:label, project: project_2, title: 'Label_4') }
+
+ let(:project_3) { create(:project, namespace: child) }
+ let!(:group_label_3) { create(:group_label, group: child, title: 'Label_5') }
+ let!(:project_label_3) { create(:label, project: project_3, title: 'Label_6') }
+
+ let!(:labeled_issue_2) { create(:labeled_issue, project: project_2, labels: [grandparent_group_label, parent_group_label, project_label_2]) }
+ let!(:labeled_issue_3) { create(:labeled_issue, project: project_3, labels: [grandparent_group_label, parent_group_label, group_label_3]) }
+
+ let!(:issue_2) { create(:issue, project: project_2) }
+
+ it 'filters by ancestors and current group labels' do
+ [grandparent_group_label, parent_group_label].each do |label|
+ select_label_on_dropdown(label.title)
+
+ wait_for_requests
+
+ if board
+ expect(page).to have_selector('.card-title') do |card|
+ expect(card).to have_selector('a', text: labeled_issue.title)
+ end
+
+ expect(page).to have_selector('.card-title') do |card|
+ expect(card).to have_selector('a', text: labeled_issue_2.title)
+ end
+ else
+ expect_issues_list_count(3)
+ expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
+ expect(page).to have_selector('span.issue-title-text', text: labeled_issue_2.title)
+ expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
+ end
+ end
+ end
+
+ it 'filters by descendant group labels' do
+ wait_for_requests
+
+ if board
+ pending("Waiting for https://gitlab.com/gitlab-org/gitlab-ce/issues/44270")
+
+ select_label_on_dropdown(group_label_3.title)
+
+ expect(page).to have_selector('.card-title') do |card|
+ expect(card).to have_selector('a', text: labeled_issue_3.title)
+ end
+ else
+ select_label_on_dropdown(group_label_3.title)
+
+ expect_issues_list_count(1)
+ expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
+ end
+ end
+
+ it 'does not filter by descendant group project labels' do
+ filtered_search.set("label:")
+
+ wait_for_requests
+
+ expect(page).not_to have_selector('.btn-link', text: project_label_3.title)
+ end
+ end
+
+ context 'when creating new issuable' do
+ before do
+ visit new_project_issue_path(project_1)
+ end
+
+ it 'should be able to assign ancestor group labels' do
+ fill_in 'issue_title', with: 'new created issue'
+ fill_in 'issue_description', with: 'new issue description'
+
+ find(".js-label-select").click
+ wait_for_requests
+
+ find('a.label-item', text: grandparent_group_label.title).click
+ find('a.label-item', text: parent_group_label.title).click
+ find('a.label-item', text: project_label_1.title).click
+
+ find('.btn-create').click
+
+ expect(page.find('.issue-details h2.title')).to have_content('new created issue')
+ expect(page).to have_selector('span.label', text: grandparent_group_label.title)
+ expect(page).to have_selector('span.label', text: parent_group_label.title)
+ expect(page).to have_selector('span.label', text: project_label_1.title)
+ end
+ end
+
+ context 'issuable sidebar' do
+ let!(:issue) { create(:issue, project: project_1) }
+
+ context 'on issue sidebar' do
+ before do
+ visit project_issue_path(project_1, issue)
+ end
+
+ it_behaves_like 'assigning labels from sidebar'
+ end
+
+ context 'on project board issue sidebar' do
+ let(:board) { create(:board, project: project_1) }
+
+ before do
+ visit project_board_path(project_1, board)
+
+ wait_for_requests
+
+ find('.card').click
+ end
+
+ it_behaves_like 'assigning labels from sidebar'
+ end
+
+ context 'on group board issue sidebar' do
+ let(:board) { create(:board, group: parent) }
+
+ before do
+ visit group_board_path(parent, board)
+
+ wait_for_requests
+
+ find('.card').click
+ end
+
+ it_behaves_like 'assigning labels from sidebar'
+ end
+ end
+
+ context 'issuable filtering' do
+ let!(:labeled_issue) { create(:labeled_issue, project: project_1, labels: [grandparent_group_label, parent_group_label, project_label_1]) }
+ let!(:issue) { create(:issue, project: project_1) }
+
+ context 'on project issuable list' do
+ before do
+ visit project_issues_path(project_1)
+ end
+
+ it_behaves_like 'filtering by ancestor labels for projects'
+
+ it 'does not filter by descendant group labels' do
+ filtered_search.set("label:")
+
+ wait_for_requests
+
+ expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
+ end
+ end
+
+ context 'on group issuable list' do
+ before do
+ visit issues_group_path(parent)
+ end
+
+ it_behaves_like 'filtering by ancestor labels for groups'
+ end
+
+ context 'on project boards filter' do
+ let(:board) { create(:board, project: project_1) }
+
+ before do
+ visit project_board_path(project_1, board)
+ end
+
+ it_behaves_like 'filtering by ancestor labels for projects', true
+ end
+
+ context 'on group boards filter' do
+ let(:board) { create(:board, group: parent) }
+
+ before do
+ visit group_board_path(parent, board)
+ end
+
+ it_behaves_like 'filtering by ancestor labels for groups', true
+ end
+ end
+
+ context 'creating boards lists' do
+ context 'on project boards' do
+ let(:board) { create(:board, project: project_1) }
+
+ before do
+ visit project_board_path(project_1, board)
+ find('.js-new-board-list').click
+ wait_for_requests
+ end
+
+ it 'creates lists from all ancestor labels' do
+ [grandparent_group_label, parent_group_label, project_label_1].each do |label|
+ find('a', text: label.title).click
+ end
+
+ wait_for_requests
+
+ expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
+ expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
+ expect(page).to have_selector('.board-title-text', text: project_label_1.title)
+ end
+ end
+
+ context 'on group boards' do
+ let(:board) { create(:board, group: parent) }
+
+ before do
+ visit group_board_path(parent, board)
+ find('.js-new-board-list').click
+ wait_for_requests
+ end
+
+ it 'creates lists from all ancestor group labels' do
+ [grandparent_group_label, parent_group_label].each do |label|
+ find('a', text: label.title).click
+ end
+
+ wait_for_requests
+
+ expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
+ expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
+ end
+
+ it 'does not create lists from descendant groups' do
+ expect(page).not_to have_selector('a', text: child_group_label.title)
+ end
+ end
+ end
+end
diff --git a/spec/features/projects/issues/user_sorts_issues_spec.rb b/spec/features/projects/issues/user_sorts_issues_spec.rb
index 34148ae0116..c3d63000dac 100644
--- a/spec/features/projects/issues/user_sorts_issues_spec.rb
+++ b/spec/features/projects/issues/user_sorts_issues_spec.rb
@@ -25,17 +25,14 @@ describe "User sorts issues" do
page.within(".issues-list") do
page.within("li.issue:nth-child(1)") do
expect(page).to have_content(issue1.title)
- expect(page).to have_content("2 1")
end
page.within("li.issue:nth-child(2)") do
expect(page).to have_content(issue2.title)
- expect(page).to have_content("1 2")
end
page.within("li.issue:nth-child(3)") do
expect(page).to have_content(issue3.title)
- expect(page).not_to have_content("0 0")
end
end
end
diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb
index d434c501110..899d0d22819 100644
--- a/spec/finders/labels_finder_spec.rb
+++ b/spec/finders/labels_finder_spec.rb
@@ -71,6 +71,24 @@ describe LabelsFinder do
end
end
+ context 'when group has no projects' do
+ let(:empty_group) { create(:group) }
+ let!(:empty_group_label_1) { create(:group_label, group: empty_group, title: 'Label 1 (empty group)') }
+ let!(:empty_group_label_2) { create(:group_label, group: empty_group, title: 'Label 2 (empty group)') }
+
+ before do
+ empty_group.add_developer(user)
+ end
+
+ context 'when only group labels is false' do
+ it 'returns group labels' do
+ finder = described_class.new(user, group_id: empty_group.id)
+
+ expect(finder.execute).to eq [empty_group_label_1, empty_group_label_2]
+ end
+ end
+ end
+
context 'when including labels from group ancestors', :nested_groups do
it 'returns labels from group and its ancestors' do
private_group_1.add_developer(user)
@@ -110,7 +128,21 @@ describe LabelsFinder do
end
end
- context 'filtering by project_id' do
+ context 'filtering by project_id', :nested_groups do
+ context 'when include_ancestor_groups is true' do
+ let!(:sub_project) { create(:project, namespace: private_subgroup_1 ) }
+ let!(:project_label) { create(:label, project: sub_project, title: 'Label 5') }
+ let(:finder) { described_class.new(user, project_id: sub_project.id, include_ancestor_groups: true) }
+
+ before do
+ private_group_1.add_developer(user)
+ end
+
+ it 'returns all ancestor labels' do
+ expect(finder.execute).to match_array([private_subgroup_label_1, private_group_label_1, project_label])
+ end
+ end
+
it 'returns labels available for the project' do
finder = described_class.new(user, project_id: project_1.id)
diff --git a/spec/fixtures/exported-project.gz b/spec/fixtures/exported-project.gz
new file mode 100644
index 00000000000..352384f16c8
--- /dev/null
+++ b/spec/fixtures/exported-project.gz
Binary files differ
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 15cbe36ae76..53c010fa0db 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -135,11 +135,37 @@ describe DiffHelper do
it "returns strings with marked inline diffs" do
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">'def'</span>})
+ expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">&#39;def&#39;</span>})
expect(marked_old_line).to be_html_safe
- expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">"def"</span>})
+ expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">&quot;def&quot;</span>})
expect(marked_new_line).to be_html_safe
end
+
+ context 'when given HTML' do
+ it 'sanitizes it' do
+ old_line = %{test.txt}
+ new_line = %{<img src=x onerror=alert(document.domain)>}
+
+ marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
+
+ expect(marked_old_line).to eq(%q{<span class="idiff left right deletion">test.txt</span>})
+ expect(marked_old_line).to be_html_safe
+ expect(marked_new_line).to eq(%q{<span class="idiff left right addition">&lt;img src=x onerror=alert(document.domain)&gt;</span>})
+ expect(marked_new_line).to be_html_safe
+ end
+
+ it 'sanitizes the entire line, not just the changes' do
+ old_line = %{<img src=x onerror=alert(document.domain)>}
+ new_line = %{<img src=y onerror=alert(document.domain)>}
+
+ marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
+
+ expect(marked_old_line).to eq(%q{&lt;img src=<span class="idiff left right deletion">x</span> onerror=alert(document.domain)&gt;})
+ expect(marked_old_line).to be_html_safe
+ expect(marked_new_line).to eq(%q{&lt;img src=<span class="idiff left right addition">y</span> onerror=alert(document.domain)&gt;})
+ expect(marked_new_line).to be_html_safe
+ end
+ end
end
describe '#parallel_diff_discussions' do
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index ccac6e29447..ffdf6561a53 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -8,6 +8,7 @@ describe TreeHelper do
describe '.render_tree' do
before do
@id = sha
+ @path = ""
@project = project
@lfs_blob_ids = []
end
@@ -61,6 +62,15 @@ describe TreeHelper do
end
end
end
+
+ context 'when the root path contains a plus character' do
+ let(:root_path) { 'gtk/C++' }
+ let(:tree_item) { double(flat_path: 'gtk/C++/glade') }
+
+ it 'returns the flattened path' do
+ expect(subject).to eq('glade')
+ end
+ end
end
describe '#commit_in_single_accessible_branch' do
diff --git a/spec/lib/banzai/filter/commit_trailers_filter_spec.rb b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb
new file mode 100644
index 00000000000..1fd145116df
--- /dev/null
+++ b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb
@@ -0,0 +1,171 @@
+require 'spec_helper'
+require 'ffaker'
+
+describe Banzai::Filter::CommitTrailersFilter do
+ include FilterSpecHelper
+ include CommitTrailersSpecHelper
+
+ let(:secondary_email) { create(:email, :confirmed) }
+ let(:user) { create(:user) }
+
+ let(:trailer) { "#{FFaker::Lorem.word}-by:"}
+
+ let(:commit_message) { trailer_line(trailer, user.name, user.email) }
+ let(:commit_message_html) { commit_html(commit_message) }
+
+ context 'detects' do
+ let(:email) { FFaker::Internet.email }
+
+ it 'trailers in the form of *-by and replace users with links' do
+ doc = filter(commit_message_html)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ end
+
+ it 'trailers prefixed with whitespaces' do
+ message_html = commit_html("\n\r #{commit_message}")
+
+ doc = filter(message_html)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ end
+
+ it 'GitLab users via a secondary email' do
+ _, message_html = build_commit_message(
+ trailer: trailer,
+ name: secondary_email.user.name,
+ email: secondary_email.email
+ )
+
+ doc = filter(message_html)
+
+ expect_to_have_user_link_with_avatar(
+ doc,
+ user: secondary_email.user,
+ trailer: trailer,
+ email: secondary_email.email
+ )
+ end
+
+ it 'non GitLab users and replaces them with mailto links' do
+ _, message_html = build_commit_message(
+ trailer: trailer,
+ name: FFaker::Name.name,
+ email: email
+ )
+
+ doc = filter(message_html)
+
+ expect_to_have_mailto_link(doc, email: email, trailer: trailer)
+ end
+
+ it 'multiple trailers in the same message' do
+ different_trailer = "#{FFaker::Lorem.word}-by:"
+ message = commit_html %(
+ #{commit_message}
+ #{trailer_line(different_trailer, FFaker::Name.name, email)}
+ )
+
+ doc = filter(message)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ expect_to_have_mailto_link(doc, email: email, trailer: different_trailer)
+ end
+
+ context 'special names' do
+ where(:name) do
+ [
+ 'John S. Doe',
+ 'L33t H@x0r'
+ ]
+ end
+
+ with_them do
+ it do
+ message, message_html = build_commit_message(
+ trailer: trailer,
+ name: name,
+ email: email
+ )
+
+ doc = filter(message_html)
+
+ expect_to_have_mailto_link(doc, email: email, trailer: trailer)
+ expect(doc.text).to match Regexp.escape(message)
+ end
+ end
+ end
+ end
+
+ context "ignores" do
+ it 'commit messages without trailers' do
+ exp = message = commit_html(FFaker::Lorem.sentence)
+ doc = filter(message)
+
+ expect(doc.to_html).to match Regexp.escape(exp)
+ end
+
+ it 'trailers that are inline the commit message body' do
+ message = commit_html %(
+ #{FFaker::Lorem.sentence} #{commit_message} #{FFaker::Lorem.sentence}
+ )
+
+ doc = filter(message)
+
+ expect(doc.css('a').size).to eq 0
+ end
+ end
+
+ context "structure" do
+ it 'preserves the commit trailer structure' do
+ doc = filter(commit_message_html)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ expect(doc.text).to match Regexp.escape(commit_message)
+ end
+
+ it 'preserves the original name used in the commit message' do
+ message, message_html = build_commit_message(
+ trailer: trailer,
+ name: FFaker::Name.name,
+ email: user.email
+ )
+
+ doc = filter(message_html)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ expect(doc.text).to match Regexp.escape(message)
+ end
+
+ it 'preserves the original email used in the commit message' do
+ message, message_html = build_commit_message(
+ trailer: trailer,
+ name: secondary_email.user.name,
+ email: secondary_email.email
+ )
+
+ doc = filter(message_html)
+
+ expect_to_have_user_link_with_avatar(
+ doc,
+ user: secondary_email.user,
+ trailer: trailer,
+ email: secondary_email.email
+ )
+ expect(doc.text).to match Regexp.escape(message)
+ end
+
+ it 'only replaces trailer lines not the full commit message' do
+ commit_body = FFaker::Lorem.paragraph
+ message = commit_html %(
+ #{commit_body}
+ #{commit_message}
+ )
+
+ doc = filter(message)
+
+ expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
+ expect(doc.text).to include(commit_body)
+ end
+ end
+end
diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
index eeb82822f68..a1dd72c498f 100644
--- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
@@ -196,6 +196,41 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
end
end
+ context 'URL reference for a commit' do
+ let(:mr) { create(:merge_request, :with_diffs) }
+ let(:reference) do
+ urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=#{mr.diff_head_sha}"
+ end
+ let(:commit) { mr.commits.find { |commit| commit.sha == mr.diff_head_sha } }
+
+ it 'links to a valid reference' do
+ doc = reference_filter("See #{reference}")
+
+ expect(doc.css('a').first.attr('href'))
+ .to eq reference
+ end
+
+ it 'has valid text' do
+ doc = reference_filter("See #{reference}")
+
+ expect(doc.text).to eq("See #{mr.to_reference(full: true)} (#{commit.short_id})")
+ end
+
+ it 'has valid title attribute' do
+ doc = reference_filter("See #{reference}")
+
+ expect(doc.css('a').first.attr('title')).to eq(commit.title)
+ end
+
+ it 'ignores invalid commit short_ids on link text' do
+ invalidate_commit_reference =
+ urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=12345678"
+ doc = reference_filter("See #{invalidate_commit_reference}")
+
+ expect(doc.text).to eq("See #{mr.to_reference(full: true)} (diffs)")
+ end
+ end
+
context 'cross-project URL reference' do
let(:namespace) { create(:namespace, name: 'cross-reference') }
let(:project2) { create(:project, :public, namespace: namespace) }
diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb
new file mode 100644
index 00000000000..6f3fb994f17
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migration, schema: 20180122154930 do
+ let(:services) { table(:services) }
+
+ describe '#perform' do
+ it 'migrates services where note_events is true' do
+ service = services.create(confidential_note_events: nil, note_events: true)
+
+ subject.perform(service.id, service.id)
+
+ expect(service.reload.confidential_note_events).to eq(true)
+ end
+
+ it 'ignores services where note_events is false' do
+ service = services.create(confidential_note_events: nil, note_events: false)
+
+ subject.perform(service.id, service.id)
+
+ expect(service.reload.confidential_note_events).to eq(nil)
+ end
+
+ it 'ignores services where confidential_note_events has already been set' do
+ service = services.create(confidential_note_events: false, note_events: true)
+
+ subject.perform(service.id, service.id)
+
+ expect(service.reload.confidential_note_events).to eq(false)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb
new file mode 100644
index 00000000000..82b484b7d5b
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migration, schema: 20180104131052 do
+ let(:web_hooks) { table(:web_hooks) }
+
+ describe '#perform' do
+ it 'migrates hooks where note_events is true' do
+ hook = web_hooks.create(confidential_note_events: nil, note_events: true)
+
+ subject.perform(hook.id, hook.id)
+
+ expect(hook.reload.confidential_note_events).to eq(true)
+ end
+
+ it 'ignores hooks where note_events is false' do
+ hook = web_hooks.create(confidential_note_events: nil, note_events: false)
+
+ subject.perform(hook.id, hook.id)
+
+ expect(hook.reload.confidential_note_events).to eq(nil)
+ end
+
+ it 'ignores hooks where confidential_note_events has already been set' do
+ hook = web_hooks.create(confidential_note_events: false, note_events: true)
+
+ subject.perform(hook.id, hook.id)
+
+ expect(hook.reload.confidential_note_events).to eq(false)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb
index aaa42566a4d..4f8412108ba 100644
--- a/spec/lib/gitlab/data_builder/note_spec.rb
+++ b/spec/lib/gitlab/data_builder/note_spec.rb
@@ -55,6 +55,14 @@ describe Gitlab::DataBuilder::Note do
.to be > issue.hook_attrs['updated_at']
end
+ context 'with confidential issue' do
+ let(:issue) { create(:issue, project: project, confidential: true) }
+
+ it 'sets event_type to confidential_note' do
+ expect(data[:event_type]).to eq('confidential_note')
+ end
+ end
+
include_examples 'project hook data'
include_examples 'deprecated repository hook data'
end
diff --git a/spec/lib/gitlab/import_export/importer_spec.rb b/spec/lib/gitlab/import_export/importer_spec.rb
new file mode 100644
index 00000000000..d75416f2a62
--- /dev/null
+++ b/spec/lib/gitlab/import_export/importer_spec.rb
@@ -0,0 +1,64 @@
+require 'spec_helper'
+
+describe Gitlab::ImportExport::Importer do
+ let(:test_path) { "#{Dir.tmpdir}/importer_spec" }
+ let(:shared) { project.import_export_shared }
+ let(:project) { create(:project, import_source: File.join(test_path, 'exported-project.gz')) }
+
+ subject(:importer) { described_class.new(project) }
+
+ before do
+ allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(test_path)
+ FileUtils.mkdir_p(shared.export_path)
+ FileUtils.cp(Rails.root.join('spec', 'fixtures', 'exported-project.gz'), test_path)
+ end
+
+ after do
+ FileUtils.rm_rf(test_path)
+ end
+
+ describe '#execute' do
+ it 'succeeds' do
+ importer.execute
+
+ expect(shared.errors).to be_empty
+ end
+
+ it 'extracts the archive' do
+ expect(Gitlab::ImportExport::FileImporter).to receive(:import).and_call_original
+
+ importer.execute
+ end
+
+ it 'checks the version' do
+ expect(Gitlab::ImportExport::VersionChecker).to receive(:check!).and_call_original
+
+ importer.execute
+ end
+
+ context 'all restores are executed' do
+ [
+ Gitlab::ImportExport::AvatarRestorer,
+ Gitlab::ImportExport::RepoRestorer,
+ Gitlab::ImportExport::WikiRestorer,
+ Gitlab::ImportExport::UploadsRestorer,
+ Gitlab::ImportExport::LfsRestorer
+ ].each do |restorer|
+ it "calls the #{restorer}" do
+ fake_restorer = double(restorer.to_s)
+
+ expect(fake_restorer).to receive(:restore).and_return(true).at_least(1)
+ expect(restorer).to receive(:new).and_return(fake_restorer).at_least(1)
+
+ importer.execute
+ end
+ end
+
+ it 'restores the ProjectTree' do
+ expect(Gitlab::ImportExport::ProjectTreeRestorer).to receive(:new).and_call_original
+
+ importer.execute
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb
new file mode 100644
index 00000000000..70eeb9ee66b
--- /dev/null
+++ b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb
@@ -0,0 +1,75 @@
+require 'spec_helper'
+
+describe Gitlab::ImportExport::LfsRestorer do
+ include UploadHelpers
+
+ let(:export_path) { "#{Dir.tmpdir}/lfs_object_restorer_spec" }
+ let(:project) { create(:project) }
+ let(:shared) { project.import_export_shared }
+ subject(:restorer) { described_class.new(project: project, shared: shared) }
+
+ before do
+ allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
+ FileUtils.mkdir_p(shared.export_path)
+ end
+
+ after do
+ FileUtils.rm_rf(shared.export_path)
+ end
+
+ describe '#restore' do
+ context 'when the archive contains lfs files' do
+ let(:dummy_lfs_file_path) { File.join(shared.export_path, 'lfs-objects', 'dummy') }
+
+ def create_lfs_object_with_content(content)
+ dummy_lfs_file = Tempfile.new('existing')
+ File.write(dummy_lfs_file.path, content)
+ size = dummy_lfs_file.size
+ oid = LfsObject.calculate_oid(dummy_lfs_file.path)
+ LfsObject.create!(oid: oid, size: size, file: dummy_lfs_file)
+ end
+
+ before do
+ FileUtils.mkdir_p(File.dirname(dummy_lfs_file_path))
+ File.write(dummy_lfs_file_path, 'not very large')
+ allow(restorer).to receive(:lfs_file_paths).and_return([dummy_lfs_file_path])
+ end
+
+ it 'creates an lfs object for the project' do
+ expect { restorer.restore }.to change { project.reload.lfs_objects.size }.by(1)
+ end
+
+ it 'assigns the file correctly' do
+ restorer.restore
+
+ expect(project.lfs_objects.first.file.read).to eq('not very large')
+ end
+
+ it 'links an existing LFS object if it existed' do
+ lfs_object = create_lfs_object_with_content('not very large')
+
+ restorer.restore
+
+ expect(project.lfs_objects).to include(lfs_object)
+ end
+
+ it 'succeeds' do
+ expect(restorer.restore).to be_truthy
+ expect(shared.errors).to be_empty
+ end
+
+ it 'stores the upload' do
+ expect_any_instance_of(LfsObjectUploader).to receive(:store!)
+
+ restorer.restore
+ end
+ end
+
+ context 'without any LFS-objects' do
+ it 'succeeds' do
+ expect(restorer.restore).to be_truthy
+ expect(shared.errors).to be_empty
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
new file mode 100644
index 00000000000..9b0e21deb2e
--- /dev/null
+++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
@@ -0,0 +1,62 @@
+require 'spec_helper'
+
+describe Gitlab::ImportExport::LfsSaver do
+ let(:shared) { project.import_export_shared }
+ let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
+ let(:project) { create(:project) }
+
+ subject(:saver) { described_class.new(project: project, shared: shared) }
+
+ before do
+ allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
+ FileUtils.mkdir_p(shared.export_path)
+ end
+
+ after do
+ FileUtils.rm_rf(shared.export_path)
+ end
+
+ describe '#save' do
+ context 'when the project has LFS objects locally stored' do
+ let(:lfs_object) { create(:lfs_object, :with_file) }
+
+ before do
+ project.lfs_objects << lfs_object
+ end
+
+ it 'does not cause errors' do
+ saver.save
+
+ expect(shared.errors).to be_empty
+ end
+
+ it 'copies the file in the correct location when there is an lfs object' do
+ saver.save
+
+ expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}")
+ end
+ end
+
+ context 'when the LFS objects are stored in object storage' do
+ let(:lfs_object) { create(:lfs_object, :object_storage) }
+
+ before do
+ allow(LfsObjectUploader).to receive(:object_store_enabled?).and_return(true)
+ allow(lfs_object.file).to receive(:url).and_return('http://my-object-storage.local')
+ project.lfs_objects << lfs_object
+ end
+
+ it 'downloads the file to include in an archive' do
+ fake_uri = double
+ exported_file_path = "#{shared.export_path}/lfs-objects/#{lfs_object.oid}"
+
+ expect(fake_uri).to receive(:open).and_return(StringIO.new('LFS file content'))
+ expect(URI).to receive(:parse).with('http://my-object-storage.local').and_return(fake_uri)
+
+ saver.save
+
+ expect(File.read(exported_file_path)).to eq('LFS file content')
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml
index f949a23ffbb..f84a777a27f 100644
--- a/spec/lib/gitlab/import_export/safe_model_attributes.yml
+++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml
@@ -390,6 +390,7 @@ Service:
- default
- wiki_page_events
- confidential_issues_events
+- confidential_note_events
ProjectHook:
- id
- url
@@ -410,6 +411,7 @@ ProjectHook:
- token
- group_id
- confidential_issues_events
+- confidential_note_events
- repository_update_events
ProtectedBranch:
- id
diff --git a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb
new file mode 100644
index 00000000000..fed9aeba30c
--- /dev/null
+++ b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe Gitlab::SidekiqLogging::JSONFormatter do
+ let(:hash_input) { { foo: 1, bar: 'test' } }
+ let(:message) { 'This is a test' }
+ let(:timestamp) { Time.now }
+
+ it 'wraps a Hash' do
+ result = subject.call('INFO', timestamp, 'my program', hash_input)
+
+ data = JSON.parse(result)
+ expected_output = hash_input.stringify_keys
+ expected_output['severity'] = 'INFO'
+ expected_output['time'] = timestamp.utc.iso8601(3)
+
+ expect(data).to eq(expected_output)
+ end
+
+ it 'wraps a String' do
+ result = subject.call('DEBUG', timestamp, 'my string', message)
+
+ data = JSON.parse(result)
+ expected_output = {
+ severity: 'DEBUG',
+ time: timestamp.utc.iso8601(3),
+ message: message
+ }
+
+ expect(data).to eq(expected_output.stringify_keys)
+ end
+end
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
new file mode 100644
index 00000000000..2421b1e5a1a
--- /dev/null
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -0,0 +1,101 @@
+require 'spec_helper'
+
+describe Gitlab::SidekiqLogging::StructuredLogger do
+ describe '#call' do
+ let(:timestamp) { Time.new('2018-01-01 12:00:00').utc }
+ let(:job) do
+ {
+ "class" => "TestWorker",
+ "args" => [1234, 'hello'],
+ "retry" => false,
+ "queue" => "cronjob:test_queue",
+ "queue_namespace" => "cronjob",
+ "jid" => "da883554ee4fe414012f5f42",
+ "created_at" => timestamp.to_f,
+ "enqueued_at" => timestamp.to_f
+ }
+ end
+ let(:logger) { double() }
+ let(:start_payload) do
+ job.merge(
+ 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start',
+ 'job_status' => 'start',
+ 'pid' => Process.pid,
+ 'created_at' => timestamp.iso8601(3),
+ 'enqueued_at' => timestamp.iso8601(3)
+ )
+ end
+ let(:end_payload) do
+ start_payload.merge(
+ 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec',
+ 'job_status' => 'done',
+ 'duration' => 0.0,
+ "completed_at" => timestamp.iso8601(3)
+ )
+ end
+ let(:exception_payload) do
+ end_payload.merge(
+ 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec',
+ 'job_status' => 'fail',
+ 'error' => ArgumentError,
+ 'error_message' => 'some exception'
+ )
+ end
+
+ before do
+ allow(Sidekiq).to receive(:logger).and_return(logger)
+
+ allow(subject).to receive(:current_time).and_return(timestamp.to_f)
+ end
+
+ subject { described_class.new }
+
+ context 'with SIDEKIQ_LOG_ARGUMENTS enabled' do
+ before do
+ stub_env('SIDEKIQ_LOG_ARGUMENTS', '1')
+ end
+
+ it 'logs start and end of job' do
+ Timecop.freeze(timestamp) do
+ expect(logger).to receive(:info).with(start_payload).ordered
+ expect(logger).to receive(:info).with(end_payload).ordered
+ expect(subject).to receive(:log_job_start).and_call_original
+ expect(subject).to receive(:log_job_done).and_call_original
+
+ subject.call(job, 'test_queue') { }
+ end
+ end
+
+ it 'logs an exception in job' do
+ Timecop.freeze(timestamp) do
+ expect(logger).to receive(:info).with(start_payload)
+ # This excludes the exception_backtrace
+ expect(logger).to receive(:warn).with(hash_including(exception_payload))
+ expect(subject).to receive(:log_job_start).and_call_original
+ expect(subject).to receive(:log_job_done).and_call_original
+
+ expect do
+ subject.call(job, 'test_queue') do
+ raise ArgumentError, 'some exception'
+ end
+ end.to raise_error(ArgumentError)
+ end
+ end
+ end
+
+ context 'with SIDEKIQ_LOG_ARGUMENTS disabled' do
+ it 'logs start and end of job' do
+ Timecop.freeze(timestamp) do
+ start_payload.delete('args')
+
+ expect(logger).to receive(:info).with(start_payload).ordered
+ expect(logger).to receive(:info).with(end_payload).ordered
+ expect(subject).to receive(:log_job_start).and_call_original
+ expect(subject).to receive(:log_job_done).and_call_original
+
+ subject.call(job, 'test_queue') { }
+ end
+ end
+ end
+ end
+end
diff --git a/spec/mailers/previews/email_rejection_mailer_preview.rb b/spec/mailers/previews/email_rejection_mailer_preview.rb
new file mode 100644
index 00000000000..639e8471232
--- /dev/null
+++ b/spec/mailers/previews/email_rejection_mailer_preview.rb
@@ -0,0 +1,5 @@
+class EmailRejectionMailerPreview < ActionMailer::Preview
+ def rejection
+ EmailRejectionMailer.rejection("some rejection reason", "From: someone@example.com\nraw email here").message
+ end
+end
diff --git a/spec/mailers/previews/notify_preview.rb b/spec/mailers/previews/notify_preview.rb
index 43c3c89f140..e32fd0bd120 100644
--- a/spec/mailers/previews/notify_preview.rb
+++ b/spec/mailers/previews/notify_preview.rb
@@ -58,16 +58,89 @@ class NotifyPreview < ActionMailer::Preview
end
end
+ def closed_issue_email
+ Notify.closed_issue_email(user.id, issue.id, user.id).message
+ end
+
+ def issue_status_changed_email
+ Notify.issue_status_changed_email(user.id, issue.id, 'closed', user.id).message
+ end
+
+ def closed_merge_request_email
+ Notify.closed_merge_request_email(user.id, issue.id, user.id).message
+ end
+
+ def merge_request_status_email
+ Notify.merge_request_status_email(user.id, merge_request.id, 'closed', user.id).message
+ end
+
+ def merged_merge_request_email
+ Notify.merged_merge_request_email(user.id, merge_request.id, user.id).message
+ end
+
+ def member_access_denied_email
+ Notify.member_access_denied_email('project', project.id, user.id).message
+ end
+
+ def member_access_granted_email
+ Notify.member_access_granted_email('project', user.id).message
+ end
+
+ def member_access_requested_email
+ Notify.member_access_requested_email('group', user.id, 'some@example.com').message
+ end
+
+ def member_invite_accepted_email
+ Notify.member_invite_accepted_email('project', user.id).message
+ end
+
+ def member_invite_declined_email
+ Notify.member_invite_declined_email(
+ 'project',
+ project.id,
+ 'invite@example.com',
+ user.id
+ ).message
+ end
+
+ def member_invited_email
+ Notify.member_invited_email('project', user.id, '1234').message
+ end
+
+ def pages_domain_enabled_email
+ cleanup do
+ pages_domain = PagesDomain.new(domain: 'my.example.com', project: project, verified_at: Time.now, enabled_until: 1.week.from_now)
+
+ Notify.pages_domain_enabled_email(pages_domain, user).message
+ end
+ end
+
+ def pipeline_success_email
+ Notify.pipeline_success_email(pipeline, pipeline.user.try(:email))
+ end
+
+ def pipeline_failed_email
+ Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email))
+ end
+
private
def project
@project ||= Project.find_by_full_path('gitlab-org/gitlab-test')
end
+ def issue
+ @merge_request ||= project.issues.first
+ end
+
def merge_request
@merge_request ||= project.merge_requests.first
end
+ def pipeline
+ @pipeline = Ci::Pipeline.last
+ end
+
def user
@user ||= User.last
end
@@ -94,14 +167,4 @@ class NotifyPreview < ActionMailer::Preview
email
end
-
- def pipeline_success_email
- pipeline = Ci::Pipeline.last
- Notify.pipeline_success_email(pipeline, pipeline.user.try(:email))
- end
-
- def pipeline_failed_email
- pipeline = Ci::Pipeline.last
- Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email))
- end
end
diff --git a/spec/mailers/previews/repository_check_mailer_preview.rb b/spec/mailers/previews/repository_check_mailer_preview.rb
new file mode 100644
index 00000000000..19d4eab1805
--- /dev/null
+++ b/spec/mailers/previews/repository_check_mailer_preview.rb
@@ -0,0 +1,5 @@
+class RepositoryCheckMailerPreview < ActionMailer::Preview
+ def notify
+ RepositoryCheckMailer.notify(3).message
+ end
+end
diff --git a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb
new file mode 100644
index 00000000000..4395e2f8264
--- /dev/null
+++ b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb')
+
+describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do
+ let(:services_table) { table(:services) }
+ let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices }
+ let(:migration_name) { migration_class.to_s.demodulize }
+
+ let!(:service_1) { services_table.create!(confidential_note_events: nil, note_events: true) }
+ let!(:service_2) { services_table.create!(confidential_note_events: nil, note_events: true) }
+ let!(:service_migrated) { services_table.create!(confidential_note_events: true, note_events: true) }
+ let!(:service_skip) { services_table.create!(confidential_note_events: nil, note_events: false) }
+ let!(:service_new) { services_table.create!(confidential_note_events: false, note_events: true) }
+ let!(:service_4) { services_table.create!(confidential_note_events: nil, note_events: true) }
+
+ before do
+ stub_const("#{described_class}::BATCH_SIZE", 1)
+ end
+
+ it 'schedules background migrations at correct time' do
+ Sidekiq::Testing.fake! do
+ Timecop.freeze do
+ migrate!
+
+ expect(migration_name).to be_scheduled_delayed_migration(20.minutes, service_1.id, service_1.id)
+ expect(migration_name).to be_scheduled_delayed_migration(40.minutes, service_2.id, service_2.id)
+ expect(migration_name).to be_scheduled_delayed_migration(60.minutes, service_4.id, service_4.id)
+ expect(BackgroundMigrationWorker.jobs.size).to eq 3
+ end
+ end
+ end
+
+ it 'correctly processes services' do
+ Sidekiq::Testing.inline! do
+ expect(services_table.where(confidential_note_events: nil).count).to eq 4
+ expect(services_table.where(confidential_note_events: true).count).to eq 1
+
+ migrate!
+
+ expect(services_table.where(confidential_note_events: nil).count).to eq 1
+ expect(services_table.where(confidential_note_events: true).count).to eq 4
+ end
+ end
+end
diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
index c81ec887ded..df009cec25c 100644
--- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
+++ b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
@@ -4,8 +4,24 @@ require Rails.root.join('db', 'post_migrate', '20171013104327_migrate_gcp_cluste
describe MigrateGcpClustersToNewClustersArchitectures, :migration do
let(:projects) { table(:projects) }
let(:project) { projects.create }
- let(:user) { create(:user) }
- let(:service) { create(:kubernetes_service, project_id: project.id) }
+ let(:users) { table(:users) }
+ let(:user) { users.create! }
+ let(:service) { GcpMigrationSpec::KubernetesService.create!(project_id: project.id) }
+
+ module GcpMigrationSpec
+ class KubernetesService < ActiveRecord::Base
+ self.table_name = 'services'
+
+ serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize
+
+ default_value_for :active, true
+ default_value_for :type, 'KubernetesService'
+ default_value_for :properties, {
+ api_url: 'https://kubernetes.example.com',
+ token: 'a' * 40
+ }
+ end
+ end
context 'when cluster is being created' do
let(:project_id) { project.id }
diff --git a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb
new file mode 100644
index 00000000000..027f4a91c90
--- /dev/null
+++ b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb')
+
+describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do
+ let(:web_hooks_table) { table(:web_hooks) }
+ let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks }
+ let(:migration_name) { migration_class.to_s.demodulize }
+
+ let!(:web_hook_1) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) }
+ let!(:web_hook_2) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) }
+ let!(:web_hook_migrated) { web_hooks_table.create!(confidential_note_events: true, note_events: true) }
+ let!(:web_hook_skip) { web_hooks_table.create!(confidential_note_events: nil, note_events: false) }
+ let!(:web_hook_new) { web_hooks_table.create!(confidential_note_events: false, note_events: true) }
+ let!(:web_hook_4) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) }
+
+ before do
+ stub_const("#{described_class}::BATCH_SIZE", 1)
+ end
+
+ it 'schedules background migrations at correct time' do
+ Sidekiq::Testing.fake! do
+ Timecop.freeze do
+ migrate!
+
+ expect(migration_name).to be_scheduled_delayed_migration(5.minutes, web_hook_1.id, web_hook_1.id)
+ expect(migration_name).to be_scheduled_delayed_migration(10.minutes, web_hook_2.id, web_hook_2.id)
+ expect(migration_name).to be_scheduled_delayed_migration(15.minutes, web_hook_4.id, web_hook_4.id)
+ expect(BackgroundMigrationWorker.jobs.size).to eq 3
+ end
+ end
+ end
+
+ it 'correctly processes web hooks' do
+ Sidekiq::Testing.inline! do
+ expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 4
+ expect(web_hooks_table.where(confidential_note_events: true).count).to eq 1
+
+ migrate!
+
+ expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 1
+ expect(web_hooks_table.where(confidential_note_events: true).count).to eq 4
+ end
+ end
+end
diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb
index 268561ee941..7e75d5a5411 100644
--- a/spec/models/ci/build_metadata_spec.rb
+++ b/spec/models/ci/build_metadata_spec.rb
@@ -13,7 +13,7 @@ describe Ci::BuildMetadata do
end
let(:build) { create(:ci_build, pipeline: pipeline) }
- let(:build_metadata) { create(:ci_build_metadata, build: build) }
+ let(:build_metadata) { build.metadata }
describe '#update_timeout_state' do
subject { build_metadata }
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index b7ed8be69fc..c536dab2681 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -368,9 +368,7 @@ describe CommitStatus do
'rspec:windows 0 : / 1' => 'rspec:windows',
'rspec:windows 0 : / 1 name' => 'rspec:windows name',
'0 1 name ruby' => 'name ruby',
- '0 :/ 1 name ruby' => 'name ruby',
- 'golang test 1.8' => 'golang test',
- '1.9 golang test' => 'golang test'
+ '0 :/ 1 name ruby' => 'name ruby'
}
tests.each do |name, group_name|
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index c853f707e6d..86962cd8d61 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -191,6 +191,21 @@ describe Note do
end
end
+ describe "confidential?" do
+ it "delegates to noteable" do
+ issue_note = build(:note, :on_issue)
+ confidential_note = build(:note, noteable: create(:issue, confidential: true))
+
+ expect(issue_note.confidential?).to be_falsy
+ expect(confidential_note.confidential?).to be_truthy
+ end
+
+ it "is falsey when noteable can't be confidential" do
+ commit_note = build(:note_on_commit)
+ expect(commit_note.confidential?).to be_falsy
+ end
+ end
+
describe "cross_reference_not_visible_for?" do
let(:private_user) { create(:user) }
let(:private_project) { create(:project, namespace: private_user.namespace) { |p| p.add_master(private_user) } }
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index 3e2a166cdd6..0cd712e2f40 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -253,6 +253,21 @@ describe HipchatService do
"<b>#{title}</b>" \
"<pre>issue <strong>note</strong></pre>")
end
+
+ context 'with confidential issue' do
+ before do
+ issue.update!(confidential: true)
+ end
+
+ it 'calls Hipchat API with issue comment' do
+ data = Gitlab::DataBuilder::Note.build(issue_note, user)
+ hipchat.execute(data)
+
+ message = hipchat.send(:create_message, data)
+
+ expect(message).to include("<pre>issue <strong>note</strong></pre>")
+ end
+ end
end
context 'when snippet comment event triggered' do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 0e560be9eaa..8bd62dcdccb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2022,6 +2022,22 @@ describe Project do
expect(forked_project.lfs_storage_project).to eq forked_project
end
end
+
+ describe '#all_lfs_objects' do
+ let(:lfs_object) { create(:lfs_object) }
+
+ before do
+ project.lfs_objects << lfs_object
+ end
+
+ it 'returns the lfs object for a project' do
+ expect(project.all_lfs_objects).to contain_exactly(lfs_object)
+ end
+
+ it 'returns the lfs object for a fork' do
+ expect(forked_project.all_lfs_objects).to contain_exactly(lfs_object)
+ end
+ end
end
describe '#pushes_since_gc' do
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 83ed3b203e6..28c908ea425 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -10,6 +10,22 @@ describe Service do
it { is_expected.to validate_presence_of(:type) }
end
+ describe 'Scopes' do
+ describe '.confidential_note_hooks' do
+ it 'includes services where confidential_note_events is true' do
+ create(:service, active: true, confidential_note_events: true)
+
+ expect(described_class.confidential_note_hooks.count).to eq 1
+ end
+
+ it 'excludes services where confidential_note_events is false' do
+ create(:service, active: true, confidential_note_events: false)
+
+ expect(described_class.confidential_note_hooks.count).to eq 0
+ end
+ end
+ end
+
describe "Test Button" do
describe '#can_test?' do
let(:service) { create(:service, project: project) }
diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb
index c6c10025f7f..92b614b087e 100644
--- a/spec/requests/api/boards_spec.rb
+++ b/spec/requests/api/boards_spec.rb
@@ -48,5 +48,36 @@ describe API::Boards do
expect(json_response['label']['name']).to eq(group_label.title)
expect(json_response['position']).to eq(3)
end
+
+ it 'creates a new board list for ancestor group labels' do
+ group = create(:group)
+ sub_group = create(:group, parent: group)
+ group_label = create(:group_label, group: group)
+ board_parent.update(group: sub_group)
+ group.add_developer(user)
+ sub_group.add_developer(user)
+
+ post api(url, user), label_id: group_label.id
+
+ expect(response).to have_gitlab_http_status(201)
+ expect(json_response['label']['name']).to eq(group_label.title)
+ end
+ end
+
+ describe "POST /groups/:id/boards/lists", :nested_groups do
+ set(:group) { create(:group) }
+ set(:board_parent) { create(:group, parent: group ) }
+ let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
+ set(:board) { create(:board, group: board_parent) }
+
+ it 'creates a new board list for ancestor group labels' do
+ group.add_developer(user)
+ group_label = create(:group_label, group: group)
+
+ post api(url, user), label_id: group_label.id
+
+ expect(response).to have_gitlab_http_status(201)
+ expect(json_response['label']['name']).to eq(group_label.title)
+ end
end
end
diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb
index 267058d98ee..c5354c2d639 100644
--- a/spec/requests/api/features_spec.rb
+++ b/spec/requests/api/features_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe API::Features do
- let(:user) { create(:user) }
- let(:admin) { create(:admin) }
+ set(:user) { create(:user) }
+ set(:admin) { create(:admin) }
before do
Flipper.unregister_groups
@@ -249,4 +249,43 @@ describe API::Features do
end
end
end
+
+ describe 'DELETE /feature/:name' do
+ let(:feature_name) { 'my_feature' }
+
+ context 'when the user has no access' do
+ it 'returns a 401 for anonymous users' do
+ delete api("/features/#{feature_name}")
+
+ expect(response).to have_gitlab_http_status(401)
+ end
+
+ it 'returns a 403 for users' do
+ delete api("/features/#{feature_name}", user)
+
+ expect(response).to have_gitlab_http_status(403)
+ end
+ end
+
+ context 'when the user has access' do
+ it 'returns 204 when the value is not set' do
+ delete api("/features/#{feature_name}", admin)
+
+ expect(response).to have_gitlab_http_status(204)
+ end
+
+ context 'when the gate value was set' do
+ before do
+ Feature.get(feature_name).enable
+ end
+
+ it 'deletes an enabled feature' do
+ delete api("/features/#{feature_name}", admin)
+
+ expect(response).to have_gitlab_http_status(204)
+ expect(Feature.get(feature_name)).not_to be_enabled
+ end
+ end
+ end
+ end
end
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index 392cad667be..12a183fed1e 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -33,6 +33,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response.first['merge_requests_events']).to eq(true)
expect(json_response.first['tag_push_events']).to eq(true)
expect(json_response.first['note_events']).to eq(true)
+ expect(json_response.first['confidential_note_events']).to eq(true)
expect(json_response.first['job_events']).to eq(true)
expect(json_response.first['pipeline_events']).to eq(true)
expect(json_response.first['wiki_page_events']).to eq(true)
@@ -62,6 +63,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
+ expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events)
expect(json_response['job_events']).to eq(hook.job_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
@@ -104,6 +106,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(false)
expect(json_response['tag_push_events']).to eq(false)
expect(json_response['note_events']).to eq(false)
+ expect(json_response['confidential_note_events']).to eq(nil)
expect(json_response['job_events']).to eq(true)
expect(json_response['pipeline_events']).to eq(false)
expect(json_response['wiki_page_events']).to eq(true)
@@ -152,6 +155,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
expect(json_response['note_events']).to eq(hook.note_events)
+ expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events)
expect(json_response['job_events']).to eq(hook.job_events)
expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb
index 0a6b6d880d3..dd0ad5f11bd 100644
--- a/spec/services/boards/issues/move_service_spec.rb
+++ b/spec/services/boards/issues/move_service_spec.rb
@@ -48,7 +48,7 @@ describe Boards::Issues::MoveService do
parent.add_developer(user)
end
- it_behaves_like 'issues move service'
+ it_behaves_like 'issues move service', true
end
end
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 41237dd7160..f95474208f3 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -97,6 +97,37 @@ describe Issues::UpdateService, :mailer do
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)
end
+ context 'when moving issue between issues from different projects' do
+ let(:group) { create(:group) }
+ let(:project_1) { create(:project, namespace: group) }
+ let(:project_2) { create(:project, namespace: group) }
+ let(:project_3) { create(:project, namespace: group) }
+
+ let(:issue_1) { create(:issue, project: project_1) }
+ let(:issue_2) { create(:issue, project: project_2) }
+ let(:issue_3) { create(:issue, project: project_3) }
+
+ before do
+ group.add_developer(user)
+ end
+
+ it 'sorts issues as specified by parameters' do
+ # Moving all issues to end here like the last example won't work since
+ # all projects only have the same issue count
+ # so their relative_position will be the same.
+ issue_1.move_to_end
+ issue_2.move_after(issue_1)
+ issue_3.move_after(issue_2)
+ [issue_1, issue_2, issue_3].map(&:save)
+
+ opts[:move_between_ids] = [issue_1.id, issue_2.id]
+ opts[:board_group_id] = group.id
+
+ described_class.new(issue_3.project, user, opts).execute(issue_3)
+ expect(issue_2.relative_position).to be_between(issue_1.relative_position, issue_2.relative_position)
+ end
+ end
+
context 'when current user cannot admin issues in the project' do
let(:guest) { create(:user) }
before do
diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb
index 6ef5e93cb20..4e2ab919f0f 100644
--- a/spec/services/notes/post_process_service_spec.rb
+++ b/spec/services/notes/post_process_service_spec.rb
@@ -23,5 +23,23 @@ describe Notes::PostProcessService do
described_class.new(@note).execute
end
+
+ context 'with a confidential issue' do
+ let(:issue) { create(:issue, :confidential, project: project) }
+
+ it "doesn't call note hooks/services" do
+ expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks)
+ expect(project).not_to receive(:execute_services).with(anything, :note_hooks)
+
+ described_class.new(@note).execute
+ end
+
+ it "calls confidential-note hooks/services" do
+ expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks)
+ expect(project).to receive(:execute_services).with(anything, :confidential_note_hooks)
+
+ described_class.new(@note).execute
+ end
+ end
end
end
diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb
index 51491c7d529..f9e5530bc9d 100644
--- a/spec/services/projects/import_export/export_service_spec.rb
+++ b/spec/services/projects/import_export/export_service_spec.rb
@@ -8,6 +8,49 @@ describe Projects::ImportExport::ExportService do
let(:service) { described_class.new(project, user) }
let!(:after_export_strategy) { Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy.new }
+ it 'saves the version' do
+ expect(Gitlab::ImportExport::VersionSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
+ it 'saves the avatar' do
+ expect(Gitlab::ImportExport::AvatarSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
+ it 'saves the models' do
+ expect(Gitlab::ImportExport::ProjectTreeSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
+ it 'saves the uploads' do
+ expect(Gitlab::ImportExport::UploadsSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
+ it 'saves the repo' do
+ # once for the normal repo, once for the wiki
+ expect(Gitlab::ImportExport::RepoSaver).to receive(:new).twice.and_call_original
+
+ service.execute
+ end
+
+ it 'saves the lfs objects' do
+ expect(Gitlab::ImportExport::LfsSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
+ it 'saves the wiki repo' do
+ expect(Gitlab::ImportExport::WikiRepoSaver).to receive(:new).and_call_original
+
+ service.execute
+ end
+
context 'when all saver services succeed' do
before do
allow(service).to receive(:save_services).and_return(true)
diff --git a/spec/support/commit_trailers_spec_helper.rb b/spec/support/commit_trailers_spec_helper.rb
new file mode 100644
index 00000000000..add359946db
--- /dev/null
+++ b/spec/support/commit_trailers_spec_helper.rb
@@ -0,0 +1,41 @@
+module CommitTrailersSpecHelper
+ extend ActiveSupport::Concern
+
+ def expect_to_have_user_link_with_avatar(doc, user:, trailer:, email: nil)
+ wrapper = find_user_wrapper(doc, trailer)
+
+ expect_to_have_links_with_url_and_avatar(wrapper, urls.user_url(user), email || user.email)
+ expect(wrapper.attribute('data-user').value).to eq user.id.to_s
+ end
+
+ def expect_to_have_mailto_link(doc, email:, trailer:)
+ wrapper = find_user_wrapper(doc, trailer)
+
+ expect_to_have_links_with_url_and_avatar(wrapper, "mailto:#{CGI.escape_html(email)}", email)
+ end
+
+ def expect_to_have_links_with_url_and_avatar(doc, url, email)
+ expect(doc).not_to be_nil
+ expect(doc.xpath("a[position()<3 and @href='#{url}']").size).to eq 2
+ expect(doc.xpath("a[position()=3 and @href='mailto:#{CGI.escape_html(email)}']").size).to eq 1
+ expect(doc.css('img').size).to eq 1
+ end
+
+ def find_user_wrapper(doc, trailer)
+ doc.xpath("descendant-or-self::node()[@data-trailer='#{trailer}']").first
+ end
+
+ def build_commit_message(trailer:, name:, email:)
+ message = trailer_line(trailer, name, email)
+
+ [message, commit_html(message)]
+ end
+
+ def trailer_line(trailer, name, email)
+ "#{trailer} #{name} <#{email}>"
+ end
+
+ def commit_html(message)
+ "<pre>#{CGI.escape_html(message)}</pre>"
+ end
+end
diff --git a/spec/support/filtered_search_helpers.rb b/spec/support/filtered_search_helpers.rb
index f3f96bd1f0a..5f42ff77fb2 100644
--- a/spec/support/filtered_search_helpers.rb
+++ b/spec/support/filtered_search_helpers.rb
@@ -21,6 +21,29 @@ module FilteredSearchHelpers
end
end
+ # Select a label clicking in the search dropdown instead
+ # of entering label names on the input.
+ def select_label_on_dropdown(label_title)
+ input_filtered_search("label:", submit: false)
+
+ within('#js-dropdown-label') do
+ wait_for_requests
+
+ find('li', text: label_title).click
+ end
+
+ filtered_search.send_keys(:enter)
+ end
+
+ def expect_issues_list_count(open_count, closed_count = 0)
+ all_count = open_count + closed_count
+
+ expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count)
+ page.within '.issues-list' do
+ expect(page).to have_selector('.issue', count: open_count)
+ end
+ end
+
# Enables input to be added character by character
def input_filtered_search_keys(search_term)
# Add an extra space to engage visual tokens
diff --git a/spec/support/shared_examples/services/boards/issues_move_service.rb b/spec/support/shared_examples/services/boards/issues_move_service.rb
index 4a4fbaa3a0e..737863ea411 100644
--- a/spec/support/shared_examples/services/boards/issues_move_service.rb
+++ b/spec/support/shared_examples/services/boards/issues_move_service.rb
@@ -1,4 +1,4 @@
-shared_examples 'issues move service' do
+shared_examples 'issues move service' do |group|
context 'when moving an issue between lists' do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) }
let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id } }
@@ -83,5 +83,18 @@ shared_examples 'issues move service' do
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)
end
+
+ if group
+ context 'when on a group board' do
+ it 'sends the board_group_id parameter' do
+ params.merge!(move_after_id: issue1.id, move_before_id: issue2.id)
+
+ match_params = { move_between_ids: [issue1.id, issue2.id], board_group_id: parent.id }
+ expect(Issues::UpdateService).to receive(:new).with(issue.project, user, match_params).and_return(double(execute: build(:issue)))
+
+ described_class.new(parent, user, params).execute(issue)
+ end
+ end
+ end
end
end
diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb
index 5e1ce19eafb..07bc3a51fd8 100644
--- a/spec/support/slack_mattermost_notifications_shared_examples.rb
+++ b/spec/support/slack_mattermost_notifications_shared_examples.rb
@@ -4,6 +4,11 @@ RSpec.shared_examples 'slack or mattermost notifications' do
let(:chat_service) { described_class.new }
let(:webhook_url) { 'https://example.gitlab.com/' }
+ def execute_with_options(options)
+ receive(:new).with(webhook_url, options)
+ .and_return(double(:slack_service).as_null_object)
+ end
+
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
@@ -33,6 +38,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
let(:project) { create(:project, :repository) }
let(:username) { 'slack_username' }
let(:channel) { 'slack_channel' }
+ let(:issue_service_options) { { title: 'Awesome issue', description: 'please fix' } }
let(:push_sample_data) do
Gitlab::DataBuilder::Push.build_sample(project, user)
@@ -48,12 +54,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
WebMock.stub_request(:post, webhook_url)
- opts = {
- title: 'Awesome issue',
- description: 'please fix'
- }
-
- issue_service = Issues::CreateService.new(project, user, opts)
+ issue_service = Issues::CreateService.new(project, user, issue_service_options)
@issue = issue_service.execute
@issues_sample_data = issue_service.hook_data(@issue, 'open')
@@ -164,6 +165,26 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.execute(@issues_sample_data)
end
+ context 'for confidential issues' do
+ let(:issue_service_options) { { title: 'Secret', confidential: true } }
+
+ it "uses confidential issue channel" do
+ chat_service.update_attributes(confidential_issue_channel: 'confidential')
+
+ expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+
+ chat_service.execute(@issues_sample_data)
+ end
+
+ it 'falls back to issue channel' do
+ chat_service.update_attributes(issue_channel: 'fallback_channel')
+
+ expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+
+ chat_service.execute(@issues_sample_data)
+ end
+ end
+
it "uses the right channel for wiki event" do
chat_service.update_attributes(wiki_page_channel: "random")
@@ -194,6 +215,32 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.execute(note_data)
end
+
+ context 'for confidential notes' do
+ before do
+ issue_note.noteable.update!(confidential: true)
+ end
+
+ it "uses confidential channel" do
+ chat_service.update_attributes(confidential_note_channel: "confidential")
+
+ note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
+
+ expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+
+ chat_service.execute(note_data)
+ end
+
+ it 'falls back to note channel' do
+ chat_service.update_attributes(note_channel: "fallback_channel")
+
+ note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
+
+ expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+
+ chat_service.execute(note_data)
+ end
+ end
end
end
end
@@ -248,8 +295,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do
create(:note_on_issue, project: project, note: "issue note")
end
+ let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) }
+
it "calls Slack API for issue comment events" do
- data = Gitlab::DataBuilder::Note.build(issue_note, user)
chat_service.execute(data)
expect(WebMock).to have_requested(:post, webhook_url).once