Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-04 18:08:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-04 18:08:40 +0300
commit6b833f1e0340e00fdee074da9c42c0d4e07a46d2 (patch)
tree6fc3a7a2f8a02fec8d1e7561b453d33eb4048dad /app
parent88a0824944720b6edaaef56376713541b9a02118 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/diffs/components/diff_stats.vue2
-rw-r--r--app/assets/javascripts/error_tracking/components/error_details.vue35
-rw-r--r--app/assets/javascripts/error_tracking/store/actions.js6
-rw-r--r--app/assets/javascripts/releases/list/components/release_block_author.vue2
-rw-r--r--app/assets/javascripts/repository/components/last_commit.vue3
-rw-r--r--app/assets/javascripts/snippets/components/snippet_header.vue4
-rw-r--r--app/assets/javascripts/snippets/components/snippet_title.vue2
-rw-r--r--app/models/blob.rb19
-rw-r--r--app/models/commit.rb53
-rw-r--r--app/models/commit_collection.rb21
-rw-r--r--app/models/concerns/has_repository.rb98
-rw-r--r--app/models/project.rb73
-rw-r--r--app/models/repository.rb41
-rw-r--r--app/models/user.rb7
-rw-r--r--app/services/merge_requests/delete_non_latest_diffs_service.rb2
-rw-r--r--app/services/merge_requests/migrate_external_diffs_service.rb2
-rw-r--r--app/services/user_project_access_changed_service.rb2
-rw-r--r--app/services/users/update_service.rb6
-rw-r--r--app/workers/admin_email_worker.rb2
-rw-r--r--app/workers/ci/archive_traces_cron_worker.rb2
-rw-r--r--app/workers/container_expiration_policy_worker.rb2
-rw-r--r--app/workers/expire_build_artifacts_worker.rb2
-rw-r--r--app/workers/gitlab_usage_ping_worker.rb2
-rw-r--r--app/workers/import_export_project_cleanup_worker.rb2
-rw-r--r--app/workers/issue_due_scheduler_worker.rb4
-rw-r--r--app/workers/namespaces/prune_aggregation_schedules_worker.rb2
-rw-r--r--app/workers/pages_domain_removal_cron_worker.rb2
-rw-r--r--app/workers/pages_domain_ssl_renewal_cron_worker.rb2
-rw-r--r--app/workers/pages_domain_verification_cron_worker.rb2
-rw-r--r--app/workers/personal_access_tokens/expiring_worker.rb2
-rw-r--r--app/workers/pipeline_schedule_worker.rb2
-rw-r--r--app/workers/prune_old_events_worker.rb2
-rw-r--r--app/workers/prune_web_hook_logs_worker.rb2
-rw-r--r--app/workers/remove_expired_group_links_worker.rb2
-rw-r--r--app/workers/remove_expired_members_worker.rb2
-rw-r--r--app/workers/remove_unreferenced_lfs_objects_worker.rb2
-rw-r--r--app/workers/repository_archive_cache_worker.rb2
-rw-r--r--app/workers/repository_check/dispatch_worker.rb2
-rw-r--r--app/workers/requests_profiles_worker.rb2
-rw-r--r--app/workers/schedule_migrate_external_diffs_worker.rb2
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb2
-rw-r--r--app/workers/stuck_import_jobs_worker.rb2
-rw-r--r--app/workers/stuck_merge_jobs_worker.rb2
-rw-r--r--app/workers/trending_projects_worker.rb2
44 files changed, 259 insertions, 173 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_stats.vue b/app/assets/javascripts/diffs/components/diff_stats.vue
index 5329cb1e241..0138790cf0e 100644
--- a/app/assets/javascripts/diffs/components/diff_stats.vue
+++ b/app/assets/javascripts/diffs/components/diff_stats.vue
@@ -17,7 +17,7 @@ export default {
diffFilesLength: {
type: Number,
required: false,
- default: 0,
+ default: null,
},
},
computed: {
diff --git a/app/assets/javascripts/error_tracking/components/error_details.vue b/app/assets/javascripts/error_tracking/components/error_details.vue
index 98fc121d39f..88861b7da0e 100644
--- a/app/assets/javascripts/error_tracking/components/error_details.vue
+++ b/app/assets/javascripts/error_tracking/components/error_details.vue
@@ -2,7 +2,15 @@
import { mapActions, mapGetters, mapState } from 'vuex';
import dateFormat from 'dateformat';
import createFlash from '~/flash';
-import { GlButton, GlFormInput, GlLink, GlLoadingIcon, GlBadge } from '@gitlab/ui';
+import {
+ GlButton,
+ GlFormInput,
+ GlLink,
+ GlLoadingIcon,
+ GlBadge,
+ GlAlert,
+ GlSprintf,
+} from '@gitlab/ui';
import { __, sprintf, n__ } from '~/locale';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
import Icon from '~/vue_shared/components/icon.vue';
@@ -26,6 +34,8 @@ export default {
Icon,
Stacktrace,
GlBadge,
+ GlAlert,
+ GlSprintf,
},
directives: {
TrackEvent: TrackEventDirective,
@@ -85,6 +95,8 @@ export default {
return {
GQLerror: null,
issueCreationInProgress: false,
+ isAlertVisible: false,
+ closedIssueId: null,
};
},
computed: {
@@ -184,7 +196,14 @@ export default {
onResolveStatusUpdate() {
const status =
this.errorStatus === errorStatus.RESOLVED ? errorStatus.UNRESOLVED : errorStatus.RESOLVED;
- this.updateResolveStatus({ endpoint: this.issueUpdatePath, status });
+
+ // eslint-disable-next-line promise/catch-or-return
+ this.updateResolveStatus({ endpoint: this.issueUpdatePath, status }).then(res => {
+ this.closedIssueId = res.closed_issue_iid;
+ if (this.closedIssueId) {
+ this.isAlertVisible = true;
+ }
+ });
},
formatDate(date) {
return `${this.timeFormatted(date)} (${dateFormat(date, 'UTC:yyyy-mm-dd h:MM:ssTT Z')})`;
@@ -199,6 +218,18 @@ export default {
<gl-loading-icon :size="3" />
</div>
<div v-else-if="showDetails" class="error-details">
+ <gl-alert v-if="isAlertVisible" @dismiss="isAlertVisible = false">
+ <gl-sprintf
+ :message="
+ __('The associated issue #%{issueId} has been closed as the error is now resolved.')
+ "
+ >
+ <template #issueId>
+ <span>{{ closedIssueId }}</span>
+ </template>
+ </gl-sprintf>
+ </gl-alert>
+
<div class="top-area align-items-center justify-content-between py-3">
<span v-if="!loadingStacktrace && stacktrace" v-html="reported"></span>
<div class="d-inline-flex">
diff --git a/app/assets/javascripts/error_tracking/store/actions.js b/app/assets/javascripts/error_tracking/store/actions.js
index 49fa5f3cec5..8f6f404ef8a 100644
--- a/app/assets/javascripts/error_tracking/store/actions.js
+++ b/app/assets/javascripts/error_tracking/store/actions.js
@@ -11,9 +11,11 @@ export const setStatus = ({ commit }, status) => {
export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) =>
service
.updateErrorStatus(endpoint, status)
- .then(() => {
- if (redirectUrl) visitUrl(redirectUrl);
+ .then(resp => {
commit(types.SET_ERROR_STATUS, status);
+ if (redirectUrl) visitUrl(redirectUrl);
+
+ return resp.data.result;
})
.catch(() => createFlash(__('Failed to update issue status')));
diff --git a/app/assets/javascripts/releases/list/components/release_block_author.vue b/app/assets/javascripts/releases/list/components/release_block_author.vue
index ff6b00d8221..e7075d4d67a 100644
--- a/app/assets/javascripts/releases/list/components/release_block_author.vue
+++ b/app/assets/javascripts/releases/list/components/release_block_author.vue
@@ -27,7 +27,7 @@ export default {
<template>
<div class="d-flex">
- <gl-sprintf message="by %{user}">
+ <gl-sprintf :message="__('by %{user}')">
<template #user>
<user-avatar-link
class="prepend-left-4"
diff --git a/app/assets/javascripts/repository/components/last_commit.vue b/app/assets/javascripts/repository/components/last_commit.vue
index 573b0c4963e..c0c599f4b3c 100644
--- a/app/assets/javascripts/repository/components/last_commit.vue
+++ b/app/assets/javascripts/repository/components/last_commit.vue
@@ -146,9 +146,8 @@ export default {
v-if="commit.description"
:class="{ 'd-block': showDescription }"
class="commit-row-description append-bottom-8"
+ >{{ commit.description }}</pre
>
- {{ commit.description }}
- </pre>
</div>
<div class="commit-actions flex-row">
<div v-if="commit.signatureHtml" v-html="commit.signatureHtml"></div>
diff --git a/app/assets/javascripts/snippets/components/snippet_header.vue b/app/assets/javascripts/snippets/components/snippet_header.vue
index e8f1bfeaf43..36ba6eeecbd 100644
--- a/app/assets/javascripts/snippets/components/snippet_header.vue
+++ b/app/assets/javascripts/snippets/components/snippet_header.vue
@@ -165,7 +165,7 @@ export default {
<gl-icon :name="visibilityLevelIcon" :size="14" />
</div>
<div class="creator">
- <gl-sprintf message="Authored %{timeago} by %{author}">
+ <gl-sprintf :message="__('Authored %{timeago} by %{author}')">
<template #timeago>
<time-ago-tooltip
:time="snippet.createdAt"
@@ -218,7 +218,7 @@ export default {
errorMessage
}}</gl-alert>
- <gl-sprintf message="Are you sure you want to delete %{name}?">
+ <gl-sprintf :message="__('Are you sure you want to delete %{name}?')">
<template #name
><strong>{{ snippet.title }}</strong></template
>
diff --git a/app/assets/javascripts/snippets/components/snippet_title.vue b/app/assets/javascripts/snippets/components/snippet_title.vue
index fc8a9b4a390..6646e70f5db 100644
--- a/app/assets/javascripts/snippets/components/snippet_title.vue
+++ b/app/assets/javascripts/snippets/components/snippet_title.vue
@@ -25,7 +25,7 @@ export default {
</div>
<small v-if="snippet.updatedAt !== snippet.createdAt" class="edited-text">
- <gl-sprintf message="Edited %{timeago}">
+ <gl-sprintf :message="__('Edited %{timeago}')">
<template #timeago>
<time-ago-tooltip :time="snippet.updatedAt" tooltip-placement="bottom" />
</template>
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 258006d8d2e..d8282c918b7 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -65,7 +65,10 @@ class Blob < SimpleDelegator
BlobViewer::YarnLock
].freeze
- attr_reader :project
+ attr_reader :container
+
+ delegate :repository, to: :container, allow_nil: true
+ delegate :project, to: :repository, allow_nil: true
# Wrap a Gitlab::Git::Blob object, or return nil when given nil
#
@@ -77,22 +80,22 @@ class Blob < SimpleDelegator
#
# blob = Blob.decorate(nil)
# puts "truthy" if blob # No output
- def self.decorate(blob, project = nil)
+ def self.decorate(blob, container = nil)
return if blob.nil?
- new(blob, project)
+ new(blob, container)
end
- def self.lazy(project, commit_id, path, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
- BatchLoader.for([commit_id, path]).batch(key: project.repository) do |items, loader, args|
+ def self.lazy(container, commit_id, path, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
+ BatchLoader.for([commit_id, path]).batch(key: container.repository) do |items, loader, args|
args[:key].blobs_at(items, blob_size_limit: blob_size_limit).each do |blob|
loader.call([blob.commit_id, blob.path], blob) if blob
end
end
end
- def initialize(blob, project = nil)
- @project = project
+ def initialize(blob, container = nil)
+ @container = container
super(blob)
end
@@ -116,7 +119,7 @@ class Blob < SimpleDelegator
def load_all_data!
# Endpoint needed: https://gitlab.com/gitlab-org/gitaly/issues/756
Gitlab::GitalyClient.allow_n_plus_1_calls do
- super(project.repository) if project
+ super(repository) if container
end
end
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 31a890096e9..f2a6a8b6cbb 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -21,11 +21,14 @@ class Commit
participant :committer
participant :notes_with_associations
- attr_accessor :project, :author
+ attr_accessor :author
attr_accessor :redacted_description_html
attr_accessor :redacted_title_html
attr_accessor :redacted_full_title_html
- attr_reader :gpg_commit
+ attr_reader :gpg_commit, :container
+
+ delegate :repository, to: :container
+ delegate :project, to: :repository, allow_nil: true
DIFF_SAFE_LINES = Gitlab::Git::DiffCollection::DEFAULT_LIMITS[:max_lines]
@@ -44,12 +47,12 @@ class Commit
cache_markdown_field :description, pipeline: :commit_description
class << self
- def decorate(commits, project)
+ def decorate(commits, container)
commits.map do |commit|
if commit.is_a?(Commit)
commit
else
- self.new(commit, project)
+ self.new(commit, container)
end
end
end
@@ -85,24 +88,24 @@ class Commit
}
end
- def from_hash(hash, project)
- raw_commit = Gitlab::Git::Commit.new(project.repository.raw, hash)
- new(raw_commit, project)
+ def from_hash(hash, container)
+ raw_commit = Gitlab::Git::Commit.new(container.repository.raw, hash)
+ new(raw_commit, container)
end
def valid_hash?(key)
!!(EXACT_COMMIT_SHA_PATTERN =~ key)
end
- def lazy(project, oid)
- BatchLoader.for({ project: project, oid: oid }).batch(replace_methods: false) do |items, loader|
- items_by_project = items.group_by { |i| i[:project] }
+ def lazy(container, oid)
+ BatchLoader.for({ container: container, oid: oid }).batch(replace_methods: false) do |items, loader|
+ items_by_container = items.group_by { |i| i[:container] }
- items_by_project.each do |project, commit_ids|
+ items_by_container.each do |container, commit_ids|
oids = commit_ids.map { |i| i[:oid] }
- project.repository.commits_by(oids: oids).each do |commit|
- loader.call({ project: commit.project, oid: commit.id }, commit) if commit
+ container.repository.commits_by(oids: oids).each do |commit|
+ loader.call({ container: commit.container, oid: commit.id }, commit) if commit
end
end
end
@@ -115,12 +118,12 @@ class Commit
attr_accessor :raw
- def initialize(raw_commit, project)
+ def initialize(raw_commit, container)
raise "Nil as raw commit passed" unless raw_commit
@raw = raw_commit
- @project = project
- @gpg_commit = Gitlab::Gpg::Commit.new(self) if project
+ @container = container
+ @gpg_commit = Gitlab::Gpg::Commit.new(self) if container
end
delegate \
@@ -141,7 +144,7 @@ class Commit
end
def project_id
- project.id
+ project&.id
end
def ==(other)
@@ -269,17 +272,17 @@ class Commit
end
def parents
- @parents ||= parent_ids.map { |oid| Commit.lazy(project, oid) }
+ @parents ||= parent_ids.map { |oid| Commit.lazy(container, oid) }
end
def parent
strong_memoize(:parent) do
- project.commit_by(oid: self.parent_id) if self.parent_id
+ container.commit_by(oid: self.parent_id) if self.parent_id
end
end
def notes
- project.notes.for_commit_id(self.id)
+ container.notes.for_commit_id(self.id)
end
def user_mentions
@@ -295,7 +298,7 @@ class Commit
end
def merge_requests
- @merge_requests ||= project.merge_requests.by_commit_sha(sha)
+ @merge_requests ||= project&.merge_requests&.by_commit_sha(sha)
end
def method_missing(method, *args, &block)
@@ -330,7 +333,7 @@ class Commit
end
def cherry_pick_branch_name
- project.repository.next_branch("cherry-pick-#{short_id}", mild: true)
+ repository.next_branch("cherry-pick-#{short_id}", mild: true)
end
def cherry_pick_description(user)
@@ -418,7 +421,7 @@ class Commit
return unless entry
if entry[:type] == :blob
- blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project)
+ blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), container)
blob.image? || blob.video? || blob.audio? ? :raw : :blob
else
entry[:type]
@@ -484,7 +487,7 @@ class Commit
end
def commit_reference(from, referable_commit_id, full: false)
- base = project.to_reference_base(from, full: full)
+ base = project&.to_reference_base(from, full: full)
if base.present?
"#{base}#{self.class.reference_prefix}#{referable_commit_id}"
@@ -510,6 +513,6 @@ class Commit
end
def merged_merge_request_no_cache(user)
- MergeRequestsFinder.new(user, project_id: project.id).find_by(merge_commit_sha: id) if merge_commit?
+ MergeRequestsFinder.new(user, project_id: project_id).find_by(merge_commit_sha: id) if merge_commit?
end
end
diff --git a/app/models/commit_collection.rb b/app/models/commit_collection.rb
index d4c29aa295b..456d32bf403 100644
--- a/app/models/commit_collection.rb
+++ b/app/models/commit_collection.rb
@@ -1,17 +1,20 @@
# frozen_string_literal: true
-# A collection of Commit instances for a specific project and Git reference.
+# A collection of Commit instances for a specific container and Git reference.
class CommitCollection
include Enumerable
include Gitlab::Utils::StrongMemoize
- attr_reader :project, :ref, :commits
+ attr_reader :container, :ref, :commits
- # project - The project the commits belong to.
+ delegate :repository, to: :container, allow_nil: true
+ delegate :project, to: :repository, allow_nil: true
+
+ # container - The object the commits belong to.
# commits - The Commit instances to store.
# ref - The name of the ref (e.g. "master").
- def initialize(project, commits, ref = nil)
- @project = project
+ def initialize(container, commits, ref = nil)
+ @container = container
@commits = commits
@ref = ref
end
@@ -39,6 +42,8 @@ class CommitCollection
# Setting the pipeline for each commit ahead of time removes the need for running
# a query for every commit we're displaying.
def with_latest_pipeline(ref = nil)
+ return self unless project
+
pipelines = project.ci_pipelines.latest_pipeline_per_commit(map(&:id), ref)
each do |commit|
@@ -59,16 +64,16 @@ class CommitCollection
# Batch load any commits that are not backed by full gitaly data, and
# replace them in the collection.
def enrich!
- # A project is needed in order to fetch data from gitaly. Projects
+ # A container is needed in order to fetch data from gitaly. Containers
# can be absent from commits in certain rare situations (like when
# viewing a MR of a deleted fork). In these cases, assume that the
# enriched data is not needed.
- return self if project.blank? || fully_enriched?
+ return self if container.blank? || fully_enriched?
# Batch load full Commits from the repository
# and map to a Hash of id => Commit
replacements = Hash[unenriched.map do |c|
- [c.id, Commit.lazy(project, c.id)]
+ [c.id, Commit.lazy(container, c.id)]
end.compact]
# Replace the commits, keeping the same order
diff --git a/app/models/concerns/has_repository.rb b/app/models/concerns/has_repository.rb
new file mode 100644
index 00000000000..66c2f57bedd
--- /dev/null
+++ b/app/models/concerns/has_repository.rb
@@ -0,0 +1,98 @@
+# frozen_string_literal: true
+
+module HasRepository
+ extend ActiveSupport::Concern
+ include Gitlab::ShellAdapter
+ include AfterCommitQueue
+ include Gitlab::Utils::StrongMemoize
+
+ delegate :base_dir, :disk_path, to: :storage
+
+ def valid_repo?
+ repository.exists?
+ rescue
+ errors.add(:path, _('Invalid repository path'))
+ false
+ end
+
+ def repo_exists?
+ strong_memoize(:repo_exists) do
+ repository.exists?
+ rescue
+ false
+ end
+ end
+
+ def repository_exists?
+ !!repository.exists?
+ end
+
+ def root_ref?(branch)
+ repository.root_ref == branch
+ end
+
+ def commit(ref = 'HEAD')
+ repository.commit(ref)
+ end
+
+ def commit_by(oid:)
+ repository.commit_by(oid: oid)
+ end
+
+ def commits_by(oids:)
+ repository.commits_by(oids: oids)
+ end
+
+ def repository
+ raise NotImplementedError
+ end
+
+ def storage
+ raise NotImplementedError
+ end
+
+ def full_path
+ raise NotImplementedError
+ end
+
+ def empty_repo?
+ repository.empty?
+ end
+
+ def default_branch
+ @default_branch ||= repository.root_ref
+ end
+
+ def reload_default_branch
+ @default_branch = nil # rubocop:disable Gitlab/ModuleWithInstanceVariables
+
+ default_branch
+ end
+
+ def url_to_repo
+ gitlab_shell.url_to_repo(full_path)
+ end
+
+ def ssh_url_to_repo
+ url_to_repo
+ end
+
+ def http_url_to_repo
+ custom_root = Gitlab::CurrentSettings.custom_http_clone_url_root
+
+ url = if custom_root.present?
+ Gitlab::Utils.append_path(
+ custom_root,
+ web_url(only_path: true)
+ )
+ else
+ web_url
+ end
+
+ "#{url}.git"
+ end
+
+ def web_url(only_path: nil)
+ raise NotImplementedError
+ end
+end
diff --git a/app/models/project.rb b/app/models/project.rb
index 54bed41e9e7..31aeb0146df 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -19,6 +19,7 @@ class Project < ApplicationRecord
include ProjectFeaturesCompatibility
include SelectForProjectAuthorization
include Presentable
+ include HasRepository
include Routable
include GroupDescendant
include Gitlab::SQL::Pattern
@@ -326,7 +327,6 @@ class Project < ApplicationRecord
to: :project_feature, allow_nil: true
delegate :scheduled?, :started?, :in_progress?, :failed?, :finished?,
prefix: :import, to: :import_state, allow_nil: true
- delegate :base_dir, :disk_path, to: :storage
delegate :no_import?, to: :import_state, allow_nil: true
delegate :name, to: :owner, allow_nil: true, prefix: true
delegate :members, to: :team, prefix: true
@@ -767,10 +767,6 @@ class Project < ApplicationRecord
Feature.enabled?(:context_commits, default_enabled: true)
end
- def empty_repo?
- repository.empty?
- end
-
def team
@team ||= ProjectTeam.new(self)
end
@@ -798,18 +794,6 @@ class Project < ApplicationRecord
has_root_container_repository_tags?
end
- def commit(ref = 'HEAD')
- repository.commit(ref)
- end
-
- def commit_by(oid:)
- repository.commit_by(oid: oid)
- end
-
- def commits_by(oids:)
- repository.commits_by(oids: oids)
- end
-
# ref can't be HEAD, can only be branch/tag name
def latest_successful_build_for_ref(job_name, ref = default_branch)
return unless ref
@@ -1357,48 +1341,6 @@ class Project < ApplicationRecord
services.public_send(hooks_scope).any? # rubocop:disable GitlabSecurity/PublicSend
end
- def valid_repo?
- repository.exists?
- rescue
- errors.add(:path, _('Invalid repository path'))
- false
- end
-
- def url_to_repo
- gitlab_shell.url_to_repo(full_path)
- end
-
- def repo_exists?
- strong_memoize(:repo_exists) do
- repository.exists?
- rescue
- false
- end
- end
-
- def root_ref?(branch)
- repository.root_ref == branch
- end
-
- def ssh_url_to_repo
- url_to_repo
- end
-
- def http_url_to_repo
- custom_root = Gitlab::CurrentSettings.custom_http_clone_url_root
-
- project_url = if custom_root.present?
- Gitlab::Utils.append_path(
- custom_root,
- web_url(only_path: true)
- )
- else
- web_url
- end
-
- "#{project_url}.git"
- end
-
# Is overridden in EE
def lfs_http_url_to_repo(_)
http_url_to_repo
@@ -1538,15 +1480,6 @@ class Project < ApplicationRecord
end
end
- def default_branch
- @default_branch ||= repository.root_ref
- end
-
- def reload_default_branch
- @default_branch = nil
- default_branch
- end
-
def visibility_level_field
:visibility_level
end
@@ -1583,10 +1516,6 @@ class Project < ApplicationRecord
create_repository(force: true) unless repository_exists?
end
- def repository_exists?
- !!repository.exists?
- end
-
def wiki_repository_exists?
wiki.repository_exists?
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 9807aed07a9..d720980faab 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -22,7 +22,7 @@ class Repository
include Gitlab::RepositoryCacheAdapter
- attr_accessor :full_path, :disk_path, :project, :repo_type
+ attr_accessor :full_path, :disk_path, :container, :repo_type
delegate :ref_name_for_sha, to: :raw_repository
delegate :bundle_to_disk, to: :raw_repository
@@ -67,10 +67,10 @@ class Repository
MERGED_BRANCH_NAMES_CACHE_DURATION = 10.minutes
- def initialize(full_path, project, disk_path: nil, repo_type: Gitlab::GlRepository::PROJECT)
+ def initialize(full_path, container, disk_path: nil, repo_type: Gitlab::GlRepository::PROJECT)
@full_path = full_path
@disk_path = disk_path || full_path
- @project = project
+ @container = container
@commit_cache = {}
@repo_type = repo_type
end
@@ -97,7 +97,7 @@ class Repository
def path_to_repo
@path_to_repo ||=
begin
- storage = Gitlab.config.repositories.storages[project.repository_storage]
+ storage = Gitlab.config.repositories.storages[container.repository_storage]
File.expand_path(
File.join(storage.legacy_disk_path, disk_path + '.git')
@@ -130,7 +130,7 @@ class Repository
commits = Gitlab::Git::Commit.batch_by_oid(raw_repository, oids)
if commits.present?
- Commit.decorate(commits, project)
+ Commit.decorate(commits, container)
else
[]
end
@@ -161,14 +161,14 @@ class Repository
}
commits = Gitlab::Git::Commit.where(options)
- commits = Commit.decorate(commits, project) if commits.present?
+ commits = Commit.decorate(commits, container) if commits.present?
- CommitCollection.new(project, commits, ref)
+ CommitCollection.new(container, commits, ref)
end
def commits_between(from, to)
commits = Gitlab::Git::Commit.between(raw_repository, from, to)
- commits = Commit.decorate(commits, project) if commits.present?
+ commits = Commit.decorate(commits, container) if commits.present?
commits
end
@@ -176,7 +176,7 @@ class Repository
def new_commits(newrev)
commits = raw.new_commits(newrev)
- ::Commit.decorate(commits, project)
+ ::Commit.decorate(commits, container)
end
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/384
@@ -188,7 +188,7 @@ class Repository
commits = raw_repository.find_commits_by_message(query, ref, path, limit, offset).map do |c|
commit(c)
end
- CommitCollection.new(project, commits, ref)
+ CommitCollection.new(container, commits, ref)
end
def find_branch(name)
@@ -281,7 +281,7 @@ class Repository
raw_repository.archive_metadata(
ref,
storage_path,
- project.path,
+ project&.path,
format,
append_sha: append_sha,
path: path
@@ -499,7 +499,7 @@ class Repository
end
def blob_at(sha, path)
- blob = Blob.decorate(raw_repository.blob_at(sha, path), project)
+ blob = Blob.decorate(raw_repository.blob_at(sha, path), container)
# Don't attempt to return a special result if there is no blob at all
return unless blob
@@ -522,7 +522,7 @@ class Repository
return [] unless exists?
raw_repository.batch_blobs(items, blob_size_limit: blob_size_limit).map do |blob|
- Blob.decorate(blob, project)
+ Blob.decorate(blob, container)
end
end
@@ -701,13 +701,13 @@ class Repository
commits = raw_repository.list_last_commits_for_tree(sha, path, offset: offset, limit: limit)
commits.each do |path, commit|
- commits[path] = ::Commit.new(commit, project)
+ commits[path] = ::Commit.new(commit, container)
end
end
def last_commit_for_path(sha, path)
commit = raw_repository.last_commit_for_path(sha, path)
- ::Commit.new(commit, project) if commit
+ ::Commit.new(commit, container) if commit
end
def last_commit_id_for_path(sha, path)
@@ -986,6 +986,7 @@ class Repository
# rubocop:disable Gitlab/RailsLogger
def async_remove_remote(remote_name)
return unless remote_name
+ return unless project
job_id = RepositoryRemoveRemoteWorker.perform_async(project.id, remote_name)
@@ -1157,6 +1158,10 @@ class Repository
Gitlab::Git::Blob.batch_metadata(raw, references).map { |raw_blob| Blob.decorate(raw_blob) }
end
+ def project
+ container
+ end
+
private
# TODO Genericize finder, later split this on finders by Ref or Oid
@@ -1203,10 +1208,10 @@ class Repository
end
def initialize_raw_repository
- Gitlab::Git::Repository.new(project.repository_storage,
+ Gitlab::Git::Repository.new(container.repository_storage,
disk_path + '.git',
- repo_type.identifier_for_container(project),
- project.full_path)
+ repo_type.identifier_for_container(container),
+ container.full_path)
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index bc113c72762..d44e8162abe 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1527,6 +1527,13 @@ class User < ApplicationRecord
end
def read_only_attribute?(attribute)
+ if Feature.enabled?(:ldap_readonly_attributes, default_enabled: true)
+ enabled = Gitlab::Auth::LDAP::Config.enabled?
+ read_only = attribute.to_sym.in?(UserSyncedAttributesMetadata::SYNCABLE_ATTRIBUTES)
+
+ return true if enabled && read_only
+ end
+
user_synced_attributes_metadata&.read_only?(attribute)
end
diff --git a/app/services/merge_requests/delete_non_latest_diffs_service.rb b/app/services/merge_requests/delete_non_latest_diffs_service.rb
index bdb7ec8a7c2..49ec3c7538c 100644
--- a/app/services/merge_requests/delete_non_latest_diffs_service.rb
+++ b/app/services/merge_requests/delete_non_latest_diffs_service.rb
@@ -13,7 +13,7 @@ module MergeRequests
diffs.each_batch(of: BATCH_SIZE) do |relation, index|
ids = relation.pluck_primary_key.map { |id| [id] }
- DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids)
+ DeleteDiffFilesWorker.bulk_perform_in(index * 5.minutes, ids) # rubocop:disable Scalability/BulkPerformWithContext
end
end
end
diff --git a/app/services/merge_requests/migrate_external_diffs_service.rb b/app/services/merge_requests/migrate_external_diffs_service.rb
index 16050244637..9fa01e0a134 100644
--- a/app/services/merge_requests/migrate_external_diffs_service.rb
+++ b/app/services/merge_requests/migrate_external_diffs_service.rb
@@ -9,7 +9,7 @@ module MergeRequests
def self.enqueue!
ids = MergeRequestDiff.ids_for_external_storage_migration(limit: MAX_JOBS)
- MigrateExternalDiffsWorker.bulk_perform_async(ids.map { |id| [id] })
+ MigrateExternalDiffsWorker.bulk_perform_async(ids.map { |id| [id] }) # rubocop:disable Scalability/BulkPerformWithContext
end
def initialize(merge_request_diff)
diff --git a/app/services/user_project_access_changed_service.rb b/app/services/user_project_access_changed_service.rb
index 21b52944800..21d0861ac3f 100644
--- a/app/services/user_project_access_changed_service.rb
+++ b/app/services/user_project_access_changed_service.rb
@@ -11,7 +11,7 @@ class UserProjectAccessChangedService
if blocking
AuthorizedProjectsWorker.bulk_perform_and_wait(bulk_args)
else
- AuthorizedProjectsWorker.bulk_perform_async(bulk_args)
+ AuthorizedProjectsWorker.bulk_perform_async(bulk_args) # rubocop:disable Scalability/BulkPerformWithContext
end
end
end
diff --git a/app/services/users/update_service.rb b/app/services/users/update_service.rb
index e7667b0ca18..57209043e3b 100644
--- a/app/services/users/update_service.rb
+++ b/app/services/users/update_service.rb
@@ -53,7 +53,11 @@ module Users
end
def discard_read_only_attributes
- discard_synced_attributes
+ if Feature.enabled?(:ldap_readonly_attributes, default_enabled: true)
+ params.reject! { |key, _| @user.read_only_attribute?(key.to_sym) }
+ else
+ discard_synced_attributes
+ end
end
def discard_synced_attributes
diff --git a/app/workers/admin_email_worker.rb b/app/workers/admin_email_worker.rb
index be05d2a6752..074b59414ab 100644
--- a/app/workers/admin_email_worker.rb
+++ b/app/workers/admin_email_worker.rb
@@ -2,7 +2,7 @@
class AdminEmailWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category_not_owned!
diff --git a/app/workers/ci/archive_traces_cron_worker.rb b/app/workers/ci/archive_traces_cron_worker.rb
index 74f389175b9..c73c7ba2dd8 100644
--- a/app/workers/ci/archive_traces_cron_worker.rb
+++ b/app/workers/ci/archive_traces_cron_worker.rb
@@ -3,7 +3,7 @@
module Ci
class ArchiveTracesCronWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :continuous_integration
diff --git a/app/workers/container_expiration_policy_worker.rb b/app/workers/container_expiration_policy_worker.rb
index 595208230f6..a930dfa0186 100644
--- a/app/workers/container_expiration_policy_worker.rb
+++ b/app/workers/container_expiration_policy_worker.rb
@@ -2,7 +2,7 @@
class ContainerExpirationPolicyWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :container_registry
diff --git a/app/workers/expire_build_artifacts_worker.rb b/app/workers/expire_build_artifacts_worker.rb
index 383fd30e098..ee57bd6dfe2 100644
--- a/app/workers/expire_build_artifacts_worker.rb
+++ b/app/workers/expire_build_artifacts_worker.rb
@@ -2,7 +2,7 @@
class ExpireBuildArtifactsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :continuous_integration
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb
index ad8302a844a..577293c2d8d 100644
--- a/app/workers/gitlab_usage_ping_worker.rb
+++ b/app/workers/gitlab_usage_ping_worker.rb
@@ -4,7 +4,7 @@ class GitlabUsagePingWorker
LEASE_TIMEOUT = 86400
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category_not_owned!
diff --git a/app/workers/import_export_project_cleanup_worker.rb b/app/workers/import_export_project_cleanup_worker.rb
index 07c29d40b54..8a018024e95 100644
--- a/app/workers/import_export_project_cleanup_worker.rb
+++ b/app/workers/import_export_project_cleanup_worker.rb
@@ -2,7 +2,7 @@
class ImportExportProjectCleanupWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :importers
diff --git a/app/workers/issue_due_scheduler_worker.rb b/app/workers/issue_due_scheduler_worker.rb
index d4d47659ef0..59027907284 100644
--- a/app/workers/issue_due_scheduler_worker.rb
+++ b/app/workers/issue_due_scheduler_worker.rb
@@ -2,7 +2,7 @@
class IssueDueSchedulerWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :issue_tracking
@@ -10,7 +10,7 @@ class IssueDueSchedulerWorker
def perform
project_ids = Issue.opened.due_tomorrow.group(:project_id).pluck(:project_id).map { |id| [id] }
- MailScheduler::IssueDueWorker.bulk_perform_async(project_ids)
+ MailScheduler::IssueDueWorker.bulk_perform_async(project_ids) # rubocop:disable Scalability/BulkPerformWithContext
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/namespaces/prune_aggregation_schedules_worker.rb b/app/workers/namespaces/prune_aggregation_schedules_worker.rb
index 9a5f533fe9a..aeb5aa37a10 100644
--- a/app/workers/namespaces/prune_aggregation_schedules_worker.rb
+++ b/app/workers/namespaces/prune_aggregation_schedules_worker.rb
@@ -3,7 +3,7 @@
module Namespaces
class PruneAggregationSchedulesWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management
worker_resource_boundary :cpu
diff --git a/app/workers/pages_domain_removal_cron_worker.rb b/app/workers/pages_domain_removal_cron_worker.rb
index 07ecde55922..b14d0d4597c 100644
--- a/app/workers/pages_domain_removal_cron_worker.rb
+++ b/app/workers/pages_domain_removal_cron_worker.rb
@@ -2,7 +2,7 @@
class PagesDomainRemovalCronWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :pages
worker_resource_boundary :cpu
diff --git a/app/workers/pages_domain_ssl_renewal_cron_worker.rb b/app/workers/pages_domain_ssl_renewal_cron_worker.rb
index f7a243e9b3b..b20ed23dc89 100644
--- a/app/workers/pages_domain_ssl_renewal_cron_worker.rb
+++ b/app/workers/pages_domain_ssl_renewal_cron_worker.rb
@@ -2,7 +2,7 @@
class PagesDomainSslRenewalCronWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :pages
diff --git a/app/workers/pages_domain_verification_cron_worker.rb b/app/workers/pages_domain_verification_cron_worker.rb
index bb3a7fede9a..8bd7fe33334 100644
--- a/app/workers/pages_domain_verification_cron_worker.rb
+++ b/app/workers/pages_domain_verification_cron_worker.rb
@@ -2,7 +2,7 @@
class PagesDomainVerificationCronWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :pages
diff --git a/app/workers/personal_access_tokens/expiring_worker.rb b/app/workers/personal_access_tokens/expiring_worker.rb
index f28109c4583..b291e9ef279 100644
--- a/app/workers/personal_access_tokens/expiring_worker.rb
+++ b/app/workers/personal_access_tokens/expiring_worker.rb
@@ -3,7 +3,7 @@
module PersonalAccessTokens
class ExpiringWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :authentication_and_authorization
diff --git a/app/workers/pipeline_schedule_worker.rb b/app/workers/pipeline_schedule_worker.rb
index 19c3c5fcc2f..841308611eb 100644
--- a/app/workers/pipeline_schedule_worker.rb
+++ b/app/workers/pipeline_schedule_worker.rb
@@ -2,7 +2,7 @@
class PipelineScheduleWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :continuous_integration
worker_resource_boundary :cpu
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb
index 1d915832833..1a54b85a384 100644
--- a/app/workers/prune_old_events_worker.rb
+++ b/app/workers/prune_old_events_worker.rb
@@ -2,7 +2,7 @@
class PruneOldEventsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category_not_owned!
diff --git a/app/workers/prune_web_hook_logs_worker.rb b/app/workers/prune_web_hook_logs_worker.rb
index 69a1dd43e69..7d128a6f1ac 100644
--- a/app/workers/prune_web_hook_logs_worker.rb
+++ b/app/workers/prune_web_hook_logs_worker.rb
@@ -4,7 +4,7 @@
# table.
class PruneWebHookLogsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :integrations
diff --git a/app/workers/remove_expired_group_links_worker.rb b/app/workers/remove_expired_group_links_worker.rb
index a43e6fd11d5..db35dfb3ca8 100644
--- a/app/workers/remove_expired_group_links_worker.rb
+++ b/app/workers/remove_expired_group_links_worker.rb
@@ -2,7 +2,7 @@
class RemoveExpiredGroupLinksWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :authentication_and_authorization
diff --git a/app/workers/remove_expired_members_worker.rb b/app/workers/remove_expired_members_worker.rb
index bf209fcec9f..278adee98e9 100644
--- a/app/workers/remove_expired_members_worker.rb
+++ b/app/workers/remove_expired_members_worker.rb
@@ -2,7 +2,7 @@
class RemoveExpiredMembersWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :authentication_and_authorization
worker_resource_boundary :cpu
diff --git a/app/workers/remove_unreferenced_lfs_objects_worker.rb b/app/workers/remove_unreferenced_lfs_objects_worker.rb
index 7f2c23f4685..486f8f12014 100644
--- a/app/workers/remove_unreferenced_lfs_objects_worker.rb
+++ b/app/workers/remove_unreferenced_lfs_objects_worker.rb
@@ -2,7 +2,7 @@
class RemoveUnreferencedLfsObjectsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management
diff --git a/app/workers/repository_archive_cache_worker.rb b/app/workers/repository_archive_cache_worker.rb
index ebc83c1b17a..bbeb9d9eace 100644
--- a/app/workers/repository_archive_cache_worker.rb
+++ b/app/workers/repository_archive_cache_worker.rb
@@ -2,7 +2,7 @@
class RepositoryArchiveCacheWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management
diff --git a/app/workers/repository_check/dispatch_worker.rb b/app/workers/repository_check/dispatch_worker.rb
index d2bd5f9b967..ca1a82ed160 100644
--- a/app/workers/repository_check/dispatch_worker.rb
+++ b/app/workers/repository_check/dispatch_worker.rb
@@ -3,7 +3,7 @@
module RepositoryCheck
class DispatchWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
include ::EachShardWorker
include ExclusiveLeaseGuard
diff --git a/app/workers/requests_profiles_worker.rb b/app/workers/requests_profiles_worker.rb
index 6ab020afb10..593451eb16b 100644
--- a/app/workers/requests_profiles_worker.rb
+++ b/app/workers/requests_profiles_worker.rb
@@ -2,7 +2,7 @@
class RequestsProfilesWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management
diff --git a/app/workers/schedule_migrate_external_diffs_worker.rb b/app/workers/schedule_migrate_external_diffs_worker.rb
index 8abb5922b54..4c6f19cbc8f 100644
--- a/app/workers/schedule_migrate_external_diffs_worker.rb
+++ b/app/workers/schedule_migrate_external_diffs_worker.rb
@@ -2,7 +2,7 @@
class ScheduleMigrateExternalDiffsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
include Gitlab::ExclusiveLeaseHelpers
feature_category :source_code_management
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index d08cea9e494..7e3f7275b55 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -2,7 +2,7 @@
class StuckCiJobsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :continuous_integration
worker_resource_boundary :cpu
diff --git a/app/workers/stuck_import_jobs_worker.rb b/app/workers/stuck_import_jobs_worker.rb
index d9a9a613ca9..4a72fcedee3 100644
--- a/app/workers/stuck_import_jobs_worker.rb
+++ b/app/workers/stuck_import_jobs_worker.rb
@@ -2,7 +2,7 @@
class StuckImportJobsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :importers
worker_resource_boundary :cpu
diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb
index 024863ab530..9214ae038a8 100644
--- a/app/workers/stuck_merge_jobs_worker.rb
+++ b/app/workers/stuck_merge_jobs_worker.rb
@@ -2,7 +2,7 @@
class StuckMergeJobsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management
diff --git a/app/workers/trending_projects_worker.rb b/app/workers/trending_projects_worker.rb
index 4c8ee1ee425..5db661dd0e6 100644
--- a/app/workers/trending_projects_worker.rb
+++ b/app/workers/trending_projects_worker.rb
@@ -2,7 +2,7 @@
class TrendingProjectsWorker
include ApplicationWorker
- include CronjobQueue
+ include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
feature_category :source_code_management