]> git.wh0rd.org - home.git/blobdiff - .bin/vcs-url
cros-board: update
[home.git] / .bin / vcs-url
index 8eaff274e119ced2dbbda9c0822b76fe4e91d1d4..6612a33c34a89cd8bf93319bf51648fbf9ab6d66 100755 (executable)
@@ -109,13 +109,13 @@ git_url() {
                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.sv.gnu.org/*|git://git.savannah.gnu.org/*|https://git.savannah.gnu.org/*)
+               repo=$(echo "${remote}" | sed -E -e 's,^(git|https)://git.(sv|savannah).gnu.org/(git/)?,,' -e 's:[.]git$::')
+               url="https://git.savannah.gnu.org/cgit/${repo}.git/commit/?h="
                ;;
        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="
+               url="https://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,')
@@ -154,7 +154,7 @@ git_url() {
                ;;
        esac
 
-       git log -n3 ${1:-HEAD} | sed "s,^commit ,${url},"
+       git log -n${num} ${1:-HEAD} | sed "s,^commit ,${url},"
 }
 
 svn_url() {
@@ -193,6 +193,8 @@ usage() {
        Usage: $0 [options] [args]
 
        Options:
+         -#       Number of commits to show (default: 3)
+         -n#      Number of commits to show
          -c       CVS URL
          -g       GIT URL (default)
          -s       SVN URL
@@ -202,9 +204,11 @@ usage() {
 }
 
 main() {
-       local vcs="auto"
+       local vcs="auto" num="3" args=()
        while [[ $# -gt 0 ]] ; do
                case $1 in
+               -n[0-9]*) num="${1:2}";;
+               -[0-9]*) num="${1:1}";;
                -c) vcs="cvs";;
                -s) vcs="svn";;
                -g) vcs="git";;
@@ -212,10 +216,11 @@ main() {
                -h) usage;;
                --) shift; break;;
                -*) usage;;
-               *)  break;;
+               *)  args+=( "$1" );;
                esac
                shift
        done
+       set -- "${args}"
 
        if [[ ${vcs} == "auto" ]] ; then
                if [[ -d CVS ]] ; then