2012-09-17 16:38:59 +00:00
|
|
|
# Controller for viewing a repository's file structure
|
2015-01-26 23:01:51 +00:00
|
|
|
class Projects::TreeController < Projects::ApplicationController
|
|
|
|
include ExtractsPath
|
|
|
|
|
2015-04-16 12:03:37 +00:00
|
|
|
before_action :require_non_empty_project, except: [:new, :create]
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2014-07-07 13:46:57 +00:00
|
|
|
|
2015-01-26 23:01:51 +00:00
|
|
|
def show
|
2014-07-07 13:46:57 +00:00
|
|
|
if tree.entries.empty?
|
|
|
|
if @repository.blob_at(@commit.id, @path)
|
2015-01-24 18:02:58 +00:00
|
|
|
redirect_to(
|
|
|
|
namespace_project_blob_path(@project.namespace, @project,
|
|
|
|
File.join(@ref, @path))
|
|
|
|
) and return
|
2014-07-07 13:46:57 +00:00
|
|
|
else
|
|
|
|
return not_found!
|
|
|
|
end
|
|
|
|
end
|
2013-10-01 14:00:28 +00:00
|
|
|
|
2012-09-17 16:38:59 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
# Disable cache so browser history works
|
|
|
|
format.js { no_cache_headers }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|