From 729eabcb410add9dbcfa46677308003dc95a64d0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 31 Aug 2020 12:10:39 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../behaviors/markdown/render_math.js | 3 +- .../javascripts/lib/utils/datetime_utility.js | 20 ++- .../javascripts/lib/utils/simple_poll.js | 4 +- .../settings/components/settings_form.vue | 13 +- app/graphql/mutations/ci/pipeline_cancel.rb | 16 +- app/views/admin/services/index.html.haml | 2 +- app/views/profiles/show.html.haml | 8 +- ...-fa-search-icons-with-gitlab-svg-icons.yml | 5 + .../unreleased/233109-drop-feature-flag.yml | 5 + ...-vulnerabilities-that-do-not-have-them.yml | 5 + .../add-conan-lock-file-to-gemnasium-job.yml | 5 + ...ltsov-add-importing-issues-usage-pings.yml | 5 + .../lm-update-pipeline-mutation.yml | 5 + changelogs/unreleased/setup-policy-btn.yml | 5 + ...ument-stop-sidekiq-puma-backup-restore.yml | 5 + ...ate_missing_vulnerabilities_issue_links.rb | 48 ++++++ ...te_location_fingerprint_for_cs_findings.rb | 30 ++++ db/schema_migrations/20200811130433 | 1 + db/schema_migrations/20200824140259 | 1 + .../graphql/reference/gitlab_schema.graphql | 5 + doc/api/graphql/reference/gitlab_schema.json | 14 ++ .../load_performance_testing.md | 24 +-- ...te_location_fingerprint_for_cs_findings.rb | 13 ++ .../Load-Performance-Testing.gitlab-ci.yml | 3 +- .../Dependency-Scanning.gitlab-ci.yml | 1 + .../Load-Performance-Testing.gitlab-ci.yml | 3 +- lib/gitlab/http.rb | 2 +- lib/gitlab/usage_data.rb | 5 + .../usage_data_counters/known_events.yml | 5 + lib/tasks/gitlab/backup.rake | 5 + qa/qa/resource/api_fabricator.rb | 4 +- qa/qa/resource/fork.rb | 2 +- qa/qa/resource/group.rb | 1 - qa/qa/resource/user.rb | 2 +- .../features/api/1_manage/rate_limits_spec.rb | 2 +- .../specs/features/api/1_manage/users_spec.rb | 6 +- .../closes_issue_via_pushing_a_commit_spec.rb | 2 +- .../automatic_failover_and_recovery_spec.rb | 4 +- .../gitaly/backend_node_recovery_spec.rb | 2 +- .../changing_repository_storage_spec.rb | 4 +- .../3_create/gitaly/distributed_reads_spec.rb | 4 +- .../gitaly/praefect_replication_queue_spec.rb | 2 +- .../api/3_create/repository/files_spec.rb | 4 +- .../project_archive_compare_spec.rb | 3 +- .../api/4_verify/pipeline_deletion_spec.rb | 2 +- .../create_group_with_mattermost_team_spec.rb | 2 +- .../1_manage/group/transfer_project_spec.rb | 2 +- .../1_manage/login/2fa_recovery_spec.rb | 2 +- .../browser_ui/1_manage/login/log_in_spec.rb | 2 +- .../1_manage/login/log_in_with_2fa_spec.rb | 2 +- .../login/log_into_gitlab_via_ldap_spec.rb | 2 +- .../log_into_mattermost_via_gitlab_spec.rb | 2 +- .../login_via_instance_wide_saml_sso_spec.rb | 2 +- .../1_manage/login/register_spec.rb | 6 +- .../project/add_project_member_spec.rb | 2 +- .../1_manage/project/create_project_spec.rb | 2 +- .../1_manage/project/dashboard_images_spec.rb | 4 +- .../project/import_github_repo_spec.rb | 2 +- .../project/view_project_activity_spec.rb | 2 +- .../email/trigger_email_notification_spec.rb | 2 +- .../issue/check_mentions_for_xss_spec.rb | 2 +- .../collapse_comments_in_discussions_spec.rb | 2 +- .../2_plan/issue/comment_issue_spec.rb | 2 +- .../2_plan/issue/create_issue_spec.rb | 6 +- .../2_plan/issue/export_as_csv_spec.rb | 2 +- .../issue/filter_issue_comments_spec.rb | 2 +- .../2_plan/issue/issue_suggestions_spec.rb | 2 +- .../2_plan/issue/jira_issue_import_spec.rb | 2 +- .../browser_ui/2_plan/issue/mentions_spec.rb | 2 +- .../2_plan/issue_boards/focus_mode_spec.rb | 2 +- .../milestone/create_group_milestone_spec.rb | 2 +- .../create_project_milestone_spec.rb | 2 +- .../related_issues/related_issues_spec.rb | 2 +- .../add_design_content_spec.rb | 2 +- .../jira/jira_basic_integration_spec.rb | 4 +- .../create_merge_request_spec.rb | 4 +- .../merge_merge_request_from_fork_spec.rb | 2 +- .../rebase_merge_request_spec.rb | 2 +- .../squash_merge_request_spec.rb | 2 +- .../view_merge_request_diff_patch_spec.rb | 4 +- .../add_list_delete_branches_spec.rb | 2 +- .../3_create/repository/clone_spec.rb | 4 +- .../create_edit_delete_file_via_web_spec.rb | 2 +- .../move_project_create_fork_spec.rb | 6 +- .../repository/protocol_v2_push_http_spec.rb | 2 +- .../repository/protocol_v2_push_ssh_spec.rb | 2 +- .../push_http_private_token_spec.rb | 2 +- .../push_mirroring_over_http_spec.rb | 2 +- .../push_over_http_file_size_spec.rb | 4 +- .../repository/push_over_http_spec.rb | 4 +- .../3_create/repository/push_over_ssh_spec.rb | 4 +- .../repository/push_protected_branch_spec.rb | 4 +- .../repository/ssh_key_support_spec.rb | 4 +- .../user_views_commit_diff_patch_spec.rb | 4 +- .../clone_push_pull_personal_snippet_spec.rb | 4 +- .../clone_push_pull_project_snippet_spec.rb | 4 +- .../snippet/create_personal_snippet_spec.rb | 2 +- .../snippet/create_project_snippet_spec.rb | 2 +- .../create_first_file_in_web_ide_spec.rb | 2 +- .../web_ide/open_fork_in_web_ide_spec.rb | 4 +- .../web_ide/review_merge_request_spec.rb | 2 +- .../project_based_content_creation_spec.rb | 8 +- ...project_based_content_manipulation_spec.rb | 4 +- ...project_based_directory_management_spec.rb | 2 +- .../3_create/wiki/project_based_list_spec.rb | 4 +- .../wiki/project_based_page_deletion_spec.rb | 2 +- .../add_remove_ci_variable_spec.rb | 4 +- .../create_and_process_pipeline_spec.rb | 2 +- .../4_verify/runner/register_runner_spec.rb | 2 +- .../testing/view_code_coverage_spec.rb | 2 +- .../5_package/maven_repository_spec.rb | 2 +- .../browser_ui/5_package/npm_registry_spec.rb | 2 +- .../deploy_key/add_deploy_key_spec.rb | 2 +- .../deploy_token/add_deploy_token_spec.rb | 2 +- ...d_pipelines_dependent_relationship_spec.rb | 4 +- ...pipelines_independent_relationship_spec.rb | 4 +- .../create_project_with_auto_devops_spec.rb | 4 +- .../kubernetes/kubernetes_integration_spec.rb | 2 +- .../all_monitor_core_features_spec.rb | 10 +- .../non_devops/performance_bar_spec.rb | 2 +- .../environments/environment_item_spec.js | 4 +- .../lib/utils/datetime_utility_spec.js | 14 ++ .../releases/components/app_index_spec.js | 109 ++++++------ .../components/snippet_header_spec.js | 3 +- spec/lib/gitlab/http_spec.rb | 11 -- spec/lib/gitlab/usage_data_spec.rb | 18 +- ...issing_vulnerabilities_issue_links_spec.rb | 160 ++++++++++++++++++ .../mutations/ci/pipeline_cancel_spec.rb | 32 ++-- 128 files changed, 627 insertions(+), 250 deletions(-) create mode 100644 changelogs/unreleased/225207-replace-fa-search-icons-with-gitlab-svg-icons.yml create mode 100644 changelogs/unreleased/233109-drop-feature-flag.yml create mode 100644 changelogs/unreleased/234066-create-issuelink-for-vulnerabilities-that-do-not-have-them.yml create mode 100644 changelogs/unreleased/add-conan-lock-file-to-gemnasium-job.yml create mode 100644 changelogs/unreleased/georgekoltsov-add-importing-issues-usage-pings.yml create mode 100644 changelogs/unreleased/lm-update-pipeline-mutation.yml create mode 100644 changelogs/unreleased/setup-policy-btn.yml create mode 100644 changelogs/unreleased/sh-document-stop-sidekiq-puma-backup-restore.yml create mode 100644 db/post_migrate/20200811130433_create_missing_vulnerabilities_issue_links.rb create mode 100644 db/post_migrate/20200824140259_update_location_fingerprint_for_cs_findings.rb create mode 100644 db/schema_migrations/20200811130433 create mode 100644 db/schema_migrations/20200824140259 create mode 100644 lib/gitlab/background_migration/update_location_fingerprint_for_cs_findings.rb create mode 100644 spec/migrations/20200811130433_create_missing_vulnerabilities_issue_links_spec.rb diff --git a/app/assets/javascripts/behaviors/markdown/render_math.js b/app/assets/javascripts/behaviors/markdown/render_math.js index 03d9955f8fc..30783562da9 100644 --- a/app/assets/javascripts/behaviors/markdown/render_math.js +++ b/app/assets/javascripts/behaviors/markdown/render_math.js @@ -1,5 +1,6 @@ import { deprecatedCreateFlash as flash } from '~/flash'; import { s__, sprintf } from '~/locale'; +import { differenceInMilliseconds } from '~/lib/utils/datetime_utility'; // Renders math using KaTeX in any element with the // `js-render-math` class @@ -111,7 +112,7 @@ class SafeMathRenderer { // Give the browser time to reflow the svg waitForReflow(() => { - const deltaTime = Date.now() - this.startTime; + const deltaTime = differenceInMilliseconds(this.startTime); this.totalMS += deltaTime; this.renderElement(); diff --git a/app/assets/javascripts/lib/utils/datetime_utility.js b/app/assets/javascripts/lib/utils/datetime_utility.js index 7e3f1231a30..770923b4176 100644 --- a/app/assets/javascripts/lib/utils/datetime_utility.js +++ b/app/assets/javascripts/lib/utils/datetime_utility.js @@ -216,8 +216,9 @@ export const timeFor = (time, expiredLabel) => { return timeago.format(time, `${timeagoLanguageCode}-remaining`).trim(); }; +export const millisecondsPerDay = 1000 * 60 * 60 * 24; + export const getDayDifference = (a, b) => { - const millisecondsPerDay = 1000 * 60 * 60 * 24; const date1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate()); const date2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate()); @@ -709,7 +710,7 @@ export const dateFromParams = (year, month, day) => { * A utility function which computes the difference in seconds * between 2 dates. * - * @param {Date} startDate the start sate + * @param {Date} startDate the start date * @param {Date} endDate the end date * * @return {Int} the difference in seconds @@ -717,3 +718,18 @@ export const dateFromParams = (year, month, day) => { export const differenceInSeconds = (startDate, endDate) => { return (endDate.getTime() - startDate.getTime()) / 1000; }; + +/** + * A utility function which computes the difference in milliseconds + * between 2 dates. + * + * @param {Date|Int} startDate the start date. Can be either a date object or a unix timestamp. + * @param {Date|Int} endDate the end date. Can be either a date object or a unix timestamp. Defaults to now. + * + * @return {Int} the difference in milliseconds + */ +export const differenceInMilliseconds = (startDate, endDate = Date.now()) => { + const startDateInMS = startDate instanceof Date ? startDate.getTime() : startDate; + const endDateInMS = endDate instanceof Date ? endDate.getTime() : endDate; + return endDateInMS - startDateInMS; +}; diff --git a/app/assets/javascripts/lib/utils/simple_poll.js b/app/assets/javascripts/lib/utils/simple_poll.js index 576a9ec880c..e4e9fb2e6fa 100644 --- a/app/assets/javascripts/lib/utils/simple_poll.js +++ b/app/assets/javascripts/lib/utils/simple_poll.js @@ -1,10 +1,12 @@ +import { differenceInMilliseconds } from '~/lib/utils/datetime_utility'; + export default (fn, { interval = 2000, timeout = 60000 } = {}) => { const startTime = Date.now(); return new Promise((resolve, reject) => { const stop = arg => (arg instanceof Error ? reject(arg) : resolve(arg)); const next = () => { - if (timeout === 0 || Date.now() - startTime < timeout) { + if (timeout === 0 || differenceInMilliseconds(startTime) < timeout) { setTimeout(fn.bind(null, next, stop), interval); } else { reject(new Error('SIMPLE_POLL_TIMEOUT')); diff --git a/app/assets/javascripts/registry/settings/components/settings_form.vue b/app/assets/javascripts/registry/settings/components/settings_form.vue index f129922c1d2..7a26fb5cbee 100644 --- a/app/assets/javascripts/registry/settings/components/settings_form.vue +++ b/app/assets/javascripts/registry/settings/components/settings_form.vue @@ -1,7 +1,7 @@