BigW Consortium Gitlab

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

  before_filter :assign_ref_vars
  before_filter :authorize_download_code!
  before_filter :require_non_empty_project, except: [:new, :create]
8

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

18 19 20 21 22 23 24
    respond_to do |format|
      format.html
      # Disable cache so browser history works
      format.js { no_cache_headers }
    end
  end
end