Skip to content
Addressable::URI with additional support for Git "URIs"
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Gem Version Build Status Dependency Status Code Climate

A git remote URI parser backed by Addressable

Works with any valid Git URI as described in the git docs.

git clone accepts many different URI formats for remote repositories. Unfortunately, not all of them are actually URIs. Addressable is able to parse many of the standard URIs accepted by git, and this library extends Addressable to handle the non-standard scp-style repository locations.

Gitable provides a uniform way to parse a git repository location and determine information about the project. Gitable can determine whether or not a repository will require authentication before actually using git to clone the repository. Gitable is also very useful for determining equivalence between git remotes that are entered slightly differently (e.g. trailing slashes, uri scheme, uri format)

This is not a general substitute for Addressable, but rather a specific solution for accepting git repository addresses and confirming validity and authentication. Gitable should not be used as a general URI parser for anything other than git repository locations.

Many thanks to Bob Aman (sporkmonger) for his work on Addressable and for his feedback on this gem.


require 'gitable/uri'
uri = Gitable::URI.parse('')

uri.path   # => 'martinemde/gitable.git'
uri.user   # => 'git'   # => ''

Maintain the same url format.

uri.to_s   # => ''

Uses ssh?

uri.ssh?   # => true

SCP format?

uri.scp?   # => true

If it can't guess the name, you named your repository wrong.

uri.project_name   # => 'gitable'

Will this uri require authentication?

uri.authenticated? # => true

Will I have to interactively type something into git (a password)?

uri.interactive_authenticated? # => false

Matching public to private git uris?

uri.equivalent?('git://') # => true
uri.equivalent?('') # => true

Link to the web page for a project (github)

if uri.github?
  uri.to_web_uri # => <Addressable::URI>

Inherited from Addressable::URI

uri.kind_of?(Addressable::URI)   # => true

Teenage Mutant Ninja Urls (mutable uris like Addressable, if you want)

uri.path = 'someotheruser/gitable.git'
uri.basename = 'umm.git'
uri.to_s    # => ''


Gitable::URI.heuristic_parse can be used to accept user input.

Currently this supports the mistake of copying the url bar instead of the git uri for a few of the popular git webhosts. It also runs through Addressable's heuristic_parse so it will correct some poorly typed URIs.

uri = Gitable::URI.heuristic_parse('')
uri.to_s   # => 'git://'

heuristic_parse is currently very limited. If the url doesn't end in .git, it switches http:// to git:// and adds .git to the basename. This works fine for and but will happily screw up other URIs.


Copyright (c) 2014 Martin Emde. See LICENSE for details.

You can’t perform that action at this time.