Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 09476dc

Browse files
committed
Fix supported_scm for recent Redmine and ChiliProject versions
git-svn-id: http://dev.holgerjust.de/svn/redmine-checkout/trunk@204 2c10314b-d60d-4f8f-b362-a6b3e82123ed
1 parent a9ce248 commit 09476dc

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

app/views/settings/_checkout.rhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ document.observe("dom:loaded", function() {
88
e.down('div').hide();
99
});
1010
<%
11-
CheckoutHelper.supported_scm.select{|scm| Setting.enabled_scm.include?(scm)}.each do |scm|
11+
CheckoutHelper.supported_scm.select{|scm| Setting.enabled_scm.include?(scm)}.each do |scm|
1212
next if Setting.send("checkout_overwrite_description_#{scm}?")
1313
-%>
1414
$('settings_checkout_description_<%= scm %>').up('div').up('div').hide();
@@ -30,7 +30,7 @@ document.observe("dom:loaded", function() {
3030

3131
<% CheckoutHelper.supported_scm.select{|scm| Setting.enabled_scm.include?(scm)}.each do |scm| -%>
3232
<fieldset class="collapsible collapsed">
33-
<legend onclick="toggleFieldset(this);"><%= "Repository::#{scm}".constantize.scm_name %></legend>
33+
<legend onclick="toggleFieldset(this);"><%= Repository.const_get(scm).scm_name %></legend>
3434
<div><%= render :partial => 'checkout_scm', :locals => {:scm => scm} %></div>
3535
</fieldset>
3636
<%- end %>

init.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
# Patches
66
require_dependency 'checkout/application_controller_patch'
77
require_dependency 'checkout/settings_controller_patch'
8-
8+
99
require_dependency 'checkout/repositories_helper_patch'
1010
require_dependency 'checkout/repository_patch'
11-
11+
1212
require_dependency 'checkout/settings_helper_patch'
1313
require_dependency 'checkout/setting_patch'
1414
end
@@ -23,13 +23,13 @@
2323
author_url 'http://meine-er.de'
2424
description 'Add links to the actual repository to the repository view.'
2525
version '0.5'
26-
26+
2727
# required because of the new i18n requirement and changed syntax
2828
requires_redmine :version_or_higher => '1.0.5'
29-
29+
3030
settings_defaults = HashWithIndifferentAccess.new({
3131
'use_zero_clipboard' => '1',
32-
32+
3333
'display_checkout_info' => 'everywhere',
3434
'description_Abstract' => <<-EOF
3535
The data contained in this repository can be downloaded to your computer using one of several clients.
@@ -38,17 +38,17 @@
3838
Please select the desired protocol below to get the URL.
3939
EOF
4040
})
41-
41+
4242
# this is needed for setting the defaults
4343
require 'checkout/repository_patch'
44-
44+
4545
CheckoutHelper.supported_scm.each do |scm|
46-
klazz = "Repository::#{scm}".constantize
47-
46+
klazz = Repository.const_get(scm)
47+
4848
settings_defaults["description_#{scm}"] = ''
4949
settings_defaults["overwrite_description_#{scm}"] = '0'
5050
settings_defaults["display_command_#{scm}"] = '0'
51-
51+
5252
# access can be one of
5353
# read+write => this protocol always allows read/write access
5454
# read-only => this protocol always allows read access only
@@ -65,9 +65,9 @@
6565
:display_login => '0'
6666
})]
6767
end
68-
68+
6969
settings :default => settings_defaults, :partial => 'settings/redmine_checkout'
70-
70+
7171
Redmine::WikiFormatting::Macros.register do
7272
desc <<-EOF
7373
Creates a checkout link to the actual repository. Example:
@@ -85,18 +85,18 @@
8585
else
8686
project = @project
8787
end
88-
88+
8989
if project && project.repository
9090
protocols = project.repository.checkout_protocols.select{|p| p.access_rw(User.current)}
91-
91+
9292
if proto.present?
9393
proto_obj = protocols.find{|p| p.protocol.downcase == proto.downcase}
9494
else
9595
proto_obj = protocols.find(&:default?) || protocols.first
9696
end
9797
end
9898
raise "Checkout protocol #{proto} not found" unless proto_obj
99-
99+
100100
cmd = (project.repository.checkout_display_command? && proto_obj.command.present?) ? proto_obj.command.strip + " " : ""
101101
cmd + link_to(proto_obj.url, proto_obj.url)
102102
end

lib/checkout/repository_patch.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,61 @@ module RepositoryPatch
66
def self.included(base) # :nodoc:
77
base.extend(ClassMethods)
88
base.send(:include, InstanceMethods)
9-
9+
1010
base.class_eval do
1111
unloadable
1212
serialize :checkout_settings, Hash
1313
end
1414
end
15-
15+
1616
module ClassMethods
1717
def allow_subtree_checkout?
1818
# default implementation
1919
false
2020
end
21-
21+
2222
def checkout_default_command
2323
# default implementation
2424
""
2525
end
2626
end
27-
27+
2828
module InstanceMethods
2929
def after_initialize
3030
self.checkout_settings ||= {}
3131
end
32-
32+
3333
def checkout_overwrite=(value)
3434
checkout_settings['checkout_overwrite'] = value
3535
end
36-
36+
3737
def checkout_overwrite
3838
(checkout_settings['checkout_overwrite'].to_i > 0) ? '1' : '0'
3939
end
4040

4141
def checkout_overwrite?
4242
self.type.present? && checkout_overwrite.to_i > 0
4343
end
44-
44+
4545
def checkout_description=(value)
4646
checkout_settings['checkout_description'] = value
4747
end
48-
48+
4949
def checkout_description
5050
if checkout_overwrite?
5151
checkout_settings['checkout_description']
5252
else
53-
if CheckoutHelper.supported_scm.include?(type) && Setting.send("checkout_overwrite_description_#{type}?")
53+
if CheckoutHelper.supported_scm.include?(type.demodulize) && Setting.send("checkout_overwrite_description_#{type}?")
5454
Setting.send("checkout_description_#{type}")
5555
else
5656
Setting.send("checkout_description_Abstract")
5757
end
5858
end
5959
end
60-
60+
6161
def checkout_protocols
6262
@checkout_protocols ||= begin
63-
if CheckoutHelper.supported_scm.include? type
63+
if CheckoutHelper.supported_scm.include?(type.demodulize)
6464
if checkout_overwrite?
6565
protocols = checkout_settings['checkout_protocols'] || []
6666
else
@@ -69,43 +69,43 @@ def checkout_protocols
6969
else
7070
protocols = []
7171
end
72-
72+
7373
protocols.collect do |p|
7474
Checkout::Protocol.new p.merge({:repository => self})
7575
end
7676
end
7777
end
78-
78+
7979
def checkout_protocols=(value)
8080
# value is an Array or a Hash
8181
if value.is_a? Hash
8282
value = value.dup.delete_if {|id, protocol| id.to_i < 0 }
8383
value = value.sort{|(ak,av),(bk,bv)|ak<=>bk}.collect{|id,protocol| protocol}
8484
end
85-
85+
8686
checkout_settings['checkout_protocols'] = value
8787
end
8888

8989
def checkout_display_command?
9090
checkout_display_command.to_i > 0
9191
end
92-
92+
9393
def checkout_display_command=(value)
9494
checkout_settings['checkout_display_command'] = value
9595
end
96-
96+
9797
def checkout_display_command
9898
if checkout_overwrite?
9999
checkout_settings['checkout_display_command']
100100
else
101101
Setting.send("checkout_display_command_#{type}")
102102
end
103103
end
104-
104+
105105
def allow_subtree_checkout?
106106
self.class.allow_subtree_checkout?
107107
end
108-
108+
109109
def checkout_default_command
110110
self.class.checkout_default_command
111111
end
@@ -128,7 +128,7 @@ def checkout_default_command
128128
CheckoutHelper.supported_scm.each do |scm|
129129
require_dependency "repository/#{scm.underscore}"
130130
cls = Repository.const_get(scm)
131-
131+
132132
allow_subtree_checkout = ""
133133
if subtree_checkout_repos.include? scm
134134
allow_subtree_checkout = <<-EOS
@@ -137,7 +137,7 @@ def allow_subtree_checkout?
137137
end
138138
EOS
139139
end
140-
140+
141141
checkout_command = ""
142142
if commands[scm]
143143
checkout_command = <<-EOS
@@ -146,7 +146,7 @@ def checkout_default_command
146146
end
147147
EOS
148148
end
149-
149+
150150
class_mod = Module.new
151151
class_mod.module_eval(<<-EOF
152152
def self.included(base)

0 commit comments

Comments
 (0)