bin/git-get: automatically create prefixes

This commit is contained in:
xeruf 2022-06-27 21:50:29 +02:00
parent 7672f9630b
commit df08c84b07
1 changed files with 13 additions and 4 deletions

View File

@ -1,7 +1,16 @@
#!/bin/sh -e #!/bin/sh -ex
# Clones from resolving the arguments and switches into the new directory # Clones from resolving the arguments and switches into the new directory
# ARGS see git-repo # ARGS see git-repo, all arguments beyond the first three are forwarded to git-clone
remote=$(git-repo "$@") remote=$(git-repo "$@")
echo "Cloning $remote" echo "Cloning $remote"
git clone $remote ${@:4} --recurse-submodules case $# in
cd "$(test -n "$2" && echo "$2" || basename ${remote%.git})" (1) dir=$(basename ${remote%.git});;
(3) prefix=$(echo "$3" | sed "s|\(.\)\b.*$|\1|")
case "$2" in
("$prefix"*) ;;
(*) dir="${prefix}_$2";;
esac;;
esac
shift 3
git clone $remote "$@" $dir --recurse-submodules
cd "${dir:-${4:-$2}}"