]> git.wh0rd.org Git - home.git/commitdiff
vcs-url: add -# support
authorMike Frysinger <vapier@gentoo.org>
Sat, 13 Jan 2024 05:23:44 +0000 (00:23 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 13 Jan 2024 05:23:44 +0000 (00:23 -0500)
.bin/vcs-url

index 99c00d9a19ce622b1cf1015c236529c60ec626ec..6612a33c34a89cd8bf93319bf51648fbf9ab6d66 100755 (executable)
@@ -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