Mercurial > hg > soundsoftware-site
annotate plugins/redmine_checkout/lib/checkout/repository_hooks.rb @ 1628:9c5f8e24dadc live tip
Quieten this cron script
author | Chris Cannam |
---|---|
date | Tue, 25 Aug 2020 11:38:49 +0100 |
parents | 12556ba57d17 |
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@1315 | 30 |
chris@1315 | 31 # cc: cribbed from |
chris@1315 | 32 # http://www.redmine.org/projects/redmine/repository/revisions/9785/diff/trunk/lib/redmine/hook.rb |
chris@1315 | 33 # for http://www.redmine.org/issues/11105 (formerly used |
chris@1315 | 34 # render_to_string on this controller, wasn't working for |
chris@1315 | 35 # :header_tags) |
chris@1315 | 36 context[:hook_caller].send(:render, {:locals => context}.merge(options)) |
Chris@16 | 37 end |
Chris@16 | 38 end |
Chris@16 | 39 end |
chris@1315 | 40 end |