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

22 lines
728 B
Ruby
Raw Normal View History

2012-01-30 20:39:34 +00:00
# -*- encoding : utf-8 -*-
class Projects::Git::BaseController < Projects::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive, :diff, :tags, :branches] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
before_filter :set_treeish_and_path
before_filter :set_branch_and_tree
protected
2011-04-04 17:00:24 +01:00
def set_treeish_and_path
2013-02-21 19:24:20 +00:00
@treeish, @path = params[:treeish].presence || @project.default_head, params[:path]
end
2011-04-04 17:00:24 +01:00
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
2012-01-30 20:39:34 +00:00
end