diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-01-12 19:24:25 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-01-12 19:24:25 +0300 |
commit | a68ba4887719ab5aa6a244c47835580d8a85eb13 (patch) | |
tree | bcf0871d3346f5370f6e9f79b1794c58f4531580 /app/models | |
parent | d6c69373e54b76232f361aa631e7b6283d3c71ef (diff) | |
parent | 6438a1afa7f260da3d7de85c4986042bdf56c84e (diff) |
Merge remote-tracking branch 'upstream/master' into 41731-predicate-memoization
* upstream/master:
Docs: move article "Autoscaling Runners on AWS" to its topic-related dir
Update missing API documentation on `GET /users/:id/projects`
Docs: remove duplicate CI examples
Only search for MR revert commits on notes after MR was merged
Added .rej files to gitignore
Fixed performance of projects dropdown
Add a note about GitLab QA page objects validator to docs
Refactor dispatcher projects blame and blob path
Fix Ctrl+Enter keyboard shortcut saving comment/note edit
Fix boolean prop being provided as string
Fixes minor aspects on Prometheus description
Refactor dispatcher project branches path
Use simple Next/Prev paging for jobs to avoid large count queries on arbitrarily large sets of historical jobs
Update the grpc gem to 1.8.3
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit.rb | 5 | ||||
-rw-r--r-- | app/models/merge_request.rb | 11 |
2 files changed, 13 insertions, 3 deletions
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 diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 2669d2a6ff3..b7762a5f281 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -982,7 +982,16 @@ class MergeRequest < ActiveRecord::Base end def can_be_reverted?(current_user) - merge_commit && !merge_commit.has_been_reverted?(current_user, self) + return false unless merge_commit + + merged_at = metrics&.merged_at + notes_association = notes_with_associations + + if merged_at + notes_association = notes_association.where('created_at > ?', merged_at) + end + + !merge_commit.has_been_reverted?(current_user, notes_association) end def can_be_cherry_picked? |