lib/autoproj/gitorious.rb in autoproj-2.0.0.b5 vs lib/autoproj/gitorious.rb in autoproj-2.0.0.b6
- old
+ new
@@ -1,105 +1,3 @@
-module Autoproj
- # Adds the relevant options to handle a gitorious server
- # What this does is ask the user how he would like to access the gitorious
- # server. Then, it sets
- #
- # #{name}_ROOT to be the base URL for pulling
- # #{name}_PUSH_ROOT to be the corresponding ssh-based URL for pushing
- #
- # For instance, with
- #
- # handle_gitorious_server "GITORIOUS", "gitorious.org"
- #
- # the URLs for the rtt repository in the orocos-toolchain gitorious project would
- # be defined in the source.yml files as
- #
- # ${GITORIOUS_ROOT}/orocos-toolchain/rtt.git
- # ${GITORIOUS_PUSH_ROOT}/orocos-toolchain/rtt.git
- #
- # Since it seems that the http method for gitorious servers is more stable, a
- # fallback importer is set up that falls back to using http for pulling as soon
- # as import failed
- def self.gitorious_server_configuration(name, base_url, options = Hash.new)
- 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 => 'http,ssh',
- :disabled_methods => [],
- config: Autoproj.config
-
- config = options.delete(:config)
- disabled_methods = Array(options[:disabled_methods])
-
- access_methods = Hash[
- 'git' => 'git,ssh',
- 'ssh' => 'ssh,ssh',
- 'http' => 'http,http']
-
- 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
- end
- elsif !access_methods.has_key?(value)
- raise Autoproj::InputError, "#{value} is not a known access method"
- elsif disabled_methods.include?(value)
- raise Autoproj::InputError, "#{value} is disabled on #{base_url}"
- end
-
- value
- end
-
- config.declare name, 'string',
- :default => options[:default],
- :doc => gitorious_long_doc, &validator
-
- access_mode = config.get(name)
- begin
- validator[access_mode]
- rescue Autoproj::InputError => e
- Autoproj.warn e.message
- config.reset(name)
- access_mode = 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]
- elsif method == "ssh" then options[:ssh_url]
- end
- config.set("#{name}#{var_suffix}", url)
- end
-
- Autoproj.add_source_handler name.downcase do |url, vcs_options|
- if url !~ /\.git$/
- url += ".git"
- end
- if url !~ /^\//
- url = "/#{url}"
- end
- pull_base_url = config.get("#{name}_ROOT")
- push_base_url = config.get("#{name}_PUSH_ROOT")
- Hash[type: 'git',
- url: "#{pull_base_url}#{url}",
- push_to: "#{push_base_url}#{url}",
- retry_count: 10,
- repository_id: "#{name.downcase}:#{url}"].merge(vcs_options)
- end
- end
-end
-
-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')
-
+Autoproj.warn "gitorious_server_configuration is deprecated, use require 'git_server_configuration' and Autoproj.git_server_configuration instead"
+Autoproj.warn "note that the method call interface has not changed, you just have to change the name(s)"
+require 'autoproj/git_server_configuration'