2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
class Projects::NetworkController < Projects::ApplicationController
|
|
|
|
include ExtractsPath
|
|
|
|
include ApplicationHelper
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before_action :whitelist_query_limiting
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2019-02-15 15:39:39 +05:30
|
|
|
before_action :assign_options
|
2017-08-17 22:00:37 +05:30
|
|
|
before_action :assign_commit
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
def show
|
2018-03-27 19:54:05 +05:30
|
|
|
@url = project_network_path(@project, @ref, @options.merge(format: :json))
|
|
|
|
@commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
if @options[:extended_sha1] && !@commit
|
|
|
|
flash.now[:alert] = "Git revision '#{@options[:extended_sha1]}' does not exist."
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
format.json do
|
|
|
|
@graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref])
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
render
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
def assign_options
|
|
|
|
@options = params.permit(:filter_ref, :extended_sha1)
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def assign_commit
|
2019-02-15 15:39:39 +05:30
|
|
|
return if @options[:extended_sha1].blank?
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
@commit = @repo.commit(@options[:extended_sha1])
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def whitelist_query_limiting
|
2019-12-04 20:38:33 +05:30
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42333')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|