]> 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:

comment update
[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, as well as the
6 # base URL and tree. Also for each argument, the tree or blob URL is printed.
7 #
8 # Copyright © 2010 martin f. krafft <madduck@madduck.net>
9 # Released under the terms of the Artistic Licence 2.0
10 #
11 # Source repository: git://git.madduck.net/etc/zsh.git
12 #
13
14 local GITWEB_BASE
15 GITWEB_BASE=http://git.madduck.net/v
16
17 local REMOTE
18 REMOTE=$(git config --get remote.origin.url)
19
20 local part
21 case "$REMOTE" in
22   madduck:pub/*|ssh://git.madduck.net/madduck/pub/*)
23     part="${REMOTE#madduck:pub/}"
24     part="${part#ssh://git.madduck.net/madduck/pub/}"
25     part="${part%.git}.git"
26     ;;
27   *)
28     echo >&2 "E: I do not know how to translate $REMOTE into a gitweb URL."
29     return 1
30     ;;
31 esac
32
33 echo $GITWEB_BASE/$part
34 HASH=$(git rev-parse HEAD)
35 echo $GITWEB_BASE/$part/commitdiff/$HASH
36
37 echo $GITWEB_BASE/$part/tree/HEAD
38 for i in $@; do
39   [ -f "$i" ] && echo "$GITWEB_BASE/$part/blob/HEAD:/$i"
40   [ -d "$i" ] && echo "$GITWEB_BASE/$part/tree/HEAD:/$i"
41 done