From f3cf8cc8d1625ae1cd532474191739cd36419425 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 11 Jan 2018 16:20:13 +0000 Subject: Only search for MR revert commits on notes after MR was merged If we search for notes before the MR was merged, we have to load every commit that was ever part of the MR, or mentioned in a push. In extreme cases, this can be tens of thousands of commits to load, but we know they can't revert the merge commit, because they are from before the MR was merged. In the (rare) case that we don't have a `merged_at` value for the MR, we can still search all notes. --- app/models/commit.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 39d7f5b159d..ede8ad301e4 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -342,10 +342,11 @@ class Commit @merged_merge_request_hash[current_user] end - def has_been_reverted?(current_user, noteable = self) + def has_been_reverted?(current_user, notes_association = nil) ext = all_references(current_user) + notes_association ||= notes_with_associations - noteable.notes_with_associations.system.each do |note| + notes_association.system.each do |note| note.all_references(current_user, extractor: ext) end -- cgit v1.2.1 From a7d26f00c35b945199d40332349f463043ae6122 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sato Date: Fri, 12 Jan 2018 20:38:36 +0000 Subject: Display related merge requests in commit detail page --- app/models/commit.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index ede8ad301e4..21904c87f01 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -238,6 +238,10 @@ class Commit notes.includes(:author) end + def merge_requests + @merge_requests ||= project.merge_requests.by_commit_sha(sha) + end + def method_missing(method, *args, &block) @raw.__send__(method, *args, &block) # rubocop:disable GitlabSecurity/PublicSend end -- cgit v1.2.1 From f32f04a50f702f7a021e79b17dddc8cc1e3f6d5a Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Mon, 15 Jan 2018 10:39:06 +0100 Subject: Migrate Commit#uri_type to Gitaly Closes gitaly#915 --- app/models/commit.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/models/commit.rb') diff --git a/app/models/commit.rb b/app/models/commit.rb index 21904c87f01..2d2d89af030 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -372,19 +372,19 @@ class Commit # uri_type('doc/README.md') # => :blob # uri_type('doc/logo.png') # => :raw # uri_type('doc/api') # => :tree - # uri_type('not/found') # => :nil + # uri_type('not/found') # => nil # # Returns a symbol def uri_type(path) - entry = @raw.rugged_tree_entry(path) + entry = @raw.tree_entry(path) + return unless entry + if entry[:type] == :blob blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project) blob.image? || blob.video? ? :raw : :blob else entry[:type] end - rescue Rugged::TreeError - nil end def raw_diffs(*args) -- cgit v1.2.1