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

39 lines
1003 B
Ruby
Raw Normal View History

2012-01-30 20:39:34 +00:00
# -*- encoding : utf-8 -*-
class Git::BaseController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
before_filter :find_git_repository
2011-04-04 17:00:24 +01:00
before_filter :find_tags
before_filter :find_branches
before_filter :set_treeish
before_filter :set_current_tag
before_filter :set_current_branch
protected
def find_git_repository
@git_repository = @project.git_repository
end
2011-04-04 17:00:24 +01:00
def find_tags
@tags = @git_repository.tags
end
def find_branches
@branches = @git_repository.branches
end
def set_treeish
@treeish = params[:treeish].presence || @project.default_branch
2011-04-04 17:00:24 +01:00
end
def set_current_tag
@current_tag = @tags.select{|t| t.name == @treeish }.first
end
def set_current_branch
@current_branch = @branches.select{|b| b.name == @treeish }.first
end
2012-01-30 20:39:34 +00:00
end