]> git.donarmstrong.com Git - zsh.git/blob - .zsh/func/giturl
output additional information
[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 GITWEB_BASE
14 GITWEB_BASE=http://git.madduck.net/v
15
16 local REMOTE
17 REMOTE=$(git config --get remote.origin.url)
18
19 local part
20 case "$REMOTE" in
21   madduck:pub/*)
22     part="${REMOTE#madduck:pub/}"
23     part="${part%.git}.git"
24     ;;
25   *)
26     echo >&2 "E: I do not know how to translate $REMOTE into a gitweb URL."
27     return 1
28     ;;
29 esac
30
31 echo $GITWEB_BASE/$part
32 HASH=$(git rev-parse HEAD)
33 echo $GITWEB_BASE/$part/commitdiff/$HASH
34
35 echo $GITWEB_BASE/$part/tree/HEAD
36 for i in $@; do
37   [ -f "$i" ] && echo "$GITWEB_BASE/$part/blob/HEAD:/$i"
38   [ -d "$i" ] && echo "$GITWEB_BASE/$part/tree/HEAD:/$i"
39 done