class Git::URL


@api public
@see github.com/sporkmonger/addressable Addresable::URI
@see git-scm.com/docs/git-clone#_git_urls GIT URLs
Any URL that can be passed to ‘git clone` can be parsed by this class.
Methods for parsing a Git URL

def self.clone_to(url, bare: false, mirror: false)

Returns:
  • (String) - the name of the repository directory

Parameters:
  • url (String) -- the Git URL containing the repository directory
def self.clone_to(url, bare: false, mirror: false)
  uri = parse(url)
  path_parts = uri.path.split('/')
  path_parts.pop if path_parts.last == '.git'
  directory = path_parts.last
  if bare || mirror
    directory += '.git' unless directory.end_with?('.git')
  elsif directory.end_with?('.git')
    directory = directory[0..-5]
  end
  directory
end

def self.parse(url)

Returns:
  • (Addressable::URI) - the parsed URI

Parameters:
  • url (String) -- the Git URL to parse
def self.parse(url)
  if !url.start_with?('file:') && (m = GIT_ALTERNATIVE_SSH_SYNTAX.match(url))
    GitAltURI.new(user: m[:user], host: m[:host], path: m[:path])
  else
    Addressable::URI.parse(url)
  end
end