From 27be085dfe9f2cf68280c509141c084be7d62e9b Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sat, 24 Dec 2016 19:59:11 +0100 Subject: [PATCH] Update git and svn functions --- satellites/functions/vcs/git.sh | 15 +++++++++++---- satellites/functions/vcs/svn.sh | 14 +++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/satellites/functions/vcs/git.sh b/satellites/functions/vcs/git.sh index f265d9f..9e5beb1 100644 --- a/satellites/functions/vcs/git.sh +++ b/satellites/functions/vcs/git.sh @@ -1,14 +1,21 @@ vcs_git() { - local url="$1"; shift - local branch="$1" + local branch='' - local reponame="$(basename "$url")" + local OPTIND=1 + local opt + while getopts 'b:' opt; do case "$opt" in + b) local branch="$OPTARG" ;; + esac; done + shift $((OPTIND-1)) + [ "$1" = '--' ] && shift + + local reponame="$(basename "$1")" local dir="$dir_source/$name/$reponame" mkdir -p "$dir" if [ ! -d "$dir/.git" ]; then # Clone new repo - git clone --recursive --depth=1 $([ "$branch" ] && echo "-b $branch") "$url" "$dir" + git clone --recursive --depth=1 $([ "$branch" ] && echo "-b $branch") "$1" "$dir" cd "$dir" echo "$(git rev-parse @)" > "${dir}_rev_$_satname" vcs_compile=true diff --git a/satellites/functions/vcs/svn.sh b/satellites/functions/vcs/svn.sh index 403f28b..5a5dd6b 100644 --- a/satellites/functions/vcs/svn.sh +++ b/satellites/functions/vcs/svn.sh @@ -1,9 +1,17 @@ vcs_svn() { + local revision='' + + local OPTIND=1 + local opt + while getopts 'r:' opt; do case "$opt" in + r) local revision="-r $OPTARG" ;; + esac; done + shift $((OPTIND-1)) + [ "$1" = '--' ] && shift + local reponame="$(basename "$1")" local dir="$dir_source/$name/$reponame" - [ "$2" ] && local revision="-r $2" || local revision="" - if [ ! -d "$dir" ]; then # Clone new repo svn co $revision "$1" "$dir" @@ -18,6 +26,6 @@ vcs_svn() { fi fi - [ "$2" ] || version="r$(svn info "$dir" --show-item revision | xargs)" + [ "$branch" ] || version="r$(svn info "$dir" --show-item revision | xargs)" getfile "$reponame" }