BigW Consortium Gitlab

tree_controller.rb 749 Bytes
Newer Older
1
# Controller for viewing a repository's file structure
2 3 4
class Projects::TreeController < Projects::ApplicationController
  include ExtractsPath

5 6 7
  before_action :require_non_empty_project, except: [:new, :create]
  before_action :assign_ref_vars
  before_action :authorize_download_code!
8

9
  def show
10 11
    if tree.entries.empty?
      if @repository.blob_at(@commit.id, @path)
Vinnie Okada committed
12 13 14 15
        redirect_to(
          namespace_project_blob_path(@project.namespace, @project,
                                      File.join(@ref, @path))
        ) and return
16 17 18 19
      else
        return not_found!
      end
    end
20

21 22 23 24 25 26 27
    respond_to do |format|
      format.html
      # Disable cache so browser history works
      format.js { no_cache_headers }
    end
  end
end