From 54b66b86dc52b36b1345b588bc3338299f6d0b15 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 8 Oct 2016 15:58:05 +0800 Subject: [PATCH] 0 --- app/controllers/repositories_controller.rb | 54 ++++++++++++---------- app/views/layouts/base_projects.html.erb | 2 +- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d1f3ffa7f..08ffca920 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -379,33 +379,37 @@ update def show # 获取版本库目录结构 @entries = @repository.entries(@path, @rev) - @changesets_latest_coimmit = @g.commits(@project.gpid, :ref_name => @rev)[0] - - # 总的提交数 - @changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count - - # 获取默认分支 - @g_default_branch = @g_project.default_branch.nil? ? "master" : @g_project.default_branch - - @creator = @project.owner.to_s - gitlab_address = Redmine::Configuration['gitlab_address'] - # REDO:需优化,仅测试用 - @zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token - @repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git" - - # 一些数据的异步同步更新 - # 访问版本庫后更新project_score表数据;changeset_num为提交总数 - project_score = @project.project_score - if project_score.nil? - ProjectScore.create(:project_id => @project.id, :score => false) + if request.xhr? + @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else - project_score.update_column(:changeset_num, @changesets_all_count) - end - unless @changesets_latest_coimmit.blank? - update_commits_date(@project, @changesets_latest_coimmit) - end + @changesets_latest_coimmit = @g.commits(@project.gpid, :ref_name => @rev)[0] - render :layout => 'base_projects' + # 总的提交数 + @changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count + + # 获取默认分支 + @g_default_branch = @g_project.default_branch.nil? ? "master" : @g_project.default_branch + + @creator = @project.owner.to_s + gitlab_address = Redmine::Configuration['gitlab_address'] + # REDO:需优化,仅测试用 + @zip_path = Gitlab.endpoint.to_s + "/projects/" + @project.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token + @repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git" + + # 一些数据的异步同步更新 + # 访问版本庫后更新project_score表数据;changeset_num为提交总数 + project_score = @project.project_score + if project_score.nil? + ProjectScore.create(:project_id => @project.id, :score => false) + else + project_score.update_column(:changeset_num, @changesets_all_count) + end + unless @changesets_latest_coimmit.blank? + update_commits_date(@project, @changesets_latest_coimmit) + end + + render :layout => 'base_projects' + end end alias_method :browse, :show diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 93bc665b3..6f0b75b31 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -53,7 +53,7 @@