Welcome to mirror list, hosted at ThFree Co, Russian Federation.

refs_controller.rb « projects « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec3b2b8d75a56d8d125555d5ed7fb373a8beb348 (plain)
1
2
3
4
5
6
7
8
9
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Projects::RefsController < Projects::ApplicationController
  include ExtractsPath

  before_filter :require_non_empty_project
  before_filter :assign_ref_vars
  before_filter :authorize_download_code!

  def switch
    respond_to do |format|
      format.html do
        new_path = if params[:destination] == "tree"
                     namespace_project_tree_path(@project.namespace, @project,
                                                 (@id))
                   elsif params[:destination] == "blob"
                     namespace_project_blob_path(@project.namespace, @project,
                                                 (@id))
                   elsif params[:destination] == "graph"
                     namespace_project_network_path(@project.namespace, @project, @id, @options)
                   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

  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

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