]> git.wh0rd.org - home.git/blobdiff - .bin/vcs-url
cros-setup-chroot: do not clobber default settings
[home.git] / .bin / vcs-url
index a86f8b7330bc9cab0fac9398072312e49531ec9b..f2cd3c9a3bd187eeeb8c2343cdcec7b6e8cf0fd5 100755 (executable)
@@ -83,18 +83,18 @@ git_url() {
                repo=$(echo "${remote}" | sed 's:.*git[.a-z]*.gentoo.org/::')
                url="https://gitweb.gentoo.org/${repo}/commit/?id="
                ;;
-       git@github.com/*|\
+       git@github.com[:/]*|\
        *://github.com/*)
-               repo=$(echo "${remote}" | sed -e 's,^git@github.com/,,' -e 's,^https://github.com/,,' -e 's,^git://github.com/,,' -e 's:[.]git$::')
+               repo=$(echo "${remote}" | sed -e 's,^git@github.com[:/],,' -e 's,^https://github.com/,,' -e 's,^git://github.com/,,' -e 's:[.]git$::')
                url="https://github.com/${repo}/commit/"
                ;;
-       git://git.sv.gnu.org/*)
-               repo=$(echo "${remote}" | sed -e 's,^git://git.sv.gnu.org/,,' -e 's:[.]git$::')
+       git://git.sv.gnu.org/*|git://git.savannah.gnu.org/*)
+               repo=$(echo "${remote}" | sed -r -e 's,^git://git.(sv|savannah).gnu.org/,,' -e 's:[.]git$::')
                url="http://git.savannah.gnu.org/cgit/${repo}.git/commit/?h="
                ;;
-       git://git.code.sf.net/p/*)
-               repo=$(echo "${remote}" | sed -r -e 's,git://git.code.sf.net/p/([^/]*)/.*,\1,')
-               url="http://sourceforge.net/p/${repo}/code/ci/"
+       git://git.code.sf.net/p/*|ssh://*@git.code.sf.net/p/*)
+               repo=$(echo "${remote}" | sed -r -e 's,(git://|ssh://([^@]*@)?)git.code.sf.net/p/([^/]*)/.*,\3,')
+               url="https://sourceforge.net/p/${repo}/code/ci/"
                ;;
        *://sourceware.org/*)
                repo=$(echo "${remote}" | sed -e 's,.*/,,' -e 's,[.]git$,,')
@@ -103,6 +103,14 @@ git_url() {
        *.googlesource.com/*)
                url="${remote%.git}/+/"
                ;;
+       *://git.enlightenment.org/*)
+               repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
+               url="https://git.enlightenment.org/${repo}.git/commit/?id="
+               ;;
+       *://git.qemu.org/*)
+               repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
+               url="http://git.qemu.org/?p=${repo}.git;a=commit;h="
+               ;;
        *)
                echo "Unknown remote: ${remote}"
                exit 1
@@ -157,7 +165,7 @@ usage() {
 }
 
 main() {
-       local vcs="git"
+       local vcs="auto"
        while [[ $# -gt 0 ]] ; do
                case $1 in
                -c) vcs="cvs";;
@@ -172,6 +180,16 @@ main() {
                shift
        done
 
+       if [[ ${vcs} == "auto" ]] ; then
+               if [[ -d CVS ]] ; then
+                       vcs="cvs"
+               elif svn info >&/dev/null ; then
+                       vcs="svn"
+               else
+                       vcs="git"
+               fi
+       fi
+
        case ${vcs} in
        cvs) cvs_url "$@";;
        git) git_url "$@";;