diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 12e41a83a..4764d1cd7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -39,6 +39,8 @@ class RepositoriesController < ApplicationController before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analysis] # 链接gitlab before_filter :connect_gitlab, :only => [:quality_analysis, :show] + # 版本库新增权限 + before_filter :show_rep, :only => [:show] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -361,10 +363,7 @@ update def show ## TODO: the below will move to filter, done. - if !User.current.member_of?(@project) && @project.hidden_repo - render_403 - return - end + # 获取版本库目录结构 @entries = @repository.entries(@path, @rev) if request.xhr? @@ -654,9 +653,20 @@ update # 链接gitlab def connect_gitlab - @g = Gitlab.client - unless @project.gpid.nil? - @g_project = @g.project(@project.gpid) + begin + @g = Gitlab.client + unless @project.gpid.nil? + @g_project = @g.project(@project.gpid) + end + rescue => e + logger.error("failed to connect gitlab ==> #{e}") + end + end + + def show_rep + if !User.current.member_of?(@project) && @project.hidden_repo + render_403 + return end end diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index 4dee108ee..7a378dcb2 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -9,7 +9,7 @@ <% if entry.is_dir? %> -<%# 展开文件目录 %> + <%# 展开文件目录 %>   <% end %> - - - - <%#= h(ent_name), :class => "(entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> -<%= link_to h(ent_name), - {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, - :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> + <%= link_to h(ent_name), + {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, + :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> - - -<%# if @repository.report_last_commit %>
-<%# end %> <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index f4a50dfb9..823d0c1ad 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -65,19 +65,9 @@
<% end %> - - <% if !@entries.nil? && authorize_for('repositories', 'browse') %> - <%# 数据统计 %> - <%#= render :partial => 'summary' %> - <%# end %> - <%#= render :partial => 'dir_list' %> + <%= render :partial => 'dir_list' %> <% end %> -<%#= render_properties(@properties) %> - - -<%#= render_properties(@properties) %> - 如何提交代码