Skip to content

Commit

Permalink
git_clone: support custom destination folder name
Browse files Browse the repository at this point in the history
Solves bug report of piKiss folder already exists
  • Loading branch information
Botspot authored Jan 2, 2024
1 parent e0aa01c commit 10dee9d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -3039,16 +3039,19 @@ Please reboot to load the new kernel, then try again."
git_clone() { #silently clone a git repository but display the output if an error occurs
# $1 is repo
local IFS=' '
local arg
local repo_name=''
for arg in "$@"; do
if [[ "$arg" == *'://'* ]];then
url="$arg"
local url="$arg"
repo_name=$(basename "$url" | sed s/.git//g)
elif [ ! -z "$repo_name" ] && [[ "$arg" != -* ]];then #repo_name already set, so this arg is after the url to specify the download folder name
repo_name="$arg"
fi
done

[ -z "$url" ] && error "git_clone(): no repository URL specified."

local repo_name=$(basename "$url" | sed s/.git//g)

local folder="$(pwd)/$repo_name"

status -n "Downloading $repo_name repository... "
Expand Down

0 comments on commit 10dee9d

Please sign in to comment.