Show only the commits that are newer in the merge request.

This commit is contained in:
Sytse Sijbrandij 2012-08-21 23:07:11 +02:00
parent 64f3682feb
commit 9ec4c2d214

View file

@ -88,8 +88,11 @@ class MergeRequest < ActiveRecord::Base
end end
def unmerged_diffs def unmerged_diffs
commits = project.repo.commits_between(target_branch, source_branch).map {|c| Commit.new(c)} # Only show what is new in the source branch compared to the target branch, not the other way around.
diffs = project.repo.diff(commits.first.prev_commit.id, commits.last.id) rescue [] # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
# From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
common_commit = project.repo.git.native(:merge_base, {}, [target_branch, source_branch]).strip
diffs = project.repo.diff(common_commit, source_branch)
end end
def last_commit def last_commit