2013-06-23 16:47:22 +00:00
|
|
|
class Projects::RefsController < Projects::ApplicationController
|
2013-04-14 12:08:16 +00:00
|
|
|
include ExtractsPath
|
2011-11-16 05:38:53 +00:00
|
|
|
|
|
|
|
# Authorize
|
|
|
|
before_filter :authorize_read_project!
|
2012-02-21 22:31:18 +00:00
|
|
|
before_filter :authorize_code_access!
|
2011-11-16 05:38:53 +00:00
|
|
|
before_filter :require_non_empty_project
|
|
|
|
|
2012-10-09 19:09:46 +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"
|
2013-04-14 12:08:16 +00:00
|
|
|
project_tree_path(@project, (@id))
|
2013-04-22 22:28:30 +00:00
|
|
|
elsif params[:destination] == "blob"
|
2013-04-14 12:08:16 +00:00
|
|
|
project_blob_path(@project, (@id))
|
2013-01-29 08:25:17 +00:00
|
|
|
elsif params[:destination] == "graph"
|
2013-06-11 06:54:01 +00:00
|
|
|
project_network_path(@project, @id, @options)
|
2012-01-29 19:30:03 +00:00
|
|
|
else
|
2013-04-14 12:08:16 +00:00
|
|
|
project_commits_path(@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
|
|
|
|
render "tree"
|
|
|
|
end
|
|
|
|
end
|
2011-11-16 17:19:18 +00:00
|
|
|
end
|
|
|
|
|
2012-07-10 19:52:38 +00:00
|
|
|
def logs_tree
|
2013-04-02 19:37:20 +00:00
|
|
|
contents = @tree.entries
|
2012-07-10 19:52:38 +00:00
|
|
|
@logs = contents.map do |content|
|
|
|
|
file = params[:path] ? File.join(params[:path], content.name) : content.name
|
2013-01-03 19:09:18 +00:00
|
|
|
last_commit = @repo.commits(@commit.id, file, 1).last
|
2012-07-22 11:08:24 +00:00
|
|
|
{
|
2012-09-17 17:49:57 +00:00
|
|
|
file_name: content.name,
|
2012-08-10 22:07:50 +00:00
|
|
|
commit: last_commit
|
2012-07-10 19:52:38 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2011-11-16 05:38:53 +00:00
|
|
|
end
|