diff options
Diffstat (limited to 'git_deps/handler.py')
-rwxr-xr-x | git_deps/handler.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/git_deps/handler.py b/git_deps/handler.py new file mode 100755 index 0000000..2fe71ad --- /dev/null +++ b/git_deps/handler.py @@ -0,0 +1,38 @@ +#!/usr/bin/python + +from __future__ import print_function + +import os +import re +import subprocess +import sys +from urlparse import urlparse, urljoin + +def abort(msg, exitcode=1): + print(msg, file=sys.stderr) + sys.exit(exitcode) + +def usage(): + abort("usage: git-handler URL") + +def main(args): + if len(args) != 1: + usage() + + url = args[0] + + if url.scheme != 'gitfile': + abort("URL must use gitfile:// scheme") + + repo = os.path.join(url.netloc, url.path) + rev = url.fragment + os.chdir(repo) + + subprocess.Popen(['gitk', '--all', '--select-commit=%s' % rev]) + +def run(): + main(sys.argv[1:]) + + +if __name__ == "__main__": + run() |