contrib/makerepo.sh: fix name for local cache of git repository

The $URL might already contain a ".git" suffix. Then $FULLNAME would
end up having two ".git" extensions. Fix that.
This commit is contained in:
Thomas Haller 2022-04-15 11:17:17 +02:00
parent 135bc5dd1f
commit 4d53df2911
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -319,16 +319,25 @@ MAKEREPO_GIT_IGNORE_LAST="makerepo.gitignore.last-$CURRENT_BRANCH"
get_local_mirror() {
local URL="$1"
local DIRNAME
local FULLNAME
if [[ -z "$URL" ]]; then
return
fi
local DIRNAME="$(echo $URL.git | sed -e 's#^.*/\([^/]\+\)$#\1#' -e 's/\(.*\)\.git$/\1/')"
local FULLNAME="$srcdir/.git/.makerepo-${DIRNAME}.git"
[[ -n "$NO_REMOTE" ]] && return
DIRNAME="${URL##*/}"
DIRNAME="${DIRNAME%.git}"
FULLNAME="$srcdir/.git/.makerepo-${DIRNAME}.git"
if [ ! -d "$FULLNAME" ] && [ -d "$FULLNAME.git" ]; then
# due to a bug, old versions of the script might have created "*.git.git/" directories.
# rename.
mv "$FULLNAME.git" "$FULLNAME"
fi
if [[ ! -d "$FULLNAME" ]]; then
if [[ -f "$FULLNAME" ]]; then
# create a file with name $FULLNAME, to suppress local mirroring