diff --git a/app/helpers/pull_request_helper.rb b/app/helpers/pull_request_helper.rb index 264d10db2..db6ee030d 100644 --- a/app/helpers/pull_request_helper.rb +++ b/app/helpers/pull_request_helper.rb @@ -1,9 +1,11 @@ # -*- encoding : utf-8 -*- module PullRequestHelper def merge_activity comments, commits - pull_comments = comments.group_by(&:data).map{|data, c| [c.first.created_at, [data || {}, [c].flatten]]} - commits = @commits.map{ |c| [(c.committed_date || c.authored_date), c] } - (pull_comments + commits).sort_by{ |c| c[0] }.map{ |c| c[1] } + common_comments, pull_comments = comments.partition {|c| c.data.blank?} + common_comments = common_comments.map{ |c| [c.created_at, c] } + pull_comments = pull_comments.group_by(&:data).map{|data, c| [c.first.created_at, [data || {}, [c].flatten]]} + commits = commits.map{ |c| [(c.committed_date || c.authored_date), c] } + (common_comments + pull_comments + commits).sort_by{ |c| c[0] }.map{ |c| c[1] } end def pull_status_label pull diff --git a/app/views/projects/pull_requests/_activity.html.haml b/app/views/projects/pull_requests/_activity.html.haml index 804644410..58c4e8ad4 100644 --- a/app/views/projects/pull_requests/_activity.html.haml +++ b/app/views/projects/pull_requests/_activity.html.haml @@ -1,14 +1,15 @@ -%a{ :name => "comments" } .hr -%h3#block-list= t("layout.comments.comments_header") - -- commits_queue = [] -- merge_activity(@comments, @commits).each do |item| # - - if item.is_a? Grit::Commit - -commits_queue << item - - elsif item.is_a? Array - = render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present? +-commits_queue = [] +-merge_activity(@comments, @commits).each do |item| # + -if item.is_a? Comment + =render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present? -commits_queue.clear - = render 'projects/pull_requests/discussion_comments', :item => item, :project => @project, :commentable => @issue, :add_id => nil -= render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present? + =render 'projects/comments/comment', :comment => item, :data => {:project => @project, :commentable => @commentable} + -elsif item.is_a? Grit::Commit + -commits_queue << item + -elsif item.is_a? Array + =render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present? + -commits_queue.clear + =render 'projects/pull_requests/discussion_comments', :item => item, :project => @project, :commentable => @issue, :add_id => nil +=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?