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