diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 96ea2a84e..2f0b1d45e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -63,18 +63,27 @@ class IssuesController < ApplicationController begin return render_404 if @project.gpid.nil? @issue_commit_ids = (params[:issue_commit_ids].is_a?(Array) ? params[:issue_commit_ids] : params[:issue_commit_ids].split(",")) unless params[:issue_commit_ids].nil? - search = params[:search].to_s.lstrip.rstrip + search = params[:search].to_s.strip @type = params[:type] - limit = 20 + limit = 15 g = Gitlab.client g_project = g.project(@project.gpid) rev = params[:branch].nil? ? g_project.default_branch : params[:branch] - @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev).select{|commit| commit.title.include?("#{search}")} @project_branches = g.branches(@project.gpid) @branch_names = @project_branches.map{|b| b.name} @default_branch = g_project.default_branch - @commits_count = g.user_static(@project.gpid, :rev => rev).count - @commits_pages = Redmine::Pagination::Paginator.new @commits_count, limit, params[:page] + # 搜索的分页需要单独处理,因为搜索不容易获取总数 + if search.present? + @commits = g.commits(@project.gpid, ref_name:rev, :search => search) + @commits_count = @commits.count + @commits_pages = Paginator.new @commits_count, limit, params['page'] || 1 + @offset ||= @commits_pages.offset + @commits = paginateHelper @commits,limit + else + @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev, :search => search) + @commits_count = g.user_static(@project.gpid, :rev => rev).count + @commits_pages = Redmine::Pagination::Paginator.new @commits_count, limit, params[:page] + end rescue Exception => e puts e end diff --git a/app/views/issues/_issue_commits_list.html.erb b/app/views/issues/_issue_commits_list.html.erb index 10cfe57ca..b6fc888a1 100644 --- a/app/views/issues/_issue_commits_list.html.erb +++ b/app/views/issues/_issue_commits_list.html.erb @@ -25,7 +25,7 @@
-
+ diff --git a/app/views/issues/issue_commits.js.erb b/app/views/issues/issue_commits.js.erb index ed25846b2..b995d9f49 100644 --- a/app/views/issues/issue_commits.js.erb +++ b/app/views/issues/issue_commits.js.erb @@ -2,6 +2,6 @@ $("#issue_commit_list").html('<%= escape_javascript(render :partial => 'issues/issue_commits_list') %>'); <% else %> var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>"; -pop_box_new(htmlvalue,760,860); +pop_box_new(htmlvalue,760,600); <% end %> diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index 60c58ef98..4b458ecee 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -52,6 +52,7 @@ class Gitlab::Client # @option options [String] :ref_name The branch or tag name of a project repository. # @option options [Integer] :page The page number. # @option options [Integer] :per_page The number of results per page. + # @option options [String] :search The obj of results's search value. # @return [Array] def commits(project, options={}) get("/projects/#{project}/repository/commits", :query => options)