debian-mirror-gitlab/app/controllers/projects/tree_controller.rb

30 lines
820 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
# Controller for viewing a repository's file structure
2015-04-26 12:48:37 +05:30
class Projects::TreeController < Projects::ApplicationController
include ExtractsPath
2015-09-11 14:41:01 +05:30
before_action :require_non_empty_project, except: [:new, :create]
before_action :assign_ref_vars
before_action :authorize_download_code!
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
def show
2015-09-11 14:41:01 +05:30
return not_found! unless @repository.commit(@ref)
2014-09-02 18:07:02 +05:30
if tree.entries.empty?
if @repository.blob_at(@commit.id, @path)
2015-04-26 12:48:37 +05:30
redirect_to(
namespace_project_blob_path(@project.namespace, @project,
File.join(@ref, @path))
) and return
2015-09-11 14:41:01 +05:30
elsif @path.present?
2014-09-02 18:07:02 +05:30
return not_found!
end
end
respond_to do |format|
format.html
# Disable cache so browser history works
format.js { no_cache_headers }
end
end
end