Skip to content
Snippets Groups Projects
Commit 80f61b40 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 4ab54c22
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 65 deletions
Loading
Loading
@@ -5,7 +5,7 @@
# Contains functionality related to objects that support adding/removing labels.
#
# This concern is not used yet, it will be used for:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48483
# https://gitlab.com/gitlab-org/gitlab-foss/issues/48483
 
module LabelEventable
extend ActiveSupport::Concern
Loading
Loading
Loading
Loading
@@ -173,11 +173,7 @@ module ReactiveCaching
end
 
def within_reactive_cache_lifetime?(*args)
if Feature.enabled?(:reactive_caching_check_key_exists, default_enabled: true)
Rails.cache.exist?(alive_reactive_cache_key(*args))
else
!!Rails.cache.read(alive_reactive_cache_key(*args))
end
Rails.cache.exist?(alive_reactive_cache_key(*args))
end
 
def enqueuing_update(*args)
Loading
Loading
Loading
Loading
@@ -225,7 +225,7 @@ module RelativePositioning
def calculate_relative_position(calculation)
# When calculating across projects, this is much more efficient than
# MAX(relative_position) without the GROUP BY, due to index usage:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54276#note_119340977
# https://gitlab.com/gitlab-org/gitlab-foss/issues/54276#note_119340977
relation = scoped_items
.order(Gitlab::Database.nulls_last_order('position', 'DESC'))
.group(self.class.relative_positioning_parent_column)
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ module Routable
#
# Usage:
#
# Klass.find_by_full_path('gitlab-org/gitlab-ce')
# Klass.find_by_full_path('gitlab-org/gitlab-foss')
#
# Returns a single object, or nil.
def find_by_full_path(path, follow_redirects: false)
Loading
Loading
@@ -48,7 +48,7 @@ module Routable
#
# Usage:
#
# Klass.where_full_path_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee})
# Klass.where_full_path_in(%w{gitlab-org/gitlab-foss gitlab-org/gitlab})
#
# Returns an ActiveRecord::Relation.
def where_full_path_in(paths)
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ module ShaAttribute
 
# This only gets executed in non-production environments as an additional check to ensure
# the column is the correct type. In production it should behave like any other attribute.
# See https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/5502 for more discussion
# See https://gitlab.com/gitlab-org/gitlab/merge_requests/5502 for more discussion
def validate_binary_column_exists!(name)
return unless database_exists?
 
Loading
Loading
Loading
Loading
@@ -165,7 +165,7 @@ class Deployment < ApplicationRecord
def deployed_by
# We use deployable's user if available because Ci::PlayBuildService
# does not update the deployment's user, just the one for the deployable.
# TODO: use deployment's user once https://gitlab.com/gitlab-org/gitlab-ce/issues/66442
# TODO: use deployment's user once https://gitlab.com/gitlab-org/gitlab-foss/issues/66442
# is completed.
deployable&.user || user
end
Loading
Loading
Loading
Loading
@@ -54,7 +54,7 @@ class Environment < ApplicationRecord
# Search environments which have names like the given query.
# Do not set a large limit unless you've confirmed that it works on gitlab.com scale.
scope :for_name_like, -> (query, limit: 5) do
where('name LIKE ?', "#{sanitize_sql_like(query)}%").limit(limit)
where(arel_table[:name].matches("#{sanitize_sql_like query}%")).limit(limit)
end
 
scope :for_project, -> (project) { where(project_id: project) }
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ class IndividualNoteDiscussion < Discussion
def convert_to_discussion!(save: false)
first_note.becomes!(Discussion.note_class).to_discussion.tap do
# Save needs to be called on first_note instead of the transformed note
# because of https://gitlab.com/gitlab-org/gitlab-ce/issues/57324
# because of https://gitlab.com/gitlab-org/gitlab-foss/issues/57324
first_note.save if save
end
end
Loading
Loading
Loading
Loading
@@ -215,8 +215,8 @@ class Label < ApplicationRecord
#
# Label.first.to_reference # => "~1"
# Label.first.to_reference(format: :name) # => "~\"bug\""
# Label.first.to_reference(project, target_project: same_namespace_project) # => "gitlab-ce~1"
# Label.first.to_reference(project, target_project: another_namespace_project) # => "gitlab-org/gitlab-ce~1"
# Label.first.to_reference(project, target_project: same_namespace_project) # => "gitlab-foss~1"
# Label.first.to_reference(project, target_project: another_namespace_project) # => "gitlab-org/gitlab-foss~1"
#
# Returns a String
#
Loading
Loading
Loading
Loading
@@ -233,7 +233,7 @@ class MergeRequest < ApplicationRecord
 
# Use this method whenever you need to make sure the head_pipeline is synced with the
# branch head commit, for example checking if a merge request can be merged.
# For more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/40004
# For more information check: https://gitlab.com/gitlab-org/gitlab-foss/issues/40004
def actual_head_pipeline
head_pipeline&.matches_sha_or_source_sha?(diff_head_sha) ? head_pipeline : nil
end
Loading
Loading
@@ -691,7 +691,7 @@ class MergeRequest < ApplicationRecord
def create_merge_request_diff
fetch_ref!
 
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37435
# n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/37435
Gitlab::GitalyClient.allow_n_plus_1_calls do
merge_request_diffs.create!
reload_merge_request_diff
Loading
Loading
@@ -1389,7 +1389,7 @@ class MergeRequest < ApplicationRecord
end
 
# TODO: remove once production database rename completes
# https://gitlab.com/gitlab-org/gitlab-ce/issues/47592
# https://gitlab.com/gitlab-org/gitlab-foss/issues/47592
alias_attribute :allow_collaboration, :allow_maintainer_to_push
 
def allow_collaboration
Loading
Loading
Loading
Loading
@@ -301,7 +301,7 @@ class MergeRequestDiff < ApplicationRecord
if without_files? && comparison = diff_refs&.compare_in(project)
# It should fetch the repository when diffs are cleaned by the system.
# We don't keep these for storage overload purposes.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/37639
# See https://gitlab.com/gitlab-org/gitlab-foss/issues/37639
comparison.diffs(diff_options)
else
diffs_collection(diff_options)
Loading
Loading
@@ -357,7 +357,7 @@ class MergeRequestDiff < ApplicationRecord
# use factories that rely on current code with an old schema. Without these
# `has_attribute?` guards, they fail with a `MissingAttributeError`.
#
# For more details, see: https://gitlab.com/gitlab-org/gitlab-ce/issues/44990
# For more details, see: https://gitlab.com/gitlab-org/gitlab-foss/issues/44990
 
def write_uploader(column, identifier)
carrierwave_write_uploader(column, identifier) if has_attribute?(column)
Loading
Loading
Loading
Loading
@@ -215,8 +215,8 @@ class Milestone < ApplicationRecord
#
# Milestone.first.to_reference # => "%1"
# Milestone.first.to_reference(format: :name) # => "%\"goal\""
# Milestone.first.to_reference(cross_namespace_project) # => "gitlab-org/gitlab-ce%1"
# Milestone.first.to_reference(same_namespace_project) # => "gitlab-ce%1"
# Milestone.first.to_reference(cross_namespace_project) # => "gitlab-org/gitlab-foss%1"
# Milestone.first.to_reference(same_namespace_project) # => "gitlab-foss%1"
#
def to_reference(from = nil, format: :name, full: false)
format_reference = milestone_format_reference(format)
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ module Network
# Get commits from repository
#
def collect_commits
# https://gitlab.com/gitlab-org/gitlab-ce/issues/58013
# https://gitlab.com/gitlab-org/gitlab-foss/issues/58013
Gitlab::GitalyClient.allow_n_plus_1_calls do
find_commits(count_to_display_commit_in_center).map do |commit|
# Decorate with app/model/network/commit.rb
Loading
Loading
Loading
Loading
@@ -38,7 +38,7 @@ class Note < ApplicationRecord
redact_field :note
 
# Aliases to make application_helper#edited_time_ago_with_tooltip helper work properly with notes.
# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/10392/diffs#note_28719102
# See https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/10392/diffs#note_28719102
alias_attribute :last_edited_at, :updated_at
alias_attribute :last_edited_by, :updated_by
 
Loading
Loading
Loading
Loading
@@ -784,7 +784,7 @@ class Project < ApplicationRecord
if forked?
RepositoryForkWorker.perform_async(id)
elsif gitlab_project_import?
# Do not retry on Import/Export until https://gitlab.com/gitlab-org/gitlab-ce/issues/26189 is solved.
# Do not retry on Import/Export until https://gitlab.com/gitlab-org/gitlab-foss/issues/26189 is solved.
RepositoryImportWorker.set(retry: false).perform_async(self.id)
else
RepositoryImportWorker.perform_async(self.id)
Loading
Loading
@@ -1316,7 +1316,7 @@ class Project < ApplicationRecord
result = self
 
# TODO: Make this go to the fork_network root immeadiatly
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-ce/issues/39769
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-foss/issues/39769
result = result.fork_source while result&.forked?
 
result || self
Loading
Loading
@@ -1328,7 +1328,7 @@ class Project < ApplicationRecord
# 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
# https://gitlab.com/gitlab-org/gitlab-foss/issues/39769
def all_lfs_objects
lfs_storage_project.lfs_objects
end
Loading
Loading
@@ -2329,7 +2329,7 @@ class Project < ApplicationRecord
Gitlab::SafeRequestStore.fetch("project-#{id}:branch-#{branch_name}:user-#{user.id}:branch_allows_collaboration") do
next false if empty_repo?
 
# Issue for N+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/49322
# Issue for N+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/49322
Gitlab::GitalyClient.allow_n_plus_1_calls do
merge_requests_allowing_collaboration(branch_name).any? do |merge_request|
merge_request.can_be_merged_by?(user)
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ module DataFields
 
class_methods do
# Provide convenient accessor methods for data fields.
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
def data_field(*args)
args.each do |arg|
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class IssueTrackerService < Service
validate :one_issue_tracker, if: :activated?, on: :manual_change
 
# TODO: we can probably just delegate as part of
# https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
data_field :project_url, :issues_url, :new_issue_url
 
default_value_for :category, 'issue_tracker'
Loading
Loading
@@ -25,7 +25,7 @@ class IssueTrackerService < Service
end
end
 
# this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
def title
if title_attribute = read_attribute(:title)
title_attribute
Loading
Loading
@@ -36,7 +36,7 @@ class IssueTrackerService < Service
end
end
 
# this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
def description
if description_attribute = read_attribute(:description)
description_attribute
Loading
Loading
@@ -49,7 +49,7 @@ class IssueTrackerService < Service
 
def handle_properties
# this has been moved from initialize_properties and should be improved
# as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
return unless properties
 
@legacy_properties_data = properties.dup
Loading
Loading
Loading
Loading
@@ -16,10 +16,10 @@ class JiraService < IssueTrackerService
 
# Jira Cloud version is deprecating authentication via username and password.
# We should use username/password for Jira Server and email/api_token for Jira Cloud,
# for more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/49936.
# for more information check: https://gitlab.com/gitlab-org/gitlab-foss/issues/49936.
 
# TODO: we can probably just delegate as part of
# https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
# https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
data_field :username, :password, :url, :api_url, :jira_issue_transition_id
 
before_update :reset_password
Loading
Loading
@@ -298,7 +298,7 @@ class JiraService < IssueTrackerService
title: title,
status: status,
icon: {
title: 'GitLab', url16x16: asset_url(Gitlab::Favicon.main, host: gitlab_config.url)
title: 'GitLab', url16x16: asset_url(Gitlab::Favicon.main, host: gitlab_config.base_url)
}
}
}
Loading
Loading
Loading
Loading
@@ -260,28 +260,8 @@ class Repository
raw_repository.languages(root_ref)
end
 
# Makes sure a commit is kept around when Git garbage collection runs.
# Git GC will delete commits from the repository that are no longer in any
# branches or tags, but we want to keep some of these commits around, for
# example if they have comments or CI builds.
#
# For Geo's sake, pass in multiple shas rather than calling it multiple times,
# to avoid unnecessary syncing.
def keep_around(*shas)
shas.each do |sha|
next unless sha.present? && commit_by(oid: sha)
next if kept_around?(sha)
# This will still fail if the file is corrupted (e.g. 0 bytes)
raw_repository.write_ref(keep_around_ref_name(sha), sha)
rescue Gitlab::Git::CommandError => ex
Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}" # rubocop:disable Gitlab/RailsLogger
end
end
def kept_around?(sha)
ref_exists?(keep_around_ref_name(sha))
Gitlab::Git::KeepAround.execute(self, shas)
end
 
def archive_metadata(ref, storage_path, format = "tar.gz", append_sha:, path: nil)
Loading
Loading
@@ -580,7 +560,7 @@ class Repository
cache_method :has_visible_content?, fallback: false
 
def avatar
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38327
# n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/38327
Gitlab::GitalyClient.allow_n_plus_1_calls do
if tree = file_on_head(:avatar)
tree.path
Loading
Loading
@@ -1119,7 +1099,7 @@ class Repository
private
 
# TODO Generice finder, later split this on finders by Ref or Oid
# gitlab-org/gitlab-ce#39239
# https://gitlab.com/gitlab-org/gitlab-foss/issues/39239
def find_commit(oid_or_ref)
commit = if oid_or_ref.is_a?(Gitlab::Git::Commit)
oid_or_ref
Loading
Loading
@@ -1157,10 +1137,6 @@ class Repository
end
end
 
def keep_around_ref_name(sha)
"refs/#{REF_KEEP_AROUND}/#{sha}"
end
def repository_event(event, tags = {})
Gitlab::Metrics.add_event(event, tags)
end
Loading
Loading
# frozen_string_literal: true
 
# This model is not used yet, it will be used for:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48483
class ResourceLabelEvent < ApplicationRecord
include Importable
include Gitlab::Utils::StrongMemoize
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment