Class: Projects::TreeController

Inherits:
ApplicationController show all
Includes:
ActionView::Helpers::SanitizeHelper, CreatesCommit, ExtractsPath
Defined in:
app/controllers/projects/tree_controller.rb

Overview

Controller for viewing a repository's file structure

Instance Method Summary collapse

Methods included from CreatesCommit

#authorize_edit_tree!, #create_commit

Methods included from ExtractsPath

#assign_ref_vars, #extract_ref, #tree

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#create_dirObject


34
35
36
37
38
39
40
# File 'app/controllers/projects/tree_controller.rb', line 34

def create_dir
  return render_404 unless @commit_params.values.all?

  create_commit(Files::CreateDirService,  success_notice: "The directory has been successfully created.",
                                          success_path: namespace_project_tree_path(@project.namespace, @project, File.join(@target_branch, @dir_name)),
                                          failure_path: namespace_project_tree_path(@project.namespace, @project, @ref))
end

#showObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/projects/tree_controller.rb', line 13

def show
  return render_404 unless @repository.commit(@ref)

  if tree.entries.empty?
    if @repository.blob_at(@commit.id, @path)
      redirect_to(
        namespace_project_blob_path(@project.namespace, @project,
                                    File.join(@ref, @path))
      ) and return
    elsif @path.present?
      return render_404
    end
  end

  respond_to do |format|
    format.html
    # Disable cache so browser history works
    format.js { no_cache_headers }
  end
end