2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-05-02 10:18:07 +01:00
|
|
|
class Projects::Git::BaseController < Projects::BaseController
|
2011-03-10 12:39:24 +00:00
|
|
|
before_filter :authenticate_user!
|
2013-02-13 11:42:24 +00:00
|
|
|
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive, :diff, :tags, :branches] if APP_CONFIG['anonymous_access']
|
2012-03-21 19:55:14 +00:00
|
|
|
load_and_authorize_resource :project
|
2011-03-10 12:39:24 +00:00
|
|
|
|
2012-07-17 09:02:56 +01:00
|
|
|
before_filter :set_treeish_and_path
|
|
|
|
before_filter :set_branch_and_tree
|
2011-03-10 12:39:24 +00:00
|
|
|
|
|
|
|
protected
|
2011-04-04 17:00:24 +01:00
|
|
|
|
2012-07-17 09:02:56 +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]
|
2012-04-19 20:45:50 +01:00
|
|
|
end
|
2011-04-04 17:00:24 +01:00
|
|
|
|
2012-07-17 09:02:56 +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?
|
2012-04-19 20:45:50 +01:00
|
|
|
end
|
2012-01-30 20:39:34 +00:00
|
|
|
end
|