debian-mirror-gitlab/app/controllers/projects/network_controller.rb

34 lines
965 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Projects::NetworkController < Projects::ApplicationController
include ExtractsPath
include ApplicationHelper
2015-09-11 14:41:01 +05:30
before_action :require_non_empty_project
before_action :assign_ref_vars
before_action :authorize_download_code!
2017-08-17 22:00:37 +05:30
before_action :assign_commit
2014-09-02 18:07:02 +05:30
def show
2017-09-10 17:25:29 +05:30
@url = project_network_path(@project, @ref, @options.merge(format: :json))
@commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
2015-09-11 14:41:01 +05:30
2014-09-02 18:07:02 +05:30
respond_to do |format|
2017-08-17 22:00:37 +05:30
format.html do
if @options[:extended_sha1] && !@commit
flash.now[:alert] = "Git revision '#{@options[:extended_sha1]}' does not exist."
end
end
2014-09-02 18:07:02 +05:30
format.json do
@graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref])
end
end
end
2017-08-17 22:00:37 +05:30
def assign_commit
return if params[:extended_sha1].blank?
@options[:extended_sha1] = params[:extended_sha1]
@commit = @repo.commit(@options[:extended_sha1])
end
2014-09-02 18:07:02 +05:30
end