Commit 79b64ef4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

fixed merge request diff

parent 958497fe
...@@ -34,8 +34,9 @@ class MergeRequestsController < ApplicationController ...@@ -34,8 +34,9 @@ class MergeRequestsController < ApplicationController
end end
def diffs def diffs
@commit = @project.commit(@merge_request.source_branch) @diffs = @merge_request.diffs
@diffs = @project.repo.diff(@merge_request.target_branch, @merge_request.source_branch) @commit = @merge_request.last_commit
render :template => "merge_requests/_diffs", :layout => false render :template => "merge_requests/_diffs", :layout => false
end end
......
...@@ -36,4 +36,8 @@ class Commit ...@@ -36,4 +36,8 @@ class Commit
def author_name def author_name
encode(author.name) encode(author.name)
end end
def prev_commit
parents.first
end
end end
...@@ -33,4 +33,14 @@ class MergeRequest < ActiveRecord::Base ...@@ -33,4 +33,14 @@ class MergeRequest < ActiveRecord::Base
def new? def new?
today? && created_at == updated_at today? && created_at == updated_at
end end
def diffs
commit = project.commit(source_branch)
commits = project.repo.commits_between(target_branch, source_branch).map {|c| Commit.new(c)}
diffs = project.repo.diff(commits.first.prev_commit.id, commits.last.id)
end
def last_commit
project.commit(source_branch)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment