Class: Projects::RefsController

Inherits:
ApplicationController show all
Includes:
ExtractsPath, TreeHelper
Defined in:
app/controllers/projects/refs_controller.rb

Instance Method Summary collapse

Methods included from TreeHelper

#can_edit_tree?, #commit_in_fork_help, #edit_in_new_fork_notice, #edit_in_new_fork_notice_now, #flatten_tree, #on_top_of_branch?, #render_readme, #render_tree, #tree_breadcrumbs, #tree_edit_branch, #tree_edit_project, #tree_hex_class, #tree_icon, #tree_join, #up_dir_path

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

#logs_treeObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/controllers/projects/refs_controller.rb', line 44

def logs_tree
  @offset = if params[:offset].present?
              params[:offset].to_i
            else
              0
            end

  @limit = 25

  @path = params[:path]

  contents = []
  contents.push(*tree.trees)
  contents.push(*tree.blobs)
  contents.push(*tree.submodules)

  @logs = contents[@offset, @limit].to_a.map do |content|
    file = @path ? File.join(@path, content.name) : content.name
    last_commit = @repo.last_commit_for_path(@commit.id, file)
    {
      file_name: content.name,
      commit: last_commit
    }
  end

  offset = (@offset + @limit)
  if contents.size > offset
    @more_log_url = logs_file_namespace_project_ref_path(@project.namespace, @project, @ref, @path || '', offset: offset)
  end

  respond_to do |format|
    format.html { render_404 }
    format.js
  end
end

#switchObject


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/projects/refs_controller.rb', line 10

def switch
  respond_to do |format|
    format.html do
      new_path =
        case params[:destination]
        when "tree"
          namespace_project_tree_path(@project.namespace, @project, @id)
        when "blob"
          namespace_project_blob_path(@project.namespace, @project, @id)
        when "graph"
          namespace_project_network_path(@project.namespace, @project, @id, @options)
        when "graphs"
          namespace_project_graph_path(@project.namespace, @project, @id)
        when "find_file"
          namespace_project_find_file_path(@project.namespace, @project, @id)
        when "graphs_commits"
          commits_namespace_project_graph_path(@project.namespace, @project, @id)
        when "badges"
          namespace_project_badges_path(@project.namespace, @project, ref: @id)
        else
          namespace_project_commits_path(@project.namespace, @project, @id)
        end

      redirect_to new_path
    end
    format.js do
      @ref = params[:ref]
      define_tree_vars
      tree
      render "tree"
    end
  end
end