Network page appear with an error message when entering nonexistent git revision

This commit is contained in:
Hiroyuki Sato 2016-10-28 20:38:14 +09:00
parent c392b0cc24
commit 56264f35d4
4 changed files with 10 additions and 5 deletions

View file

@ -9,6 +9,8 @@
(function() { (function() {
$(function() { $(function() {
if (!$(".network-graph").length) return;
var network_graph; var network_graph;
network_graph = new Network({ network_graph = new Network({
url: $(".network-graph").attr('data-url'), url: $(".network-graph").attr('data-url'),

View file

@ -11,7 +11,9 @@ class Projects::NetworkController < Projects::ApplicationController
@commit_url = namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s") @commit_url = namespace_project_commit_path(@project.namespace, @project, 'ae45ca32').gsub("ae45ca32", "%s")
respond_to do |format| respond_to do |format|
format.html format.html do
flash.now[:alert] = "Git revision '#{params[:extended_sha1]}' does not exist." if params[:extended_sha1].present? && !@commit
end
format.json do format.json do
@graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref]) @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref])

View file

@ -17,5 +17,6 @@
= check_box_tag :filter_ref, 1, @options[:filter_ref] = check_box_tag :filter_ref, 1, @options[:filter_ref]
%span Begin with the selected commit %span Begin with the selected commit
- if @commit
.network-graph{ data: { url: @url, commit_url: @commit_url, ref: @ref, commit_id: @commit.id } } .network-graph{ data: { url: @url, commit_url: @commit_url, ref: @ref, commit_id: @commit.id } }
= spinner nil, true = spinner nil, true

View file

@ -125,9 +125,9 @@ module ExtractsPath
request.format = :atom if @commit request.format = :atom if @commit
end end
end
raise InvalidPathError unless @commit raise InvalidPathError unless @commit
end
@hex_path = Digest::SHA1.hexdigest(@path) @hex_path = Digest::SHA1.hexdigest(@path)
@logs_path = logs_file_namespace_project_ref_path(@project.namespace, @logs_path = logs_file_namespace_project_ref_path(@project.namespace,