lib/autoproj/gitorious.rb in autoproj-1.12.5 vs lib/autoproj/gitorious.rb in autoproj-1.12.6
- old
+ new
@@ -23,39 +23,55 @@
options = Kernel.validate_options options,
:git_url => "git://#{base_url}",
:http_url => "https://git.#{base_url}",
:ssh_url => "git@#{base_url}:",
:fallback_to_http => true,
- :default => 'git,ssh'
+ :default => 'http,ssh',
+ :disabled_methods => []
+
+ disabled_methods = Array(options[:disabled_methods])
- gitorious_long_doc = [
- "How should I interact with #{base_url} (git, http or ssh)",
- "If you give two values, comma-separated, the first one will be",
- "used for pulling and the second one for pushing"]
-
access_methods = Hash[
'git' => 'git,ssh',
'ssh' => 'ssh,ssh',
'http' => 'http,http']
- configuration_option name, 'string',
- :default => options[:default],
- :doc => gitorious_long_doc do |value|
- if value =~ /,/
- value.split(',').each do |method|
- if !access_methods.has_key?(method)
- raise Autoproj::InputError, "#{method} is not a known access method"
- end
+ gitorious_long_doc = [
+ "How should I interact with #{base_url} (#{(access_methods.keys - disabled_methods).sort.join(", ")})",
+ "If you give two values, comma-separated, the first one will be",
+ "used for pulling and the second one for pushing"]
+
+ validator = lambda do |value|
+ if value =~ /,/
+ value.split(',').each do |method|
+ if !access_methods.has_key?(method)
+ raise Autoproj::InputError, "#{method} is not a known access method"
+ elsif disabled_methods.include?(method)
+ raise Autoproj::InputError, "#{method} is disabled on #{base_url}"
end
- elsif !access_methods.has_key?(value)
- raise Autoproj::InputError, "#{value} is not a known access method"
end
-
- value
+ elsif !access_methods.has_key?(value)
+ raise Autoproj::InputError, "#{value} is not a known access method"
+ elsif disabled_methods.include?(value)
+ raise Autoproj::InputError, "#{method} is disabled on #{base_url}"
end
- access_mode = Autoproj.user_config(name)
+ value
+ end
+
+ configuration_option name, 'string',
+ :default => options[:default],
+ :doc => gitorious_long_doc, &validator
+
+ access_mode = Autoproj.config.get(name)
+ begin
+ validator[access_mode]
+ rescue Autoproj::InputError => e
+ Autoproj.warn e.message
+ Autoproj.config.reset(name)
+ access_mode = Autoproj.config.get(name)
+ end
access_mode = access_methods[access_mode] || access_mode
pull, push = access_mode.split(',')
[[pull, "_ROOT"], [push, "_PUSH_ROOT"]].each do |method, var_suffix|
url = if method == "git" then options[:git_url]
elsif method == "http" then options[:http_url]
@@ -76,8 +92,8 @@
Hash[:type => 'git', :url => "#{pull_base_url}#{url}", :push_to => "#{push_base_url}#{url}", :retry_count => 10].merge(vcs_options)
end
end
end
-Autoproj.gitorious_server_configuration('GITORIOUS', 'gitorious.org')
+Autoproj.gitorious_server_configuration('GITORIOUS', 'gitorious.org', :default => 'http,ssh', :disabled_methods => 'git')
Autoproj.gitorious_server_configuration('GITHUB', 'github.com', :http_url => 'https://github.com', :default => 'http,ssh')