]> git.madduck.net Git - etc/zsh.git/blob - .zsh/func/giturl

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

more flexible giturl handling
[etc/zsh.git] / .zsh / func / giturl
1 #!/bin/sh
2 #
3 # func/giturl
4 #
5 # a convenient way to display the gitweb URL of a commit-ish
6 #
7 # Copyright © 2010 martin f. krafft <madduck@madduck.net>
8 # Released under the terms of the Artistic Licence 2.0
9 #
10 # Source repository: git://git.madduck.net/etc/zsh.git
11 #
12
13 local remote; remote=$(git config --get remote.origin.url)
14
15 local part gitweb_base oldstyle
16 oldstyle=0
17 case "$remote" in
18   madduck:pub/*)
19     gitweb_base=http://git.madduck.net/v
20     part="${remote#madduck:pub/}"
21     ;;
22   debian:*|*://git.debian.org/git/*|*@git.debian.org/git/*)
23     gitweb_base=http://git.debian.org
24     part="${remote#debian:}"
25     part="${part#*://git.debian.org/git/}"
26     part="${part#*@git.debian.org/git/}"
27     oldstyle=1
28     ;;
29   *)
30     echo >&2 "E: I do not know how to translate $REMOTE into a gitweb URL."
31     return 1
32     ;;
33 esac
34
35 local hash
36 hash=$(git rev-parse HEAD)
37
38 case "$oldstyle" in
39   0) echo "$gitweb_base/$part/commitdiff/$hash";;
40   *) echo "$gitweb_base/?p=$part;a=commitdiff;h=$hash";;
41 esac