fixed merge request diff

This commit is contained in:
Dmitriy Zaporozhets 2011-11-29 20:06:37 +02:00
parent 958497fecb
commit 79b64ef4ac
3 changed files with 17 additions and 2 deletions

View file

@ -34,8 +34,9 @@ class MergeRequestsController < ApplicationController
end
def diffs
@commit = @project.commit(@merge_request.source_branch)
@diffs = @project.repo.diff(@merge_request.target_branch, @merge_request.source_branch)
@diffs = @merge_request.diffs
@commit = @merge_request.last_commit
render :template => "merge_requests/_diffs", :layout => false
end

View file

@ -36,4 +36,8 @@ class Commit
def author_name
encode(author.name)
end
def prev_commit
parents.first
end
end

View file

@ -33,4 +33,14 @@ class MergeRequest < ActiveRecord::Base
def new?
today? && created_at == updated_at
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