rosa-build/app/controllers/projects/git/base_controller.rb

23 lines
709 B
Ruby

# -*- encoding : utf-8 -*-
class Projects::Git::BaseController < Projects::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
before_filter :set_treeish_and_path
before_filter :set_branch_and_tree
protected
def set_treeish_and_path
@treeish = params[:treeish].presence || @project.default_branch
@path = params[:path]
end
def set_branch_and_tree
@branch = @project.repo.branches.detect{|b| b.name == @treeish}
@tree = @project.repo.tree(@treeish)
# raise Grit::NoSuchPathError if @tree.blobs.blank?
end
end