[#369] dont redirect to project if get an ajax request

This commit is contained in:
Alexander Machehin 2015-03-05 10:57:28 +05:00
parent f6257a97f6
commit 9f53a384db
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,6 @@
class Projects::Git::TreesController < Projects::Git::BaseController
before_filter -> {redirect_to @project if params[:treeish] == @project.resolve_default_branch and params[:path].blank?}, only: :show
before_filter -> { redirect_to_project }, only: :show
skip_before_filter :set_branch_and_tree, :set_treeish_and_path, only: :archive
before_filter -> { raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) }, only: [:branch, :destroy]
@ -79,4 +79,12 @@ class Projects::Git::TreesController < Projects::Git::BaseController
end
end
protected
def redirect_to_project
if params[:treeish] == @project.resolve_default_branch && params[:path].blank? && !request.xhr?
redirect_to @project
end
end
end

View File

@ -10,6 +10,7 @@ if params[:info] == 'true'
else
page = params[:page].to_i
page = page < 1 ? 0 : page
json.tree do
json.array! @project.tree_info(@tree, @treeish, @path, page).each do |node, node_path, commit|