版本库代码简化

This commit is contained in:
huang 2016-10-08 10:10:59 +08:00
parent 25b2602d3e
commit 0906da5132
1 changed files with 14 additions and 24 deletions

View File

@ -376,11 +376,21 @@ update
def show
## TODO: the below will move to filter, done.
# 访问版本庫后更新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
# 获取版本库目录结构
@entries = @repository.entries(@path, @rev)
#@entries = @repository.entries(@path, @rev)
if request.xhr?
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
#@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else
@changesets = @g.commits(@project.gpid, :ref_name => @rev)
# 最近一次提交
@ -388,34 +398,14 @@ update
g_project = @g.project(@project.gpid)
# 总的提交数
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
# 获取默认分支
@g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
# 访问版本庫后更新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
@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
# 获取版本库路径主要分为两种一种随Gitlab类型另一种为Git类型Git类型为无用数据最终需要删掉这种类型。
# if @repository.type.to_s == "Repository::Gitlab"
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
# else
# @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s + @repository.url.slice(project_path_cut, @repository.url.length).to_s
# end
render :action => 'show', :layout => 'base_projects'
@repos_url = gitlab_address.to_s+"/" + @creator + "/" + @repository.identifier+"."+"git"
render :layout => 'base_projects'
end
end