From fe3fbacdbc7bf6e594b3763fac33a2d5c6eb06ca Mon Sep 17 00:00:00 2001 From: houxiang Date: Wed, 18 Nov 2015 16:11:51 +0800 Subject: [PATCH] modify commit count show --- app/controllers/repositories_controller.rb | 28 +++++++++++++++++++++- app/views/projects/show.html.erb | 4 ++-- app/views/repositories/_revisions.html.erb | 6 +++++ app/views/repositories/changes.html.erb | 4 +++- app/views/repositories/show.html.erb | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 21ee6e1de..de44f44d5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -271,11 +271,37 @@ update alias_method :browse, :show + + #add by houxiang + + def get_commits(id) + g = Gitlab.client + tmp_commit = g.commits(id,page:0) + commits = [] + i=0 + while tmp_commit!=[] + commits = commits+tmp_commit + i=i+1 + tmp_commit = g.commits(id,page:i) + end + commits_count = commits.length + + return commits_count + + end + + def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client - @commits = g.commits(@project.gpid, page:params[:page]) + limit = 20 + + + @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) + @commits_count = get_commits(@project.gpid) + @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] + @commit = g.commit(@project.gpid,@rev) # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 22317dc91..8d371912e 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -20,7 +20,7 @@ <% next if e.forge_act_type.safe_constantize.nil? act = e.forge_act; next if act.nil? %> - + \ <% if e.forge_act_type == "Issue" %>
<%= image_tag(url_to_avatar(act.author), :width => "42", :height => "42") %> @@ -111,4 +111,4 @@ <% end %> <% end %> <% end %> -<%= paginate @events_pages, :left => 3, :right => 3 %> \ No newline at end of file +<%= paginate @events_pages, :left => 3, :right => 3 %> diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 837096c89..50c973fb4 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -13,6 +13,7 @@ + <% show_diff = revisions.size > 1 %> <% line_num = 1 %> <% revisions.each do |changeset| %> @@ -48,4 +49,9 @@ <%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>

+ + <% end %> + diff --git a/app/views/repositories/changes.html.erb b/app/views/repositories/changes.html.erb index 428799f07..3780df172 100644 --- a/app/views/repositories/changes.html.erb +++ b/app/views/repositories/changes.html.erb @@ -14,7 +14,9 @@ <%= render_properties(@properties) %>
- <%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @commits, :entry => @entry }) unless @commits.empty? %> + + <%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path ,:revisions => @commits, :entry => @entry ,:commits_pages =>@commits_pages , :commits_count => @commits_count}) unless @commits.empty? %> +
<% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 9601e5188..af53d760f 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -40,7 +40,7 @@ - <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev} %> 提交 + <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1} %> 提交
<% end %>