Git subcommand for getting a repo browser link to a git object
Project description
Git link is a git sub-command for getting a repo-browser link to a git object. The motivation behind git-link is that it is often faster to navigate to a git object or path on the command line than it is to click your way to it through a web interface.
Git link can build urls for the following repo-browser: cgit, gitweb, github, github-private
Usage
$ git link -h Usage: git link [options] <commit|tree|blob|path|branch|tag|diff> Options: -h, --help show this help message and exit -v, --version show version and exit -c, --clipboard copy link to clipboard (overwrites link.clipboard) -u, --url <url> repo browser base url (overwrites link.url) -b, --browser <type> repo browser type (overwrites link.browser) -r, --raw show raw blob if possible Available repo browsers: cgit github-private github gitweb Configuration: git config --add link.url <repo browser url> git config --add link.browser <repo browser> git config --add link.clipboard false|true Examples: git link HEAD~10 -> url to 10th commit before HEAD git link v0.1.0^{tree} -> url to tree object at tag v0.1.0 git link master:file -> url to file in branch master git link path/file -> url to path/file in current branch git link devel -- path -> url to path in branch devel git link v0.1.0 -> url to tag v0.1.0
Installing
The latest stable version of git link is available on pypi, while the development version can be installed from github:
$ pip install gitlink # latest stable version $ pip install git+git://github.com/gvalkov/git-link.git # latest development version
Alternatively, you can install it manually like any other python package:
$ git clone git@github.com:gvalkov/git-link.git $ cd git-link $ git reset --hard HEAD $versiontag $ python setup.py install
Setup
Git link needs to know the name and url of the repository browser for every repository it is being run in. They can be specified either through git-config or on the command line:
$ git config --add link.url <repo browser url> $ git config --add link.browser <repo browser name> $ git config --add link.clipboard false|true # optional $ git link --browser <url> --name <name> --clipboard ...
Shell completion
Git link comes with shell completion for bash and zsh.
bash: copy git-link.sh to /etc/bash_completion.d/ (TBD)
zsh: copy git-link.zsh anywhere in $fpath
If you are installing system-wide, git link will attempt to place these files in the right locations.
Development
See repobrowsers.py and test_cgit.py if you are interested in adding a new repository browser. Running python setup.py test or py.test tests/ before committing is generally a good idea. You might also want to run tox to make sure that tests pass on all supported python versions (>=2.6).
Please make do without bringing in any external dependencies. As nice as GitPython and libgit2 are, anything that this tool needs from git can be queried using the command line tools.
License
Git link is released under the terms of the New BSD License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.