2011-03-10 12:39:24 +00:00
|
|
|
class Git::BaseController < ApplicationController
|
|
|
|
before_filter :authenticate_user!
|
|
|
|
|
2011-03-10 14:22:53 +00:00
|
|
|
before_filter :find_platform
|
2011-03-10 12:39:24 +00:00
|
|
|
before_filter :find_repository
|
2011-03-11 17:19:47 +00:00
|
|
|
before_filter :find_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
|
2011-03-10 12:39:24 +00:00
|
|
|
|
|
|
|
protected
|
2011-03-10 13:19:23 +00:00
|
|
|
def find_platform
|
2011-03-11 17:19:47 +00:00
|
|
|
@platform = Platform.find(params[:platform_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_repository
|
|
|
|
@repository = @platform.repositories.find(params[:repository_id])
|
2011-03-10 13:19:23 +00:00
|
|
|
end
|
|
|
|
|
2011-03-10 12:39:24 +00:00
|
|
|
def find_project
|
2011-03-11 17:19:47 +00:00
|
|
|
@project = @repository.projects.find(params[:project_id])
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|
|
|
|
|
2011-03-11 17:19:47 +00:00
|
|
|
def find_git_repository
|
|
|
|
@git_repository = @project.git_repository
|
2011-03-10 12:39:24 +00:00
|
|
|
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
|
2011-04-07 14:20:21 +01:00
|
|
|
@treeish = params[:treeish].present? ? params[:treeish] : "master"
|
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
|
2011-03-10 12:39:24 +00:00
|
|
|
end
|