gitlab-org--gitlab-foss/app/controllers/projects/refs_controller.rb

65 lines
1.8 KiB
Ruby
Raw Normal View History

class Projects::RefsController < Projects::ApplicationController
2013-04-14 12:08:16 +00:00
include ExtractsPath
2011-11-16 05:38:53 +00:00
before_filter :require_non_empty_project
before_filter :assign_ref_vars
before_filter :authorize_download_code!
2011-11-16 05:38:53 +00:00
def switch
respond_to do |format|
format.html do
2012-01-29 19:30:03 +00:00
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)
2012-01-29 19:30:03 +00:00
else
namespace_project_commits_path(@project.namespace, @project, @id)
2012-01-29 19:30:03 +00:00
end
2011-11-16 17:19:18 +00:00
2012-09-17 17:49:57 +00:00
redirect_to new_path
2012-01-29 19:30:03 +00:00
end
2012-09-17 17:49:57 +00:00
format.js do
2012-01-29 19:30:03 +00:00
@ref = params[:ref]
define_tree_vars
2013-10-01 14:00:28 +00:00
tree
2012-01-29 19:30:03 +00:00
render "tree"
end
end
2011-11-16 17:19:18 +00:00
end
2012-07-10 19:52:38 +00:00
def logs_tree
@offset = if params[:offset].present?
2015-02-03 05:38:50 +00:00
params[:offset].to_i
else
0
end
@limit = 25
@path = params[:path]
contents = []
2014-10-09 07:47:47 +00:00
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)
2012-07-22 11:08:24 +00:00
{
2012-09-17 17:49:57 +00:00
file_name: content.name,
commit: last_commit
2012-07-10 19:52:38 +00:00
}
end
respond_to do |format|
format.html { render_404 }
format.js
end
2012-07-10 19:52:38 +00:00
end
2011-11-16 05:38:53 +00:00
end