diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-28 00:10:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-28 00:10:10 +0300 |
commit | 579e85eb029c4ee66e8b8cd537a94b9e6cb0e58b (patch) | |
tree | 26c28e966b7f2e4fabf06bfaa1d650ac4579f9e4 /app | |
parent | f569792df8a25caa1bed9c448c8c4c3f837f5164 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/app.vue | 15 | ||||
-rw-r--r-- | app/models/ci/job_artifact.rb | 7 | ||||
-rw-r--r-- | app/services/ci/create_job_artifacts_service.rb | 11 | ||||
-rw-r--r-- | app/services/ci/destroy_expired_job_artifacts_service.rb | 2 | ||||
-rw-r--r-- | app/views/layouts/_page.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/devise.html.haml | 4 | ||||
-rw-r--r-- | app/workers/all_queues.yml | 2 | ||||
-rw-r--r-- | app/workers/process_commit_worker.rb | 4 |
8 files changed, 39 insertions, 8 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 072bcaaad97..98c660077bb 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -7,6 +7,7 @@ import createFlash from '~/flash'; import PanelResizer from '~/vue_shared/components/panel_resizer.vue'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { isSingleViewStyle } from '~/helpers/diffs_helper'; +import { updateHistory } from '~/lib/utils/url_utility'; import eventHub from '../../notes/event_hub'; import CompareVersions from './compare_versions.vue'; import DiffFile from './diff_file.vue'; @@ -140,6 +141,20 @@ export default { }, }, watch: { + commit(newCommit, oldCommit) { + const commitChangedAfterRender = newCommit && !this.isLoading; + const commitIsDifferent = oldCommit && newCommit.id !== oldCommit.id; + const url = window?.location ? String(window.location) : ''; + + if (commitChangedAfterRender && commitIsDifferent) { + updateHistory({ + title: document.title, + url: url.replace(oldCommit.id, newCommit.id), + }); + this.refetchDiffData(); + this.adjustView(); + } + }, diffViewType() { if (this.needsReload() || this.needsFirstLoad()) { this.refetchDiffData(); diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 96bfe7f93b7..3e06fa0957c 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -70,6 +70,10 @@ module Ci TYPE_AND_FORMAT_PAIRS = INTERNAL_TYPES.merge(REPORT_TYPES).freeze + # This is required since we cannot add a default to the database + # https://gitlab.com/gitlab-org/gitlab/-/issues/215418 + attribute :locked, :boolean, default: false + belongs_to :project belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id @@ -86,6 +90,7 @@ module Ci scope :with_files_stored_locally, -> { where(file_store: [nil, ::JobArtifactUploader::Store::LOCAL]) } scope :with_files_stored_remotely, -> { where(file_store: ::JobArtifactUploader::Store::REMOTE) } scope :for_sha, ->(sha, project_id) { joins(job: :pipeline).where(ci_pipelines: { sha: sha, project_id: project_id }) } + scope :for_ref, ->(ref, project_id) { joins(job: :pipeline).where(ci_pipelines: { ref: ref, project_id: project_id }) } scope :for_job_name, ->(name) { joins(:job).where(ci_builds: { name: name }) } scope :with_file_types, -> (file_types) do @@ -121,6 +126,8 @@ module Ci end scope :expired, -> (limit) { where('expire_at < ?', Time.now).limit(limit) } + scope :locked, -> { where(locked: true) } + scope :unlocked, -> { where(locked: [false, nil]) } scope :scoped_project, -> { where('ci_job_artifacts.project_id = projects.id') } diff --git a/app/services/ci/create_job_artifacts_service.rb b/app/services/ci/create_job_artifacts_service.rb index 5d7d552dc5a..350751610e6 100644 --- a/app/services/ci/create_job_artifacts_service.rb +++ b/app/services/ci/create_job_artifacts_service.rb @@ -33,7 +33,8 @@ module Ci file_type: params['artifact_type'], file_format: params['artifact_format'], file_sha256: artifacts_file.sha256, - expire_in: expire_in) + expire_in: expire_in, + locked: true) artifact_metadata = if metadata_file Ci::JobArtifact.new( @@ -43,7 +44,8 @@ module Ci file_type: :metadata, file_format: :gzip, file_sha256: metadata_file.sha256, - expire_in: expire_in) + expire_in: expire_in, + locked: true) end [artifact, artifact_metadata] @@ -64,6 +66,7 @@ module Ci Ci::JobArtifact.transaction do artifact.save! artifact_metadata&.save! + unlock_previous_artifacts!(artifact) # NOTE: The `artifacts_expire_at` column is already deprecated and to be removed in the near future. job.update_column(:artifacts_expire_at, artifact.expire_at) @@ -81,6 +84,10 @@ module Ci error(error.message, :bad_request) end + def unlock_previous_artifacts!(artifact) + Ci::JobArtifact.for_ref(artifact.job.ref, artifact.project_id).locked.update_all(locked: false) + end + def sha256_matches_existing_artifact?(job, artifact_type, artifacts_file) existing_artifact = job.job_artifacts.find_by_file_type(artifact_type) return false unless existing_artifact diff --git a/app/services/ci/destroy_expired_job_artifacts_service.rb b/app/services/ci/destroy_expired_job_artifacts_service.rb index 7d2f5d33fed..181133ba63c 100644 --- a/app/services/ci/destroy_expired_job_artifacts_service.rb +++ b/app/services/ci/destroy_expired_job_artifacts_service.rb @@ -28,7 +28,7 @@ module Ci private def destroy_batch - artifacts = Ci::JobArtifact.expired(BATCH_SIZE).to_a + artifacts = Ci::JobArtifact.expired(BATCH_SIZE).unlocked.to_a return false if artifacts.empty? diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index 80a14412968..49345b7b215 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -5,7 +5,7 @@ .mobile-overlay .alert-wrapper = render 'shared/outdated_browser' - - if Feature.enabled?(:subscribable_banner_license) + - if Feature.enabled?(:subscribable_banner_license, default_enabled: true) = render_if_exists "layouts/header/ee_subscribable_banner" = render "layouts/broadcast" = render "layouts/header/read_only_banner" diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 6a261bbbc46..bbcb525ea4f 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -22,10 +22,10 @@ = brand_text - else %h3.mt-sm-0 - = _('Open source software to collaborate on code') + = _('A complete DevOps platform') %p - = _('Manage Git repositories with fine-grained access controls that keep your code secure. Perform code reviews and enhance collaboration with merge requests. Each project can also have an issue tracker and a wiki.') + = _('GitLab is a single application for the entire software development lifecycle. From project planning and source code management to CI/CD, monitoring, and security.') - if Gitlab::CurrentSettings.sign_in_text.present? = markdown_field(Gitlab::CurrentSettings.current_application_settings, :sign_in_text) diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml index 27e69f5d7d5..37b47897949 100644 --- a/app/workers/all_queues.yml +++ b/app/workers/all_queues.yml @@ -1234,7 +1234,7 @@ :urgency: :high :resource_boundary: :unknown :weight: 3 - :idempotent: + :idempotent: true - :name: project_cache :feature_category: :source_code_management :has_external_dependencies: diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb index 9960e812a2f..bdfabea8938 100644 --- a/app/workers/process_commit_worker.rb +++ b/app/workers/process_commit_worker.rb @@ -7,13 +7,15 @@ # result of this the workload of this worker should be kept to a bare minimum. # Consider using an extra worker if you need to add any extra (and potentially # slow) processing of commits. -class ProcessCommitWorker # rubocop:disable Scalability/IdempotentWorker +class ProcessCommitWorker include ApplicationWorker feature_category :source_code_management urgency :high weight 3 + idempotent! + # project_id - The ID of the project this commit belongs to. # user_id - The ID of the user that pushed the commit. # commit_hash - Hash containing commit details to use for constructing a |