]> git.wh0rd.org - home.git/blobdiff - .bin/vcs-url
vcs-url: add nongnu/kernel sites
[home.git] / .bin / vcs-url
index 8cc3680a20eed73d6bfe2f9c9a0a9f12b56ece71..94ff2a03d7245cadb1042d7df40c87b2c099e738 100755 (executable)
@@ -70,25 +70,59 @@ git_url() {
        *://buildroot.org/*|*://git.buildroot.org/*|\
        *://buildroot.net/*|*://git.buildroot.net/*)
                repo=$(echo "${remote}" | sed -e 's,^[^:]*://[^/]*/,,' -e 's:[.]git$::')
-               url="https://git.${repo,,}.org/${repo}/commit/?id="
+               url="https://git."
+               case ${repo} in
+               uclibc)    url+="uclibc.org" ;;
+               buildroot) url+="buildroot.org" ;;
+               *)         url+="busybox.net" ;;
+               esac
+               url+="/${repo}/commit/?id="
                ;;
        *://git@git.gentoo.org/*|\
        *://anongit.gentoo.org/*)
                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$::')
+               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@gitlab.com[:/]*|\
+       *://gitlab.com/*)
+               repo=$(echo "${remote}" | sed -e 's,^git@gitlab.com[:/],,' -e 's,^https://gitlab.com/,,' -e 's,^git://gitlab.com/,,' -e 's:[.]git$::')
+               url="https://gitlab.com/${repo}/commit/"
+               ;;
+       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.sv.nongnu.org/*|git://git.savannah.nongnu.org/*)
+               repo=$(echo "${remote}" | sed -r -e 's,^git://git.(sv|savannah).nongnu.org/,,' -e 's:[.]git$::')
+               url="http://git.savannah.nongnu.org/cgit/${repo}.git/commit/?h="
+               ;;
+       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$,,')
+               url="https://sourceware.org/git/?p=${repo}.git;a=commit;h="
+               ;;
+       *.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="https://git.qemu.org/?p=${repo}.git;a=commit;h="
+               ;;
+       *://git.kernel.org/*)
+               repo=$(echo "${remote}" | sed -e 's,^[^/]*//[^/]*/,,' -e 's,[.]git$,,')
+               url="https://git.kernel.org/${repo}.git/commit/?id="
                ;;
        *)
                echo "Unknown remote: ${remote}"
@@ -104,7 +138,7 @@ svn_url() {
                svn info | \
                awk '{
                        if ($1 == "URL:") {
-                               URL = "http://sources.gentoo.org/" gensub(/.*svnroot\/([^/]*).*/,"\\1","");
+                               URL = "http://sources.gentoo.org/" gensub(/.*svnroot\/([^/]*).*/, "\\1", 1);
                        } else if ($1 == "Revision:") {
                                rev = $2
                                URL = URL "?rev=" (rev + 1) "&view=rev"
@@ -144,7 +178,7 @@ usage() {
 }
 
 main() {
-       local vcs="git"
+       local vcs="auto"
        while [[ $# -gt 0 ]] ; do
                case $1 in
                -c) vcs="cvs";;
@@ -159,6 +193,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 "$@";;