2013-06-23 12:47:22 -04:00
|
|
|
class Projects::RefsController < Projects::ApplicationController
|
2013-04-14 08:08:16 -04:00
|
|
|
include ExtractsPath
|
2015-07-26 05:17:34 -04:00
|
|
|
include TreeHelper
|
2011-11-16 00:38:53 -05:00
|
|
|
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
2015-10-13 00:43:24 -04:00
|
|
|
before_action :validate_ref_id
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2011-11-16 00:38:53 -05:00
|
|
|
|
2012-10-09 15:09:46 -04:00
|
|
|
def switch
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2015-07-02 14:12:24 -04:00
|
|
|
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)
|
2016-01-07 06:56:18 -05:00
|
|
|
when "find_file"
|
|
|
|
namespace_project_find_file_path(@project.namespace, @project, @id)
|
2015-07-02 14:12:24 -04:00
|
|
|
when "graphs_commits"
|
|
|
|
commits_namespace_project_graph_path(@project.namespace, @project, @id)
|
2016-04-04 04:40:40 -04:00
|
|
|
when "badges"
|
2016-07-20 08:33:13 -04:00
|
|
|
namespace_project_pipelines_settings_path(@project.namespace, @project, ref: @id)
|
2015-07-02 14:12:24 -04:00
|
|
|
else
|
|
|
|
namespace_project_commits_path(@project.namespace, @project, @id)
|
|
|
|
end
|
2011-11-16 12:19:18 -05:00
|
|
|
|
2012-09-17 13:49:57 -04:00
|
|
|
redirect_to new_path
|
2012-01-29 14:30:03 -05:00
|
|
|
end
|
|
|
|
end
|
2011-11-16 12:19:18 -05:00
|
|
|
end
|
|
|
|
|
2012-07-10 15:52:38 -04:00
|
|
|
def logs_tree
|
2014-06-12 05:01:54 -04:00
|
|
|
@offset = if params[:offset].present?
|
2015-02-03 00:38:50 -05:00
|
|
|
params[:offset].to_i
|
|
|
|
else
|
|
|
|
0
|
|
|
|
end
|
2014-06-12 05:01:54 -04:00
|
|
|
|
2014-06-26 03:29:39 -04:00
|
|
|
@limit = 25
|
2014-06-12 05:01:54 -04:00
|
|
|
|
|
|
|
@path = params[:path]
|
|
|
|
|
|
|
|
contents = []
|
2014-10-09 03:47:47 -04:00
|
|
|
contents.push(*tree.trees)
|
|
|
|
contents.push(*tree.blobs)
|
|
|
|
contents.push(*tree.submodules)
|
2014-06-12 05:01:54 -04:00
|
|
|
|
|
|
|
@logs = contents[@offset, @limit].to_a.map do |content|
|
|
|
|
file = @path ? File.join(@path, content.name) : content.name
|
2014-02-10 14:46:46 -05:00
|
|
|
last_commit = @repo.last_commit_for_path(@commit.id, file)
|
2012-07-22 07:08:24 -04:00
|
|
|
{
|
2012-09-17 13:49:57 -04:00
|
|
|
file_name: content.name,
|
2012-08-10 18:07:50 -04:00
|
|
|
commit: last_commit
|
2012-07-10 15:52:38 -04:00
|
|
|
}
|
|
|
|
end
|
2015-04-06 23:02:06 -04:00
|
|
|
|
2016-02-23 08:41:03 -05:00
|
|
|
offset = (@offset + @limit)
|
2016-02-23 04:06:26 -05:00
|
|
|
if contents.size > offset
|
|
|
|
@more_log_url = logs_file_namespace_project_ref_path(@project.namespace, @project, @ref, @path || '', offset: offset)
|
2015-07-26 05:17:34 -04:00
|
|
|
end
|
|
|
|
|
2015-04-06 23:02:06 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { render_404 }
|
|
|
|
format.js
|
|
|
|
end
|
2012-07-10 15:52:38 -04:00
|
|
|
end
|
2015-10-13 00:43:24 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def validate_ref_id
|
|
|
|
return not_found! if params[:id].present? && params[:id] !~ Gitlab::Regex.git_reference_regex
|
|
|
|
end
|
2011-11-16 00:38:53 -05:00
|
|
|
end
|