summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin/services_controller.rb4
-rw-r--r--app/models/ability.rb2
-rw-r--r--app/models/abuse_report.rb2
-rw-r--r--app/models/active_session.rb2
-rw-r--r--app/models/appearance.rb2
-rw-r--r--app/models/application_setting.rb2
-rw-r--r--app/models/audit_event.rb2
-rw-r--r--app/models/award_emoji.rb2
-rw-r--r--app/models/badge.rb2
-rw-r--r--app/models/blob.rb2
-rw-r--r--app/models/board.rb2
-rw-r--r--app/models/broadcast_message.rb2
-rw-r--r--app/models/chat_name.rb2
-rw-r--r--app/models/chat_team.rb2
-rw-r--r--app/models/commit.rb10
-rw-r--r--app/models/commit_range.rb2
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--app/models/compare.rb2
-rw-r--r--app/models/container_repository.rb2
-rw-r--r--app/models/cycle_analytics.rb2
-rw-r--r--app/models/dashboard_milestone.rb2
-rw-r--r--app/models/deploy_key.rb2
-rw-r--r--app/models/deploy_keys_project.rb2
-rw-r--r--app/models/deploy_token.rb2
-rw-r--r--app/models/deployment.rb2
-rw-r--r--app/models/diff_discussion.rb2
-rw-r--r--app/models/diff_note.rb2
-rw-r--r--app/models/directly_addressed_user.rb2
-rw-r--r--app/models/discussion.rb2
-rw-r--r--app/models/discussion_note.rb2
-rw-r--r--app/models/email.rb2
-rw-r--r--app/models/environment.rb4
-rw-r--r--app/models/epic.rb2
-rw-r--r--app/models/event.rb2
-rw-r--r--app/models/event_collection.rb2
-rw-r--r--app/models/external_issue.rb2
-rw-r--r--app/models/fork_network.rb2
-rw-r--r--app/models/fork_network_member.rb2
-rw-r--r--app/models/forked_project_link.rb2
-rw-r--r--app/models/generic_commit_status.rb2
-rw-r--r--app/models/global_label.rb2
-rw-r--r--app/models/global_milestone.rb2
-rw-r--r--app/models/gpg_key.rb2
-rw-r--r--app/models/gpg_key_subkey.rb2
-rw-r--r--app/models/gpg_signature.rb2
-rw-r--r--app/models/group.rb2
-rw-r--r--app/models/group_custom_attribute.rb2
-rw-r--r--app/models/group_label.rb2
-rw-r--r--app/models/group_milestone.rb2
-rw-r--r--app/models/guest.rb2
-rw-r--r--app/models/identity.rb2
-rw-r--r--app/models/import_export_upload.rb2
-rw-r--r--app/models/individual_note_discussion.rb2
-rw-r--r--app/models/instance_configuration.rb2
-rw-r--r--app/models/internal_id.rb2
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/issue_assignee.rb2
-rw-r--r--app/models/issue_collection.rb2
-rw-r--r--app/models/key.rb2
-rw-r--r--app/models/label.rb2
-rw-r--r--app/models/label_link.rb2
-rw-r--r--app/models/label_priority.rb2
-rw-r--r--app/models/legacy_diff_discussion.rb2
-rw-r--r--app/models/legacy_diff_note.rb2
-rw-r--r--app/models/lfs_file_lock.rb2
-rw-r--r--app/models/lfs_object.rb2
-rw-r--r--app/models/lfs_objects_project.rb2
-rw-r--r--app/models/list.rb2
-rw-r--r--app/models/member.rb2
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--app/models/merge_request_diff.rb10
-rw-r--r--app/models/merge_request_diff_commit.rb2
-rw-r--r--app/models/merge_request_diff_file.rb2
-rw-r--r--app/models/merge_requests_closing_issues.rb2
-rw-r--r--app/models/milestone.rb2
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/note.rb2
-rw-r--r--app/models/note_diff_file.rb2
-rw-r--r--app/models/notification_reason.rb2
-rw-r--r--app/models/notification_recipient.rb2
-rw-r--r--app/models/notification_setting.rb2
-rw-r--r--app/models/oauth_access_grant.rb2
-rw-r--r--app/models/oauth_access_token.rb2
-rw-r--r--app/models/out_of_context_discussion.rb2
-rw-r--r--app/models/pages_domain.rb2
-rw-r--r--app/models/personal_access_token.rb2
-rw-r--r--app/models/personal_snippet.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/project_authorization.rb2
-rw-r--r--app/models/project_auto_devops.rb2
-rw-r--r--app/models/project_ci_cd_setting.rb2
-rw-r--r--app/models/project_custom_attribute.rb2
-rw-r--r--app/models/project_deploy_token.rb2
-rw-r--r--app/models/project_feature.rb2
-rw-r--r--app/models/project_group_link.rb2
-rw-r--r--app/models/project_import_data.rb2
-rw-r--r--app/models/project_import_state.rb2
-rw-r--r--app/models/project_label.rb2
-rw-r--r--app/models/project_snippet.rb2
-rw-r--r--app/models/project_statistics.rb2
-rw-r--r--app/models/project_team.rb2
-rw-r--r--app/models/protectable_dropdown.rb2
-rw-r--r--app/models/protected_branch.rb2
-rw-r--r--app/models/protected_ref_matcher.rb2
-rw-r--r--app/models/protected_tag.rb2
-rw-r--r--app/models/push_event.rb2
-rw-r--r--app/models/push_event_payload.rb2
-rw-r--r--app/models/readme_blob.rb2
-rw-r--r--app/models/redirect_route.rb2
-rw-r--r--app/models/release.rb2
-rw-r--r--app/models/remote_mirror.rb2
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/route.rb2
-rw-r--r--app/models/security_event.rb2
-rw-r--r--app/models/sent_notification.rb2
-rw-r--r--app/models/service.rb2
-rw-r--r--app/models/snippet.rb2
-rw-r--r--app/models/snippet_blob.rb2
-rw-r--r--app/models/spam_log.rb2
-rw-r--r--app/models/subscription.rb2
-rw-r--r--app/models/system_note_metadata.rb2
-rw-r--r--app/models/term_agreement.rb2
-rw-r--r--app/models/timelog.rb2
-rw-r--r--app/models/todo.rb2
-rw-r--r--app/models/tree.rb2
-rw-r--r--app/models/trending_project.rb2
-rw-r--r--app/models/u2f_registration.rb2
-rw-r--r--app/models/upload.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--app/models/user_agent_detail.rb2
-rw-r--r--app/models/user_callout.rb2
-rw-r--r--app/models/user_custom_attribute.rb2
-rw-r--r--app/models/user_interacted_project.rb2
-rw-r--r--app/models/user_synced_attributes_metadata.rb2
-rw-r--r--app/models/users_star_project.rb2
-rw-r--r--app/models/wiki_directory.rb2
-rw-r--r--app/models/wiki_page.rb2
-rw-r--r--app/views/projects/jobs/show.html.haml2
-rw-r--r--app/views/projects/settings/ci_cd/show.html.haml2
-rw-r--r--changelogs/unreleased/48246-osw-load-diffs-improvement.yml5
-rw-r--r--changelogs/unreleased/49851-link-to-runners.yml6
-rw-r--r--changelogs/unreleased/frozen-string-enable-app-models.yml5
-rw-r--r--doc/user/profile/account/two_factor_authentication.md2
-rw-r--r--lib/gitlab/bare_repository_import/importer.rb36
-rw-r--r--lib/gitlab/bare_repository_import/repository.rb2
-rw-r--r--lib/gitlab/git/repository.rb13
-rw-r--r--spec/controllers/admin/services_controller_spec.rb2
-rw-r--r--spec/lib/gitlab/bare_repository_import/importer_spec.rb54
-rw-r--r--spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb2
-rw-r--r--spec/lib/gitlab/git/attributes_parser_spec.rb2
-rw-r--r--spec/lib/gitlab/git/blame_spec.rb2
-rw-r--r--spec/lib/gitlab/git/blob_snippet_spec.rb2
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb2
-rw-r--r--spec/lib/gitlab/git/branch_spec.rb2
-rw-r--r--spec/lib/gitlab/git/commit_spec.rb2
-rw-r--r--spec/lib/gitlab/git/committer_with_hooks_spec.rb2
-rw-r--r--spec/lib/gitlab/git/compare_spec.rb2
-rw-r--r--spec/lib/gitlab/git/diff_collection_spec.rb2
-rw-r--r--spec/lib/gitlab/git/diff_spec.rb2
-rw-r--r--spec/lib/gitlab/git/hooks_service_spec.rb2
-rw-r--r--spec/lib/gitlab/git/index_spec.rb2
-rw-r--r--spec/lib/gitlab/git/remote_repository_spec.rb2
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb2
-rw-r--r--spec/lib/gitlab/git/tag_spec.rb2
-rw-r--r--spec/lib/gitlab/git/tree_spec.rb2
-rw-r--r--spec/models/merge_request_diff_spec.rb7
-rw-r--r--spec/support/helpers/seed_helper.rb6
-rw-r--r--spec/support/helpers/test_env.rb8
-rw-r--r--spec/support/stored_repositories.rb4
169 files changed, 387 insertions, 95 deletions
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
index e70aa549140..91a36af34f3 100644
--- a/app/controllers/admin/services_controller.rb
+++ b/app/controllers/admin/services_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Admin::ServicesController < Admin::ApplicationController
include ServiceParams
@@ -30,7 +32,7 @@ class Admin::ServicesController < Admin::ApplicationController
def services_templates
Service.available_services_names.map do |service_name|
- service_template = service_name.concat("_service").camelize.constantize
+ service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index bb600eaccba..a853106e5bd 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require_dependency 'declarative_policy'
class Ability
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index 4cbd90c5817..1b78fd04ebb 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class AbuseReport < ActiveRecord::Base
include CacheMarkdownField
diff --git a/app/models/active_session.rb b/app/models/active_session.rb
index b4a86dbb331..0d9c6a4a1f0 100644
--- a/app/models/active_session.rb
+++ b/app/models/active_session.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ActiveSession
include ActiveModel::Model
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index b770aadef0e..bffba3e13fa 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Appearance < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 17297769e7e..bbe7811841a 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ApplicationSetting < ActiveRecord::Base
include CacheableAttributes
include CacheMarkdownField
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 112a8778b4e..8508c88d406 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class AuditEvent < ActiveRecord::Base
serialize :details, Hash # rubocop:disable Cop/ActiveRecordSerialize
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index 4d1a15c53aa..99c7866d636 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class AwardEmoji < ActiveRecord::Base
DOWNVOTE_NAME = "thumbsdown".freeze
UPVOTE_NAME = "thumbsup".freeze
diff --git a/app/models/badge.rb b/app/models/badge.rb
index 265c5d872d4..7e3b6b659e4 100644
--- a/app/models/badge.rb
+++ b/app/models/badge.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Badge < ActiveRecord::Base
# This structure sets the placeholders that the urls
# can have. This hash also sets which action to ask when
diff --git a/app/models/blob.rb b/app/models/blob.rb
index 71c974b4c09..acc64ffca67 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Blob is a Rails-specific wrapper around Gitlab::Git::Blob objects
class Blob < SimpleDelegator
CACHE_TIME = 60 # Cache raw blobs referred to by a (mutable) ref for 1 minute
diff --git a/app/models/board.rb b/app/models/board.rb
index bb6bb753daf..a137863456c 100644
--- a/app/models/board.rb
+++ b/app/models/board.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Board < ActiveRecord::Base
belongs_to :group
belongs_to :project
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 4aa236555cb..baf8adb318b 100644
--- a/app/models/broadcast_message.rb
+++ b/app/models/broadcast_message.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class BroadcastMessage < ActiveRecord::Base
include CacheMarkdownField
include Sortable
diff --git a/app/models/chat_name.rb b/app/models/chat_name.rb
index fbd0f123341..03b0af53046 100644
--- a/app/models/chat_name.rb
+++ b/app/models/chat_name.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ChatName < ActiveRecord::Base
LAST_USED_AT_INTERVAL = 1.hour
diff --git a/app/models/chat_team.rb b/app/models/chat_team.rb
index 25ecf2d5937..4e724f9adf7 100644
--- a/app/models/chat_team.rb
+++ b/app/models/chat_team.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ChatTeam < ActiveRecord::Base
validates :team_id, presence: true
validates :namespace, uniqueness: true
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 56d4c86774e..8b9f4490ffa 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -1,4 +1,6 @@
# coding: utf-8
+# frozen_string_literal: true
+
class Commit
extend ActiveModel::Naming
extend Gitlab::Cache::RequestCache
@@ -339,21 +341,21 @@ class Commit
end
def cherry_pick_description(user)
- message_body = "(cherry picked from commit #{sha})"
+ message_body = ["(cherry picked from commit #{sha})"]
if merged_merge_request?(user)
commits_in_merge_request = merged_merge_request(user).commits
if commits_in_merge_request.present?
- message_body << "\n"
+ message_body << ""
commits_in_merge_request.reverse.each do |commit_in_merge|
- message_body << "\n#{commit_in_merge.short_id} #{commit_in_merge.title}"
+ message_body << "#{commit_in_merge.short_id} #{commit_in_merge.title}"
end
end
end
- message_body
+ message_body.join("\n")
end
def cherry_pick_message(user)
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb
index b93c111dabc..094747ee48d 100644
--- a/app/models/commit_range.rb
+++ b/app/models/commit_range.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# CommitRange makes it easier to work with commit ranges
#
# Examples:
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 8b1093655b7..b65d7672973 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class CommitStatus < ActiveRecord::Base
include HasStatus
include Importable
diff --git a/app/models/compare.rb b/app/models/compare.rb
index feb4b89c781..b2d46ada831 100644
--- a/app/models/compare.rb
+++ b/app/models/compare.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Compare
include Gitlab::Utils::StrongMemoize
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb
index d0c94d3b694..41413854d5c 100644
--- a/app/models/container_repository.rb
+++ b/app/models/container_repository.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ContainerRepository < ActiveRecord::Base
belongs_to :project
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb
index b34d1382d43..d0f5b6970b1 100644
--- a/app/models/cycle_analytics.rb
+++ b/app/models/cycle_analytics.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class CycleAnalytics
STAGES = %i[issue plan code test review staging production].freeze
diff --git a/app/models/dashboard_milestone.rb b/app/models/dashboard_milestone.rb
index 86eb4ec76fc..96bc8090b81 100644
--- a/app/models/dashboard_milestone.rb
+++ b/app/models/dashboard_milestone.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class DashboardMilestone < GlobalMilestone
def issues_finder_params
{ authorized_only: true }
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb
index 89a74b7dcb1..fd5d7726fb6 100644
--- a/app/models/deploy_key.rb
+++ b/app/models/deploy_key.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class DeployKey < Key
include IgnorableColumn
diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb
index 6eef12c4373..71fd02fac86 100644
--- a/app/models/deploy_keys_project.rb
+++ b/app/models/deploy_keys_project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class DeployKeysProject < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_key, inverse_of: :deploy_keys_projects
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index fdbe95059e5..c466304a827 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class DeployToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 687246b47b2..6962b54441b 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Deployment < ActiveRecord::Base
include AtomicInternalId
include IidRoutes
diff --git a/app/models/diff_discussion.rb b/app/models/diff_discussion.rb
index bd6af622bfb..93e3ebf7896 100644
--- a/app/models/diff_discussion.rb
+++ b/app/models/diff_discussion.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A discussion on merge request or commit diffs consisting of `DiffNote` notes.
#
# A discussion of this type can be resolvable.
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index d752d5bcdee..58d949315e0 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A note on merge request or commit diffs
#
# A note of this type can be resolvable.
diff --git a/app/models/directly_addressed_user.rb b/app/models/directly_addressed_user.rb
index 0d519c6ac22..06df2d6c012 100644
--- a/app/models/directly_addressed_user.rb
+++ b/app/models/directly_addressed_user.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class DirectlyAddressedUser
class << self
def reference_pattern
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 35a0ef00856..dbc7b6e67be 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A non-diff discussion on an issue, merge request, commit, or snippet, consisting of `DiscussionNote` notes.
#
# A discussion of this type can be resolvable.
diff --git a/app/models/discussion_note.rb b/app/models/discussion_note.rb
index e660b024083..89d86aaed66 100644
--- a/app/models/discussion_note.rb
+++ b/app/models/discussion_note.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A note in a non-diff discussion on an issue, merge request, commit, or snippet.
#
# A note of this type can be resolvable.
diff --git a/app/models/email.rb b/app/models/email.rb
index 15bdedeac33..b6a977dfa22 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Email < ActiveRecord::Base
include Sortable
include Gitlab::SQL::Pattern
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 4856d313318..c8d1d378ae0 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Environment < ActiveRecord::Base
# Used to generate random suffixes for the slug
LETTERS = 'a'..'z'
@@ -173,7 +175,7 @@ class Environment < ActiveRecord::Base
# * cannot end with `-`
def generate_slug
# Lowercase letters and numbers only
- slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
+ slugified = +name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
# Must start with a letter
slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0])
diff --git a/app/models/epic.rb b/app/models/epic.rb
index 286b855de3f..f027993376c 100644
--- a/app/models/epic.rb
+++ b/app/models/epic.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Placeholder class for model that is implemented in EE
# It reserves '&' as a reference prefix, but the table does not exists in CE
class Epic < ActiveRecord::Base
diff --git a/app/models/event.rb b/app/models/event.rb
index ac0b1c7b27c..ba28866e8e6 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Event < ActiveRecord::Base
include Sortable
include IgnorableColumn
diff --git a/app/models/event_collection.rb b/app/models/event_collection.rb
index 8b8244314af..a4c69b11781 100644
--- a/app/models/event_collection.rb
+++ b/app/models/event_collection.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A collection of events to display in an event list.
#
# An EventCollection is meant to be used for displaying events to a user (e.g.
diff --git a/app/models/external_issue.rb b/app/models/external_issue.rb
index 282fd7edcb7..4f73beaafc5 100644
--- a/app/models/external_issue.rb
+++ b/app/models/external_issue.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ExternalIssue
include Referable
diff --git a/app/models/fork_network.rb b/app/models/fork_network.rb
index 7f1728e8c77..1b9bf93cbbc 100644
--- a/app/models/fork_network.rb
+++ b/app/models/fork_network.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ForkNetwork < ActiveRecord::Base
belongs_to :root_project, class_name: 'Project'
has_many :fork_network_members
diff --git a/app/models/fork_network_member.rb b/app/models/fork_network_member.rb
index eb9417dc34f..36c66f21b0b 100644
--- a/app/models/fork_network_member.rb
+++ b/app/models/fork_network_member.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ForkNetworkMember < ActiveRecord::Base
belongs_to :fork_network
belongs_to :project
diff --git a/app/models/forked_project_link.rb b/app/models/forked_project_link.rb
index 8d35864eff6..0f7067238cd 100644
--- a/app/models/forked_project_link.rb
+++ b/app/models/forked_project_link.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ForkedProjectLink < ActiveRecord::Base
belongs_to :forked_to_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
belongs_to :forked_from_project, -> { where.not(pending_delete: true) }, class_name: 'Project'
diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb
index 5ac8bde44cd..3028bf21301 100644
--- a/app/models/generic_commit_status.rb
+++ b/app/models/generic_commit_status.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GenericCommitStatus < CommitStatus
before_validation :set_default_values
diff --git a/app/models/global_label.rb b/app/models/global_label.rb
index 2a1b7564962..c5b2492bbf6 100644
--- a/app/models/global_label.rb
+++ b/app/models/global_label.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GlobalLabel
attr_accessor :title, :labels
alias_attribute :name, :title
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index dc2f6817190..2ddad9b6b0b 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GlobalMilestone
include Milestoneish
diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb
index 44eda741679..077afffd358 100644
--- a/app/models/gpg_key.rb
+++ b/app/models/gpg_key.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GpgKey < ActiveRecord::Base
KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze
KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze
diff --git a/app/models/gpg_key_subkey.rb b/app/models/gpg_key_subkey.rb
index b57922aba30..440b588bc78 100644
--- a/app/models/gpg_key_subkey.rb
+++ b/app/models/gpg_key_subkey.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GpgKeySubkey < ActiveRecord::Base
include ShaAttribute
diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb
index bf88d75246f..0816778deae 100644
--- a/app/models/gpg_signature.rb
+++ b/app/models/gpg_signature.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GpgSignature < ActiveRecord::Base
include ShaAttribute
diff --git a/app/models/group.rb b/app/models/group.rb
index ddebaff50b0..cd548fc0061 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'carrierwave/orm/activerecord'
class Group < Namespace
diff --git a/app/models/group_custom_attribute.rb b/app/models/group_custom_attribute.rb
index 8157d602d67..22f14885657 100644
--- a/app/models/group_custom_attribute.rb
+++ b/app/models/group_custom_attribute.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GroupCustomAttribute < ActiveRecord::Base
belongs_to :group
diff --git a/app/models/group_label.rb b/app/models/group_label.rb
index 92c83b54861..ff14529c6e6 100644
--- a/app/models/group_label.rb
+++ b/app/models/group_label.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GroupLabel < Label
belongs_to :group
diff --git a/app/models/group_milestone.rb b/app/models/group_milestone.rb
index 98135ee3c8b..d6ab32ea7c8 100644
--- a/app/models/group_milestone.rb
+++ b/app/models/group_milestone.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class GroupMilestone < GlobalMilestone
attr_accessor :group
diff --git a/app/models/guest.rb b/app/models/guest.rb
index df287c277a7..9c8097e1ac8 100644
--- a/app/models/guest.rb
+++ b/app/models/guest.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Guest
class << self
def can?(action, subject = :global)
diff --git a/app/models/identity.rb b/app/models/identity.rb
index 3fd0c5e751d..f5a13dbd6f2 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Identity < ActiveRecord::Base
def self.uniqueness_scope
:provider
diff --git a/app/models/import_export_upload.rb b/app/models/import_export_upload.rb
index 60d53d6c2c8..40795d7c42f 100644
--- a/app/models/import_export_upload.rb
+++ b/app/models/import_export_upload.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ImportExportUpload < ActiveRecord::Base
include WithUploads
include ObjectStorage::BackgroundMove
diff --git a/app/models/individual_note_discussion.rb b/app/models/individual_note_discussion.rb
index 6be8ca45739..07ee7470ea2 100644
--- a/app/models/individual_note_discussion.rb
+++ b/app/models/individual_note_discussion.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A discussion to wrap a single `Note` note on the root of an issue, merge request,
# commit, or snippet, that is not displayed as a discussion.
#
diff --git a/app/models/instance_configuration.rb b/app/models/instance_configuration.rb
index b30b707e5fe..7d8ce0bbd05 100644
--- a/app/models/instance_configuration.rb
+++ b/app/models/instance_configuration.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'resolv'
class InstanceConfiguration
diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb
index e5d0f94073c..4eb211eff61 100644
--- a/app/models/internal_id.rb
+++ b/app/models/internal_id.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# An InternalId is a strictly monotone sequence of integers
# generated for a given scope and usage.
#
diff --git a/app/models/issue.rb b/app/models/issue.rb
index e4ed06f9a69..0d135f54038 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'carrierwave/orm/activerecord'
class Issue < ActiveRecord::Base
diff --git a/app/models/issue_assignee.rb b/app/models/issue_assignee.rb
index 326b9eb7ad5..400c0256945 100644
--- a/app/models/issue_assignee.rb
+++ b/app/models/issue_assignee.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class IssueAssignee < ActiveRecord::Base
belongs_to :issue
belongs_to :assignee, class_name: "User", foreign_key: :user_id
diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb
index 49f011c113f..05607fc3a08 100644
--- a/app/models/issue_collection.rb
+++ b/app/models/issue_collection.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# IssueCollection can be used to reduce a list of issues down to a subset.
#
# IssueCollection is not meant to be some sort of Enumerable, instead it's meant
diff --git a/app/models/key.rb b/app/models/key.rb
index ae5769c0627..3bb0d2f6f9c 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'digest/md5'
class Key < ActiveRecord::Base
diff --git a/app/models/label.rb b/app/models/label.rb
index 7b08547fa6e..96c1515b41a 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Label < ActiveRecord::Base
include CacheMarkdownField
include Referable
diff --git a/app/models/label_link.rb b/app/models/label_link.rb
index d68e1f54317..779657b25d5 100644
--- a/app/models/label_link.rb
+++ b/app/models/label_link.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class LabelLink < ActiveRecord::Base
include Importable
diff --git a/app/models/label_priority.rb b/app/models/label_priority.rb
index 5b85e0b6533..8ed8bb7577f 100644
--- a/app/models/label_priority.rb
+++ b/app/models/label_priority.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class LabelPriority < ActiveRecord::Base
belongs_to :project
belongs_to :label
diff --git a/app/models/legacy_diff_discussion.rb b/app/models/legacy_diff_discussion.rb
index 80fc6304fd4..7d78c580fa2 100644
--- a/app/models/legacy_diff_discussion.rb
+++ b/app/models/legacy_diff_discussion.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A discussion on merge request or commit diffs consisting of `LegacyDiffNote` notes.
#
# All new diff discussions are of the type `DiffDiscussion`, but any diff discussions created
diff --git a/app/models/legacy_diff_note.rb b/app/models/legacy_diff_note.rb
index d90cafd14b4..20f9b18e4ca 100644
--- a/app/models/legacy_diff_note.rb
+++ b/app/models/legacy_diff_note.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A note on merge request or commit diffs, using the legacy implementation.
#
# All new diff notes are of the type `DiffNote`, but any diff notes created
diff --git a/app/models/lfs_file_lock.rb b/app/models/lfs_file_lock.rb
index 50bb6ca382d..431d37e12e9 100644
--- a/app/models/lfs_file_lock.rb
+++ b/app/models/lfs_file_lock.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class LfsFileLock < ActiveRecord::Base
belongs_to :project
belongs_to :user
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index 84487031ee5..2a1a4ef48b7 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class LfsObject < ActiveRecord::Base
include AfterCommitQueue
include ObjectStorage::BackgroundMove
diff --git a/app/models/lfs_objects_project.rb b/app/models/lfs_objects_project.rb
index b0625c52b62..353602800d7 100644
--- a/app/models/lfs_objects_project.rb
+++ b/app/models/lfs_objects_project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class LfsObjectsProject < ActiveRecord::Base
belongs_to :project
belongs_to :lfs_object
diff --git a/app/models/list.rb b/app/models/list.rb
index 4edcfa78835..eabe3ffccbb 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class List < ActiveRecord::Base
belongs_to :board
belongs_to :label
diff --git a/app/models/member.rb b/app/models/member.rb
index 00a13a279a9..05c0bc8cb97 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Member < ActiveRecord::Base
include AfterCommitQueue
include Sortable
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 124ff6b3f91..06642c15585 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class MergeRequest < ActiveRecord::Base
include AtomicInternalId
include IidRoutes
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index a073bbfad20..d9393b4e545 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class MergeRequestDiff < ActiveRecord::Base
include Sortable
include Importable
@@ -249,15 +251,13 @@ class MergeRequestDiff < ActiveRecord::Base
end
def load_diffs(options)
- raw = merge_request_diff_files.map(&:to_hash)
+ collection = merge_request_diff_files
if paths = options[:paths]
- raw = raw.select do |diff|
- paths.include?(diff[:old_path]) || paths.include?(diff[:new_path])
- end
+ collection = collection.where('old_path IN (?) OR new_path IN (?)', paths, paths)
end
- Gitlab::Git::DiffCollection.new(raw, options)
+ Gitlab::Git::DiffCollection.new(collection.map(&:to_hash), options)
end
def load_commits
diff --git a/app/models/merge_request_diff_commit.rb b/app/models/merge_request_diff_commit.rb
index 1c2e57bb01f..4ad3690512d 100644
--- a/app/models/merge_request_diff_commit.rb
+++ b/app/models/merge_request_diff_commit.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class MergeRequestDiffCommit < ActiveRecord::Base
include ShaAttribute
diff --git a/app/models/merge_request_diff_file.rb b/app/models/merge_request_diff_file.rb
index cd8ba6b904d..a9f110bec5c 100644
--- a/app/models/merge_request_diff_file.rb
+++ b/app/models/merge_request_diff_file.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class MergeRequestDiffFile < ActiveRecord::Base
include Gitlab::EncodingHelper
include DiffFile
diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb
index 7f7c114803d..242b65bedc0 100644
--- a/app/models/merge_requests_closing_issues.rb
+++ b/app/models/merge_requests_closing_issues.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class MergeRequestsClosingIssues < ActiveRecord::Base
belongs_to :merge_request
belongs_to :issue
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index d0f7f9c3593..f2b2d291da9 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Milestone < ActiveRecord::Base
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index de06e080a7d..b974309aeb6 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Namespace < ActiveRecord::Base
include CacheMarkdownField
include Sortable
diff --git a/app/models/note.rb b/app/models/note.rb
index 87cf7c7b2fa..969d34ae09a 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# A note on the root of an issue, merge request, commit, or snippet.
#
# A note of this type is never resolvable.
diff --git a/app/models/note_diff_file.rb b/app/models/note_diff_file.rb
index e688018a6d9..27aef7adc48 100644
--- a/app/models/note_diff_file.rb
+++ b/app/models/note_diff_file.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class NoteDiffFile < ActiveRecord::Base
include DiffFile
diff --git a/app/models/notification_reason.rb b/app/models/notification_reason.rb
index c3965565022..0a13487574f 100644
--- a/app/models/notification_reason.rb
+++ b/app/models/notification_reason.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Holds reasons for a notification to have been sent as well as a priority list to select which reason to use
# above the rest
class NotificationReason
diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb
index 1a03dd9df56..9f16eefe074 100644
--- a/app/models/notification_recipient.rb
+++ b/app/models/notification_recipient.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class NotificationRecipient
include Gitlab::Utils::StrongMemoize
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index 1933c46ee44..1df3a51a7fc 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class NotificationSetting < ActiveRecord::Base
include IgnorableColumn
diff --git a/app/models/oauth_access_grant.rb b/app/models/oauth_access_grant.rb
index 3a997406565..d5a8a1a25b6 100644
--- a/app/models/oauth_access_grant.rb
+++ b/app/models/oauth_access_grant.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class OauthAccessGrant < Doorkeeper::AccessGrant
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'
diff --git a/app/models/oauth_access_token.rb b/app/models/oauth_access_token.rb
index e8595b13d6d..0aa920fa828 100644
--- a/app/models/oauth_access_token.rb
+++ b/app/models/oauth_access_token.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class OauthAccessToken < Doorkeeper::AccessToken
belongs_to :resource_owner, class_name: 'User'
belongs_to :application, class_name: 'Doorkeeper::Application'
diff --git a/app/models/out_of_context_discussion.rb b/app/models/out_of_context_discussion.rb
index 4227c40b69a..4de717e2c51 100644
--- a/app/models/out_of_context_discussion.rb
+++ b/app/models/out_of_context_discussion.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# When notes on a commit are displayed in the context of a merge request that
# contains that commit, they are displayed as if they were a discussion.
#
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index bfea64c3759..7739a3894d3 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class PagesDomain < ActiveRecord::Base
VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
VERIFICATION_THRESHOLD = 3.days.freeze
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb
index 063dc521324..207146479c0 100644
--- a/app/models/personal_access_token.rb
+++ b/app/models/personal_access_token.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class PersonalAccessToken < ActiveRecord::Base
include Expirable
include TokenAuthenticatable
diff --git a/app/models/personal_snippet.rb b/app/models/personal_snippet.rb
index 355624fd552..1b5be8698b1 100644
--- a/app/models/personal_snippet.rb
+++ b/app/models/personal_snippet.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class PersonalSnippet < Snippet
include WithUploads
end
diff --git a/app/models/project.rb b/app/models/project.rb
index af32afc08e2..16d63639141 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'carrierwave/orm/activerecord'
class Project < ActiveRecord::Base
diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb
index 73302207e6b..746bb4584c9 100644
--- a/app/models/project_authorization.rb
+++ b/app/models/project_authorization.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectAuthorization < ActiveRecord::Base
belongs_to :user
belongs_to :project
diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb
index faa831b1949..155400d1a43 100644
--- a/app/models/project_auto_devops.rb
+++ b/app/models/project_auto_devops.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectAutoDevops < ActiveRecord::Base
belongs_to :project
diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb
index 588cced5781..1dad235cc2b 100644
--- a/app/models/project_ci_cd_setting.rb
+++ b/app/models/project_ci_cd_setting.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectCiCdSetting < ActiveRecord::Base
belongs_to :project, inverse_of: :ci_cd_settings
diff --git a/app/models/project_custom_attribute.rb b/app/models/project_custom_attribute.rb
index 3f1a7b86a82..4e767cb3b26 100644
--- a/app/models/project_custom_attribute.rb
+++ b/app/models/project_custom_attribute.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectCustomAttribute < ActiveRecord::Base
belongs_to :project
diff --git a/app/models/project_deploy_token.rb b/app/models/project_deploy_token.rb
index ab4482f0c0b..719c492a1ff 100644
--- a/app/models/project_deploy_token.rb
+++ b/app/models/project_deploy_token.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectDeployToken < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_token, inverse_of: :project_deploy_tokens
diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb
index 9c768b13f78..d74cb2506ba 100644
--- a/app/models/project_feature.rb
+++ b/app/models/project_feature.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectFeature < ActiveRecord::Base
# == Project features permissions
#
diff --git a/app/models/project_group_link.rb b/app/models/project_group_link.rb
index cf8fc41e870..bc3759142ae 100644
--- a/app/models/project_group_link.rb
+++ b/app/models/project_group_link.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectGroupLink < ActiveRecord::Base
include Expirable
diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb
index 1d7089ccfc7..2c3080c6d8d 100644
--- a/app/models/project_import_data.rb
+++ b/app/models/project_import_data.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'carrierwave/orm/activerecord'
class ProjectImportData < ActiveRecord::Base
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index 1605317ae14..89ed09af96a 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectImportState < ActiveRecord::Base
include AfterCommitQueue
diff --git a/app/models/project_label.rb b/app/models/project_label.rb
index 313815e5869..d0b16cc98b4 100644
--- a/app/models/project_label.rb
+++ b/app/models/project_label.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectLabel < Label
MAX_NUMBER_OF_PRIORITIES = 1
diff --git a/app/models/project_snippet.rb b/app/models/project_snippet.rb
index 25b5d777641..b3585c4cf4c 100644
--- a/app/models/project_snippet.rb
+++ b/app/models/project_snippet.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectSnippet < Snippet
belongs_to :project
belongs_to :author, class_name: "User"
diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb
index ef4a26f0e7f..781a197d56f 100644
--- a/app/models/project_statistics.rb
+++ b/app/models/project_statistics.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectStatistics < ActiveRecord::Base
belongs_to :project
belongs_to :namespace
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index c7d0f49d837..33bc6a561f9 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectTeam
include BulkMemberAccessLoad
diff --git a/app/models/protectable_dropdown.rb b/app/models/protectable_dropdown.rb
index c96edc5a259..25e70ab406c 100644
--- a/app/models/protectable_dropdown.rb
+++ b/app/models/protectable_dropdown.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProtectableDropdown
REF_TYPES = %i[branches tags].freeze
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index dff99cfca35..6c1073265a1 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProtectedBranch < ActiveRecord::Base
include Gitlab::ShellAdapter
include ProtectedRef
diff --git a/app/models/protected_ref_matcher.rb b/app/models/protected_ref_matcher.rb
index d970f2b01fc..bfa9180ac93 100644
--- a/app/models/protected_ref_matcher.rb
+++ b/app/models/protected_ref_matcher.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProtectedRefMatcher
def initialize(protected_ref)
@protected_ref = protected_ref
diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb
index 42a9bcf7723..a36f0d36262 100644
--- a/app/models/protected_tag.rb
+++ b/app/models/protected_tag.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProtectedTag < ActiveRecord::Base
include Gitlab::ShellAdapter
include ProtectedRef
diff --git a/app/models/push_event.rb b/app/models/push_event.rb
index 90c085c888e..9c0267c3140 100644
--- a/app/models/push_event.rb
+++ b/app/models/push_event.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class PushEvent < Event
# This validation exists so we can't accidentally use PushEvent with a
# different "action" value.
diff --git a/app/models/push_event_payload.rb b/app/models/push_event_payload.rb
index 6cdb1cd4fe9..c7769edf055 100644
--- a/app/models/push_event_payload.rb
+++ b/app/models/push_event_payload.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class PushEventPayload < ActiveRecord::Base
include ShaAttribute
diff --git a/app/models/readme_blob.rb b/app/models/readme_blob.rb
index 1863a08f1de..7b49fa632f6 100644
--- a/app/models/readme_blob.rb
+++ b/app/models/readme_blob.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ReadmeBlob < SimpleDelegator
attr_reader :repository
diff --git a/app/models/redirect_route.rb b/app/models/redirect_route.rb
index 31de204d824..c6bd4bb6dfa 100644
--- a/app/models/redirect_route.rb
+++ b/app/models/redirect_route.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class RedirectRoute < ActiveRecord::Base
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
diff --git a/app/models/release.rb b/app/models/release.rb
index c936899799e..cba80ad30ca 100644
--- a/app/models/release.rb
+++ b/app/models/release.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Release < ActiveRecord::Base
include CacheMarkdownField
diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb
index 6172bb38881..833faf3bc82 100644
--- a/app/models/remote_mirror.rb
+++ b/app/models/remote_mirror.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class RemoteMirror < ActiveRecord::Base
include AfterCommitQueue
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 9a6281bc1f7..69f375dc6f3 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'securerandom'
class Repository
diff --git a/app/models/route.rb b/app/models/route.rb
index 2d609920051..4b23dfa5778 100644
--- a/app/models/route.rb
+++ b/app/models/route.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Route < ActiveRecord::Base
include CaseSensitivity
diff --git a/app/models/security_event.rb b/app/models/security_event.rb
index d131c11cb6c..3fe4cc99c9b 100644
--- a/app/models/security_event.rb
+++ b/app/models/security_event.rb
@@ -1,2 +1,4 @@
+# frozen_string_literal: true
+
class SecurityEvent < AuditEvent
end
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 3da7c301d28..e65b3df0fb6 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class SentNotification < ActiveRecord::Base
serialize :position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
diff --git a/app/models/service.rb b/app/models/service.rb
index cbfe0c6eedd..140058771ee 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index 390bdbf838a..5b394e3fa79 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Snippet < ActiveRecord::Base
include Gitlab::VisibilityLevel
include CacheMarkdownField
diff --git a/app/models/snippet_blob.rb b/app/models/snippet_blob.rb
index fa5fa151607..cf1ab089829 100644
--- a/app/models/snippet_blob.rb
+++ b/app/models/snippet_blob.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class SnippetBlob
include BlobLike
diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb
index 56a115d1db4..ef3f974b959 100644
--- a/app/models/spam_log.rb
+++ b/app/models/spam_log.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class SpamLog < ActiveRecord::Base
belongs_to :user
diff --git a/app/models/subscription.rb b/app/models/subscription.rb
index 2f0c9640744..0f6ee0ddf7e 100644
--- a/app/models/subscription.rb
+++ b/app/models/subscription.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :project
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb
index 1c2161accc4..c5c77bc8333 100644
--- a/app/models/system_note_metadata.rb
+++ b/app/models/system_note_metadata.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class SystemNoteMetadata < ActiveRecord::Base
# These notes's action text might contain a reference that is external.
# We should always force a deep validation upon references that are found
diff --git a/app/models/term_agreement.rb b/app/models/term_agreement.rb
index c317bd0c90b..9b3c8ac68bd 100644
--- a/app/models/term_agreement.rb
+++ b/app/models/term_agreement.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class TermAgreement < ActiveRecord::Base
belongs_to :term, class_name: 'ApplicationSetting::Term'
belongs_to :user
diff --git a/app/models/timelog.rb b/app/models/timelog.rb
index 659146f43e4..e04c644a53a 100644
--- a/app/models/timelog.rb
+++ b/app/models/timelog.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Timelog < ActiveRecord::Base
validates :time_spent, :user, presence: true
validate :issuable_id_is_present
diff --git a/app/models/todo.rb b/app/models/todo.rb
index a2ab405fdbe..5f5c2f9073d 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Todo < ActiveRecord::Base
include Sortable
diff --git a/app/models/tree.rb b/app/models/tree.rb
index 4c1856b67a8..3641c33254c 100644
--- a/app/models/tree.rb
+++ b/app/models/tree.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Tree
include Gitlab::MarkupHelper
diff --git a/app/models/trending_project.rb b/app/models/trending_project.rb
index 27e3732da17..7b22e8cb760 100644
--- a/app/models/trending_project.rb
+++ b/app/models/trending_project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class TrendingProject < ActiveRecord::Base
belongs_to :project
diff --git a/app/models/u2f_registration.rb b/app/models/u2f_registration.rb
index 808acec098f..37598173fd1 100644
--- a/app/models/u2f_registration.rb
+++ b/app/models/u2f_registration.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Registration information for U2F (universal 2nd factor) devices, like Yubikeys
class U2fRegistration < ActiveRecord::Base
diff --git a/app/models/upload.rb b/app/models/upload.rb
index cf71a7b76fc..23bc9ca42fc 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class Upload < ActiveRecord::Base
# Upper limit for foreground checksum processing
CHECKSUM_THRESHOLD = 100.megabytes
diff --git a/app/models/user.rb b/app/models/user.rb
index 31b49b9bf2a..fdf3618b4dc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'carrierwave/orm/activerecord'
class User < ActiveRecord::Base
diff --git a/app/models/user_agent_detail.rb b/app/models/user_agent_detail.rb
index 2d05fdd3e54..e2b2e7f1df9 100644
--- a/app/models/user_agent_detail.rb
+++ b/app/models/user_agent_detail.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UserAgentDetail < ActiveRecord::Base
belongs_to :subject, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
diff --git a/app/models/user_callout.rb b/app/models/user_callout.rb
index 9d461c6750a..97e955ace36 100644
--- a/app/models/user_callout.rb
+++ b/app/models/user_callout.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UserCallout < ActiveRecord::Base
belongs_to :user
diff --git a/app/models/user_custom_attribute.rb b/app/models/user_custom_attribute.rb
index eff25b31f9b..e0ffe8ebbfd 100644
--- a/app/models/user_custom_attribute.rb
+++ b/app/models/user_custom_attribute.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UserCustomAttribute < ActiveRecord::Base
belongs_to :user
diff --git a/app/models/user_interacted_project.rb b/app/models/user_interacted_project.rb
index dd55a6acb79..ae6778e49be 100644
--- a/app/models/user_interacted_project.rb
+++ b/app/models/user_interacted_project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UserInteractedProject < ActiveRecord::Base
belongs_to :user
belongs_to :project
diff --git a/app/models/user_synced_attributes_metadata.rb b/app/models/user_synced_attributes_metadata.rb
index 688432a9d67..7115262942d 100644
--- a/app/models/user_synced_attributes_metadata.rb
+++ b/app/models/user_synced_attributes_metadata.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UserSyncedAttributesMetadata < ActiveRecord::Base
belongs_to :user
diff --git a/app/models/users_star_project.rb b/app/models/users_star_project.rb
index 0dfe597317e..bdaf58ae1c1 100644
--- a/app/models/users_star_project.rb
+++ b/app/models/users_star_project.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class UsersStarProject < ActiveRecord::Base
belongs_to :project, counter_cache: :star_count, touch: true
belongs_to :user
diff --git a/app/models/wiki_directory.rb b/app/models/wiki_directory.rb
index 9340fc2dbbe..712ba79bbd2 100644
--- a/app/models/wiki_directory.rb
+++ b/app/models/wiki_directory.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class WikiDirectory
include ActiveModel::Validations
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 55243136140..33790afc35e 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# rubocop:disable Rails/ActiveRecordAliases
class WikiPage
PageChangedError = Class.new(StandardError)
diff --git a/app/views/projects/jobs/show.html.haml b/app/views/projects/jobs/show.html.haml
index 1f33bb3a129..078f40c4477 100644
--- a/app/views/projects/jobs/show.html.haml
+++ b/app/views/projects/jobs/show.html.haml
@@ -22,7 +22,7 @@
%br
Go to
- = link_to project_runners_path(@build.project) do
+ = link_to project_runners_path(@build.project, anchor: 'js-runners-settings') do
Runners page
- if @build.starts_environment?
diff --git a/app/views/projects/settings/ci_cd/show.html.haml b/app/views/projects/settings/ci_cd/show.html.haml
index be22bbd7a9b..e9f5e62f5e7 100644
--- a/app/views/projects/settings/ci_cd/show.html.haml
+++ b/app/views/projects/settings/ci_cd/show.html.haml
@@ -28,7 +28,7 @@
.settings-content
= render 'autodevops_form'
-%section.qa-runners-settings.settings.no-animate{ class: ('expanded' if expanded) }
+%section.qa-runners-settings.settings.no-animate#js-runners-settings{ class: ('expanded' if expanded) }
.settings-header
%h4
= _("Runners")
diff --git a/changelogs/unreleased/48246-osw-load-diffs-improvement.yml b/changelogs/unreleased/48246-osw-load-diffs-improvement.yml
new file mode 100644
index 00000000000..c4292ab0d29
--- /dev/null
+++ b/changelogs/unreleased/48246-osw-load-diffs-improvement.yml
@@ -0,0 +1,5 @@
+---
+title: Improve performance when fetching collapsed diffs and commenting in merge requests
+merge_request: 20940
+author:
+type: performance
diff --git a/changelogs/unreleased/49851-link-to-runners.yml b/changelogs/unreleased/49851-link-to-runners.yml
new file mode 100644
index 00000000000..89fd6853bc8
--- /dev/null
+++ b/changelogs/unreleased/49851-link-to-runners.yml
@@ -0,0 +1,6 @@
+---
+title: Automatically expand runner's settings block when linking to the runner's settings
+ page
+merge_request:
+author:
+type: other
diff --git a/changelogs/unreleased/frozen-string-enable-app-models.yml b/changelogs/unreleased/frozen-string-enable-app-models.yml
new file mode 100644
index 00000000000..4c149ea55ef
--- /dev/null
+++ b/changelogs/unreleased/frozen-string-enable-app-models.yml
@@ -0,0 +1,5 @@
+---
+title: Enable frozen string in app/models/*.rb
+merge_request: 20851
+author: gfyoung
+type: performance
diff --git a/doc/user/profile/account/two_factor_authentication.md b/doc/user/profile/account/two_factor_authentication.md
index d3a2a7dcd14..e25e1e19b13 100644
--- a/doc/user/profile/account/two_factor_authentication.md
+++ b/doc/user/profile/account/two_factor_authentication.md
@@ -88,7 +88,7 @@ storage in a safe place. **Each code can be used only once** to log in to your
account.
If you lose the recovery codes or just want to generate new ones, you can do so
-from the **Profile settings ➔ Account** page where you first enabled 2FA.
+[using SSH](#generate-new-recovery-codes-using-ssh).
## Logging in with 2FA Enabled
diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb
index 4ca5a78e068..04aa6aab771 100644
--- a/lib/gitlab/bare_repository_import/importer.rb
+++ b/lib/gitlab/bare_repository_import/importer.rb
@@ -26,6 +26,12 @@ module Gitlab
end
end
+ # This is called from within a rake task only used by Admins, so allow writing
+ # to STDOUT
+ def self.log(message)
+ puts message # rubocop:disable Rails/Output
+ end
+
attr_reader :user, :project_name, :bare_repo
delegate :log, to: :class
@@ -59,11 +65,10 @@ module Gitlab
import_type: 'bare_repository',
namespace_id: group&.id).execute
- if project.persisted? && mv_repo(project)
+ if project.persisted? && mv_repositories(project)
log " * Created #{project.name} (#{project_full_path})".color(:green)
project.write_repository_config
- Gitlab::Git::Repository.create_hooks(project.repository.path_to_repo, Gitlab.config.gitlab_shell.hooks_path)
ProjectCacheWorker.perform_async(project.id)
else
@@ -74,12 +79,11 @@ module Gitlab
project
end
- def mv_repo(project)
- storage_path = storage_path_for_shard(project.repository_storage)
- FileUtils.mv(repo_path, project.repository.path_to_repo)
+ def mv_repositories(project)
+ mv_repo(bare_repo.repo_path, project.repository)
if bare_repo.wiki_exists?
- FileUtils.mv(wiki_path, File.join(storage_path, project.disk_path + '.wiki.git'))
+ mv_repo(bare_repo.wiki_path, project.wiki.repository)
end
true
@@ -89,6 +93,11 @@ module Gitlab
false
end
+ def mv_repo(path, repository)
+ repository.create_from_bundle(bundle(path))
+ FileUtils.rm_rf(path)
+ end
+
def storage_path_for_shard(shard)
Gitlab.config.repositories.storages[shard].legacy_disk_path
end
@@ -101,10 +110,17 @@ module Gitlab
Groups::NestedCreateService.new(user, group_path: group_path).execute
end
- # This is called from within a rake task only used by Admins, so allow writing
- # to STDOUT
- def self.log(message)
- puts message # rubocop:disable Rails/Output
+ def bundle(repo_path)
+ # TODO: we could save some time and disk space by using
+ # `git bundle create - --all` and streaming the bundle directly to
+ # Gitaly, rather than writing it on disk first
+ bundle_path = "#{repo_path}.bundle"
+ cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)
+ output, status = Gitlab::Popen.popen(cmd)
+
+ raise output unless status.zero?
+
+ bundle_path
end
end
end
diff --git a/lib/gitlab/bare_repository_import/repository.rb b/lib/gitlab/bare_repository_import/repository.rb
index fe267248275..c0c666dfb7b 100644
--- a/lib/gitlab/bare_repository_import/repository.rb
+++ b/lib/gitlab/bare_repository_import/repository.rb
@@ -1,5 +1,3 @@
-# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/953
-#
module Gitlab
module BareRepositoryImport
class Repository
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index eb02c7ac8e1..73151e4a4c5 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -39,19 +39,6 @@ module Gitlab
ChecksumError = Class.new(StandardError)
class << self
- # Unlike `new`, `create` takes the repository path
- def create(repo_path, bare: true, symlink_hooks_to: nil)
- FileUtils.mkdir_p(repo_path, mode: 0770)
-
- # Equivalent to `git --git-path=#{repo_path} init [--bare]`
- repo = Rugged::Repository.init_at(repo_path, bare)
- repo.close
-
- create_hooks(repo_path, symlink_hooks_to) if symlink_hooks_to.present?
-
- true
- end
-
def create_hooks(repo_path, global_hooks_path)
local_hooks_path = File.join(repo_path, 'hooks')
real_local_hooks_path = :not_found
diff --git a/spec/controllers/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb
index 701211c2586..4439ea4a533 100644
--- a/spec/controllers/admin/services_controller_spec.rb
+++ b/spec/controllers/admin/services_controller_spec.rb
@@ -13,7 +13,7 @@ describe Admin::ServicesController do
Service.available_services_names.each do |service_name|
context "#{service_name}" do
let!(:service) do
- service_template = service_name.concat("_service").camelize.constantize
+ service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
diff --git a/spec/lib/gitlab/bare_repository_import/importer_spec.rb b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
index 468f6ff6d24..6e21c846c0a 100644
--- a/spec/lib/gitlab/bare_repository_import/importer_spec.rb
+++ b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
@@ -1,10 +1,11 @@
require 'spec_helper'
-describe Gitlab::BareRepositoryImport::Importer, repository: true do
+describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
let!(:admin) { create(:admin) }
let!(:base_dir) { Dir.mktmpdir + '/' }
let(:bare_repository) { Gitlab::BareRepositoryImport::Repository.new(base_dir, File.join(base_dir, "#{project_path}.git")) }
let(:gitlab_shell) { Gitlab::Shell.new }
+ let(:source_project) { TEST_REPO_PATH }
subject(:importer) { described_class.new(admin, bare_repository) }
@@ -17,16 +18,11 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
after do
FileUtils.rm_rf(base_dir)
+ TestEnv.clean_test_path
+ ensure_seeds
Rainbow.enabled = @rainbow
end
- around do |example|
- # TODO migrate BareRepositoryImport https://gitlab.com/gitlab-org/gitaly/issues/953
- Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- example.run
- end
- end
-
shared_examples 'importing a repository' do
describe '.execute' do
it 'creates a project for a repository in storage' do
@@ -86,8 +82,8 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
importer.create_project_if_needed
end
- it 'creates the Git repo on disk with the proper symlink for hooks' do
- create_bare_repository("#{project_path}.git")
+ it 'creates the Git repo on disk' do
+ prepare_repository("#{project_path}.git", source_project)
importer.create_project_if_needed
@@ -97,9 +93,6 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
expect(gitlab_shell.exists?(project.repository_storage, repo_path)).to be(true)
expect(gitlab_shell.exists?(project.repository_storage, hook_path)).to be(true)
-
- full_hook_path = File.join(project.repository.path_to_repo, 'hooks')
- expect(File.readlink(full_hook_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
end
context 'hashed storage enabled' do
@@ -148,7 +141,7 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
end
it 'creates the Git repo in disk' do
- create_bare_repository("#{project_path}.git")
+ prepare_repository("#{project_path}.git", source_project)
importer.create_project_if_needed
@@ -158,23 +151,23 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + '.wiki.git')).to be(true)
end
- it 'moves an existing project to the correct path' do
+ context 'with a repository already on disk' do
+ let!(:base_dir) { TestEnv.repos_path }
# This is a quick way to get a valid repository instead of copying an
# existing one. Since it's not persisted, the importer will try to
# create the project.
- project = build(:project, :legacy_storage, :repository)
- original_commit_count = project.repository.commit_count
-
- legacy_path = Gitlab.config.repositories.storages[project.repository_storage].legacy_disk_path
+ let(:project) { build(:project, :legacy_storage, :repository) }
+ let(:project_path) { project.full_path }
- bare_repo = Gitlab::BareRepositoryImport::Repository.new(legacy_path, project.repository.path)
- gitlab_importer = described_class.new(admin, bare_repo)
+ it 'moves an existing project to the correct path' do
+ original_commit_count = project.repository.commit_count
- expect(gitlab_importer).to receive(:create_project).and_call_original
+ expect(importer).to receive(:create_project).and_call_original
- new_project = gitlab_importer.create_project_if_needed
+ new_project = importer.create_project_if_needed
- expect(new_project.repository.commit_count).to eq(original_commit_count)
+ expect(new_project.repository.commit_count).to eq(original_commit_count)
+ end
end
end
@@ -185,8 +178,8 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
it_behaves_like 'importing a repository'
it 'creates the Wiki git repo in disk' do
- create_bare_repository("#{project_path}.git")
- create_bare_repository("#{project_path}.wiki.git")
+ prepare_repository("#{project_path}.git", source_project)
+ prepare_repository("#{project_path}.wiki.git", source_project)
expect(Projects::CreateService).to receive(:new).with(admin, hash_including(skip_wiki: true,
import_type: 'bare_repository')).and_call_original
@@ -213,8 +206,13 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
end
end
- def create_bare_repository(project_path)
+ def prepare_repository(project_path, source_project)
repo_path = File.join(base_dir, project_path)
- Gitlab::Git::Repository.create(repo_path, bare: true)
+
+ return create_bare_repository(repo_path) unless source_project
+
+ cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{source_project} #{repo_path})
+
+ system(git_env, *cmd, chdir: SEED_STORAGE_PATH, out: '/dev/null', err: '/dev/null')
end
end
diff --git a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
index 5d22dcfb508..ca067a29174 100644
--- a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::AttributesAtRefParser, seed_helper: true do
+describe Gitlab::Git::AttributesAtRefParser, :seed_helper do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
diff --git a/spec/lib/gitlab/git/attributes_parser_spec.rb b/spec/lib/gitlab/git/attributes_parser_spec.rb
index 2d103123998..18ebfef38f0 100644
--- a/spec/lib/gitlab/git/attributes_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_parser_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::AttributesParser, seed_helper: true do
+describe Gitlab::Git::AttributesParser, :seed_helper do
let(:attributes_path) { File.join(SEED_STORAGE_PATH, 'with-git-attributes.git', 'info', 'attributes') }
let(:data) { File.read(attributes_path) }
diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb
index ba790b717ae..e704d1c673c 100644
--- a/spec/lib/gitlab/git/blame_spec.rb
+++ b/spec/lib/gitlab/git/blame_spec.rb
@@ -1,7 +1,7 @@
# coding: utf-8
require "spec_helper"
-describe Gitlab::Git::Blame, seed_helper: true do
+describe Gitlab::Git::Blame, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
let(:blame) do
Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md")
diff --git a/spec/lib/gitlab/git/blob_snippet_spec.rb b/spec/lib/gitlab/git/blob_snippet_spec.rb
index d6d365f6492..6effec8295c 100644
--- a/spec/lib/gitlab/git/blob_snippet_spec.rb
+++ b/spec/lib/gitlab/git/blob_snippet_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-describe Gitlab::Git::BlobSnippet, seed_helper: true do
+describe Gitlab::Git::BlobSnippet, :seed_helper do
describe '#data' do
context 'empty lines' do
let(:snippet) { Gitlab::Git::BlobSnippet.new('master', nil, nil, nil) }
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 034b89a46fa..ea49502ae2e 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-describe Gitlab::Git::Blob, seed_helper: true do
+describe Gitlab::Git::Blob, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
describe 'initialize' do
diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb
index a8c5627e678..79ccbb79966 100644
--- a/spec/lib/gitlab/git/branch_spec.rb
+++ b/spec/lib/gitlab/git/branch_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Branch, seed_helper: true do
+describe Gitlab::Git::Branch, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
let(:rugged) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb
index 0adb684765d..2718a3c5e49 100644
--- a/spec/lib/gitlab/git/commit_spec.rb
+++ b/spec/lib/gitlab/git/commit_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Commit, seed_helper: true do
+describe Gitlab::Git::Commit, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
let(:commit) { described_class.find(repository, SeedRepo::Commit::ID) }
let(:rugged_commit) do
diff --git a/spec/lib/gitlab/git/committer_with_hooks_spec.rb b/spec/lib/gitlab/git/committer_with_hooks_spec.rb
index 2100690f873..c7626058acd 100644
--- a/spec/lib/gitlab/git/committer_with_hooks_spec.rb
+++ b/spec/lib/gitlab/git/committer_with_hooks_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::CommitterWithHooks, seed_helper: true do
+describe Gitlab::Git::CommitterWithHooks, :seed_helper do
# TODO https://gitlab.com/gitlab-org/gitaly/issues/1234
skip 'needs to be moved to gitaly-ruby test suite' do
shared_examples 'calling wiki hooks' do
diff --git a/spec/lib/gitlab/git/compare_spec.rb b/spec/lib/gitlab/git/compare_spec.rb
index b6a42e422b5..7cc6f52f8ee 100644
--- a/spec/lib/gitlab/git/compare_spec.rb
+++ b/spec/lib/gitlab/git/compare_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Compare, seed_helper: true do
+describe Gitlab::Git::Compare, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) }
let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) }
diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb
index 65edc750f39..81658874be7 100644
--- a/spec/lib/gitlab/git/diff_collection_spec.rb
+++ b/spec/lib/gitlab/git/diff_collection_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::DiffCollection, seed_helper: true do
+describe Gitlab::Git::DiffCollection, :seed_helper do
subject do
Gitlab::Git::DiffCollection.new(
iterator,
diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb
index 11ab376ab8f..87d9fcee39e 100644
--- a/spec/lib/gitlab/git/diff_spec.rb
+++ b/spec/lib/gitlab/git/diff_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Diff, seed_helper: true do
+describe Gitlab::Git::Diff, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
before do
diff --git a/spec/lib/gitlab/git/hooks_service_spec.rb b/spec/lib/gitlab/git/hooks_service_spec.rb
index 9337aa39e13..55ffced36ac 100644
--- a/spec/lib/gitlab/git/hooks_service_spec.rb
+++ b/spec/lib/gitlab/git/hooks_service_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::HooksService, seed_helper: true do
+describe Gitlab::Git::HooksService, :seed_helper do
let(:gl_id) { 'user-456' }
let(:gl_username) { 'janedoe' }
let(:user) { Gitlab::Git::User.new(gl_username, 'Jane Doe', 'janedoe@example.com', gl_id) }
diff --git a/spec/lib/gitlab/git/index_spec.rb b/spec/lib/gitlab/git/index_spec.rb
index e51b875be11..c4edd6961e1 100644
--- a/spec/lib/gitlab/git/index_spec.rb
+++ b/spec/lib/gitlab/git/index_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::Index, seed_helper: true do
+describe Gitlab::Git::Index, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
let(:index) { described_class.new(repository) }
diff --git a/spec/lib/gitlab/git/remote_repository_spec.rb b/spec/lib/gitlab/git/remote_repository_spec.rb
index eb148cc3804..53ed7c5a13a 100644
--- a/spec/lib/gitlab/git/remote_repository_spec.rb
+++ b/spec/lib/gitlab/git/remote_repository_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Gitlab::Git::RemoteRepository, seed_helper: true do
+describe Gitlab::Git::RemoteRepository, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
subject { described_class.new(repository) }
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 62396af1ebe..35a6fc94753 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1,7 +1,7 @@
# coding: utf-8
require "spec_helper"
-describe Gitlab::Git::Repository, seed_helper: true do
+describe Gitlab::Git::Repository, :seed_helper do
include Gitlab::EncodingHelper
using RSpec::Parameterized::TableSyntax
diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb
index be2f5bfb819..2d9db576a6c 100644
--- a/spec/lib/gitlab/git/tag_spec.rb
+++ b/spec/lib/gitlab/git/tag_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Tag, seed_helper: true do
+describe Gitlab::Git::Tag, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
shared_examples 'Gitlab::Git::Repository#tags' do
diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb
index 001e406a930..3792d6bf67b 100644
--- a/spec/lib/gitlab/git/tree_spec.rb
+++ b/spec/lib/gitlab/git/tree_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe Gitlab::Git::Tree, seed_helper: true do
+describe Gitlab::Git::Tree, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
context :repo do
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index 0aee78ac12d..90cce826b6c 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -127,6 +127,13 @@ describe MergeRequestDiff do
expect(diffs.map(&:new_path)).to contain_exactly('files/ruby/popen.rb')
end
+ it 'only serializes diff files found by query' do
+ expect(diff_with_commits.merge_request_diff_files.count).to be > 10
+ expect_any_instance_of(MergeRequestDiffFile).to receive(:to_hash).once
+
+ diffs
+ end
+
it 'uses the diffs from the DB' do
expect(diff_with_commits).to receive(:load_diffs)
diff --git a/spec/support/helpers/seed_helper.rb b/spec/support/helpers/seed_helper.rb
index 8fd107260cc..25781f5e679 100644
--- a/spec/support/helpers/seed_helper.rb
+++ b/spec/support/helpers/seed_helper.rb
@@ -101,10 +101,4 @@ bla/bla.txt
handle.write('# hello'.encode(enc))
end
end
-
- # Prevent developer git configurations from being persisted to test
- # repositories
- def git_env
- { 'GIT_TEMPLATE_DIR' => '' }
- end
end
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index e531495d917..8e1d4cfe269 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -243,6 +243,14 @@ module TestEnv
set_repo_refs(target_repo_path, refs)
end
+ def create_bare_repository(path)
+ FileUtils.mkdir_p(path)
+
+ system(git_env, *%W(#{Gitlab.config.git.bin_path} -C #{path} init --bare),
+ out: '/dev/null',
+ err: '/dev/null')
+ end
+
def repos_path
@repos_path ||= Gitlab.config.repositories.storages[REPOS_STORAGE].legacy_disk_path
end
diff --git a/spec/support/stored_repositories.rb b/spec/support/stored_repositories.rb
index 21995c89a6e..26f823cb6ef 100644
--- a/spec/support/stored_repositories.rb
+++ b/spec/support/stored_repositories.rb
@@ -1,8 +1,4 @@
RSpec.configure do |config|
- config.before(:each, :repository) do
- TestEnv.clean_test_path
- end
-
config.before(:all, :broken_storage) do
FileUtils.rm_rf Gitlab.config.repositories.storages.broken.legacy_disk_path
end