From 45d8e648404b7d6d5210aeea916e527604104152 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 9 Oct 2016 09:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9gitlab=20tree=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=B1=BB=E5=9E=8B=EF=BC=88lastrev=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 3 ++- app/models/repository.rb | 4 ++-- app/views/repositories/show.html.erb | 2 +- lib/redmine/scm/adapters/gitlab_adapter.rb | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 08ffca920..e2a3e2d2a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -382,7 +382,8 @@ update if request.xhr? @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - @changesets_latest_coimmit = @g.commits(@project.gpid, :ref_name => @rev)[0] + @changesets_latest_coimmit = @g.commit(@project.gpid, @entries.first.try(:lastrev)) + # @changesets_latest_coimmit = @g.commits(@project.gpid, :ref_name => @rev)[0] # 总的提交数 @changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count diff --git a/app/models/repository.rb b/app/models/repository.rb index 305c82f97..c9346e15b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -422,8 +422,8 @@ class Repository < ActiveRecord::Base def load_entries_changesets(entries) if entries entries.each do |entry| - if entry.lastrev && entry.lastrev.identifier - entry.changeset = find_changeset_by_name(entry.lastrev.identifier) + if entry.lastrev + entry.changeset = entry.lastrev end end end diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index a0ae74d73..8b47190e5 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -49,7 +49,7 @@
- <% if @changesets && !@changesets.empty? %> + <% if @changesets_latest_coimmit %> <% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %> <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %> diff --git a/lib/redmine/scm/adapters/gitlab_adapter.rb b/lib/redmine/scm/adapters/gitlab_adapter.rb index 7b2d18310..4aaf8fc91 100644 --- a/lib/redmine/scm/adapters/gitlab_adapter.rb +++ b/lib/redmine/scm/adapters/gitlab_adapter.rb @@ -96,7 +96,7 @@ module Redmine :path => File.join(path,tree.name), :kind => tree.type == 'tree' ? 'dir' : 'file', :size => nil, - :lastrev => nil + :lastrev => tree.commit_id }) end entries.sort_by_name