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/merge_request_diff.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/models/merge_request_diff.rb') diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index afab72930c1..69a846da9be 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -28,6 +28,9 @@ class MergeRequestDiff < ActiveRecord::Base end scope :viewable, -> { without_state(:empty) } + scope :by_commit_sha, ->(sha) do + joins(:merge_request_diff_commits).where(merge_request_diff_commits: { sha: sha }).reorder(nil) + end scope :recent, -> { order(id: :desc).limit(100) } -- cgit v1.2.1