diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 03:09:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 03:09:34 +0300 |
commit | 5781a4966047232d4725f9ee4769c4bd5aed9b26 (patch) | |
tree | 0ef2b81a40931ec51f8fdd5284ed9e47cf42a923 /app/models | |
parent | 4d48b3cfcd74bcca0f0f305746f74cf7224dd78b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 16 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 | ||||
-rw-r--r-- | app/models/note.rb | 13 | ||||
-rw-r--r-- | app/models/project.rb | 6 | ||||
-rw-r--r-- | app/models/repository.rb | 9 | ||||
-rw-r--r-- | app/models/user.rb | 7 |
6 files changed, 28 insertions, 27 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index 2b8e4aa8278..681fe727456 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -242,14 +242,6 @@ class Commit data end - # Discover issues should be closed when this commit is pushed to a project's - # default branch. - def closes_issues(current_user = self.committer) - return unless repository.repo_type.project? - - Gitlab::ClosingIssueExtractor.new(project, current_user).closed_by_message(safe_message) - end - def lazy_author BatchLoader.for(author_email.downcase).batch do |emails, loader| users = User.by_any_email(emails, confirmed: true).includes(:emails) @@ -299,14 +291,6 @@ class Commit notes.includes(:author, :award_emoji) end - def merge_requests - strong_memoize(:merge_requests) do - next MergeRequest.none unless repository.repo_type.project? && project - - project.merge_requests.by_commit_sha(sha) - end - end - def method_missing(method, *args, &block) @raw.__send__(method, *args, &block) # rubocop:disable GitlabSecurity/PublicSend end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 26e3c8f38f6..0aaeed9f977 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -257,6 +257,10 @@ class MergeRequest < ApplicationRecord with_state(:opened).where(auto_merge_enabled: true) end + scope :including_metrics, -> do + includes(:metrics) + end + ignore_column :state, remove_with: '12.7', remove_after: '2019-12-22' after_save :keep_around_commit, unless: :importing? diff --git a/app/models/note.rb b/app/models/note.rb index 561391a55b6..670a981a78f 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -290,6 +290,19 @@ class Note < ApplicationRecord @commit ||= project.commit(commit_id) if commit_id.present? end + # Notes on merge requests and commits can be traced back to one or several + # MRs. This method returns a relation if the note is for one of these types, + # or nil if it is a note on some other object. + def merge_requests + if for_commit? + project.merge_requests.by_commit_sha(commit_id) + elsif for_merge_request? + MergeRequest.id_in(noteable_id) + else + nil + end + end + # override to return commits, which are not active record def noteable return commit if for_commit? diff --git a/app/models/project.rb b/app/models/project.rb index d6a52b37f19..daae6544ad5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1787,8 +1787,10 @@ class Project < ApplicationRecord # rubocop:enable Gitlab/RailsLogger def after_import - repository.after_import - wiki.repository.after_import + repository.expire_content_cache + wiki.repository.expire_content_cache + + DetectRepositoryLanguagesWorker.perform_async(id) # The import assigns iid values on its own, e.g. by re-using GitHub ids. # Flush existing InternalId records for this project for consistency reasons. diff --git a/app/models/repository.rb b/app/models/repository.rb index 534c62ec467..5603c35b419 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -437,15 +437,6 @@ class Repository expire_all_method_caches end - # Runs code after a repository has been forked/imported. - def after_import - expire_content_cache - - return unless repo_type.project? - - DetectRepositoryLanguagesWorker.perform_async(project.id) - end - # Runs code after a new commit has been pushed. def after_push_commit(branch_name) expire_statistics_caches diff --git a/app/models/user.rb b/app/models/user.rb index 0a28268bbc6..b0db21b2d1c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1683,6 +1683,13 @@ class User < ApplicationRecord super end + # override from Devise::Confirmable + def confirmation_period_valid? + return false if Feature.disabled?(:soft_email_confirmation) + + super + end + private def default_private_profile_to_false |