def expanded_url(server_name = 'origin', raw_url = nil, opts = {})
      if raw_url.nil?
        raise ArgumentError.new('Need server_name') unless server_name

        conf_key = "remote.#{server_name}.url"
        url = config[conf_key]

        raise GitHubService::NoRemoteRepository.new("There is no value set for '#{conf_key}'") if url.nil? or url.empty?
      else
        raise GitHubService::NoRemoteRepository.new("There is no value set for '#{raw_url}'") if raw_url.nil? or raw_url.empty?
        url = raw_url
      end

      if /^\S+@/ =~ url
        url.sub(/^(\S+@\S+?):(.*)$/, "ssh://\\1/\\2")
      else
        uri = URI.parse(url)
        host = uri.host
        scheme = uri.scheme

        raise URI::InvalidURIError.new("Need a scheme in URI: '#{url}'") unless scheme

        if scheme == 'file'
          url
        elsif host.nil?
          # assume that the 'scheme' is the named configuration in ~/.ssh/config
          rv = GitRemote.hostname_and_user_from_ssh_config(scheme, opts[:ssh_config_file] ||= "#{ENV['HOME']}/.ssh/config")

          raise GitHubService::NoRemoteRepository.new("Could not determine a host from #{url}") if rv.nil?

          host = rv[0]
          user = rv[1]
          url.sub(/^\S+:(\S+)$/, "ssh://#{user}@#{host}/\\1")
        else
          url
        end
      end
    end
def expanded_url(server_name = 'origin', raw_url = nil, opts = {})
      if raw_url.nil?
        raise ArgumentError.new('Need server_name') unless server_name

        conf_key = "remote.#{server_name}.url"
        url = config[conf_key]

        raise GitHubService::NoRemoteRepository.new("There is no value set for '#{conf_key}'") if url.nil? or url.empty?
      else
        raise GitHubService::NoRemoteRepository.new("There is no value set for '#{raw_url}'") if raw_url.nil? or raw_url.empty?
        url = raw_url
      end

      if /^\S+@/ =~ url
        url.sub(/^(\S+@\S+?):(.*)$/, "ssh://\\1/\\2")
      else
        uri = URI.parse(url)
        host = uri.host
        scheme = uri.scheme

        raise URI::InvalidURIError.new("Need a scheme in URI: '#{url}'") unless scheme

        if scheme == 'file'
          url
        elsif host.nil?
          # assume that the 'scheme' is the named configuration in ~/.ssh/config
          rv = GitRemote.hostname_and_user_from_ssh_config(scheme, opts[:ssh_config_file] ||= "#{ENV['HOME']}/.ssh/config")

          raise GitHubService::NoRemoteRepository.new("Could not determine a host from #{url}") if rv.nil?

          host = rv[0]
          user = rv[1]
          url.sub(/^\S+:(\S+)$/, "ssh://#{user}@#{host}/\\1")
        else
          url
        end
      end
    end
Expands the git configuration server name to a url.

 Takes into account further expanding an SSH uri that uses SSH aliasing in .ssh/config

 @param [String] server_name the git configuration server name; defaults to 'origin'

 @option opts [String] :ssh_config_file the SSH config file to use; defaults to ~/.ssh/config

 @return the fully expanded URL; never nil

 @raise [GitHubService::NoRemoteRepository] there is not a URL set for the server name
 @raise [URI::InvalidURIError] the retrieved URL does not have a schema
 @raise [GitHubService::NoRemoteRepository] if could not figure out a host for the retrieved URL
 @raise [::ArgumentError] if a server name is not provided

 @todo use the netrc gem