annotate vendor/plugins/redmine_checkout/lib/checkout/repository_hooks.rb @ 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 020926a36823
children
rev   line source
Chris@16 1 module Checkout
Chris@16 2 class RepositoryHooks < Redmine::Hook::ViewListener
Chris@16 3 # Renders the checkout URL
Chris@16 4 #
Chris@16 5 # Context:
Chris@16 6 # * :project => Current project
Chris@16 7 # * :repository => Current Repository
Chris@16 8 #
Chris@16 9 def view_repositories_show_contextual(context={})
Chris@16 10 if context[:repository].present? && Setting.checkout_display_checkout_info?
Chris@16 11 protocols = context[:repository].checkout_protocols.select do |p|
Chris@16 12 p.access_rw(User.current)
Chris@16 13 end
Chris@16 14
Chris@16 15 path = context[:controller].instance_variable_get("@path")
Chris@16 16 if path && context[:controller].instance_variable_get("@entry")
Chris@16 17 # a single file is showing, so we return only the directory
Chris@16 18 path = File.dirname(path)
Chris@16 19 end
Chris@16 20
Chris@16 21 default = protocols.find(&:default?) || protocols.first
Chris@16 22
Chris@16 23 context.merge!({
Chris@16 24 :protocols => protocols,
Chris@16 25 :default_protocol => default,
Chris@16 26 :checkout_path => path
Chris@16 27 })
Chris@16 28
Chris@16 29 options = {:partial => "redmine_checkout_hooks/view_repositories_show_contextual"}
Chris@16 30 context[:controller].send(:render_to_string, {:locals => context}.merge(options))
Chris@16 31 end
Chris@16 32 end
Chris@16 33 end
Chris@16 34 end