A tool for parsing all sorts of Git URLs
giturl is just a pip install giturl.py
away.
You can safely do from giturl import *
. This imports the class GitURL
.
The usage of giturl is best illustrated through an example:
g = GitURL('gh:willyg302/giturl')
print g.host # prints "github.com"
print g.owner # prints "willyg302"
print g.repo # prints "giturl"
g.to_ssh() # returns '[email protected]:willyg302/giturl.git'
g.to_https() # returns 'https://github.com/willyg302/giturl'
g.to_git() # returns 'git://github.com/willyg302/giturl.git'
g.to_http() # returns None
g.to('ssh') # same as g.to_ssh()
g.is_a('github') # returns True
g.valid # returns True
giturl is capable of parsing short versions of common Git URLs:
- GitHub:
gh:owner/repo
- Bitbucket:
bb:owner/repo
- Assembla:
as:repo
- GitHub Gists:
gist:owner/repo
Call tests with python test.py
or python setup.py test
.