forked from kiss-community/kiss
kiss: Further simplify git source handling
This commit is contained in:
parent
c1bdf283f2
commit
2cdc994e41
34
kiss
34
kiss
@ -247,32 +247,18 @@ pkg_extract() {
|
|||||||
case $src in \#*|'') ;;
|
case $src in \#*|'') ;;
|
||||||
# Git repository.
|
# Git repository.
|
||||||
git+*)
|
git+*)
|
||||||
url=${src##git+}
|
# Split the source into URL + OBJECT (branch or commit).
|
||||||
log "$1" "Cloning ${url%[@#]*}"
|
url=${src##git+} com=${url##*[@#]} com=${com#${url%[#@]*}}
|
||||||
|
|
||||||
# Intelligently clone git repositories, pulling down as little
|
# This magic will shallow clone branches, commits or the
|
||||||
# as possible. All clones are done using '--depth 1'. Commit
|
# regular repository. It correctly handles cases where a
|
||||||
# clones aren't supported by every remote (GitHub/GitLab support
|
# shallow clone is not possible.
|
||||||
# them) so a fallback is available.
|
log "$1" "Cloning ${url%[#@]*}"; {
|
||||||
case $url in
|
|
||||||
# Branch clones.
|
|
||||||
*'@'*) git clone --depth=1 -b "${src##*@}" "${url%@*}" . ;;
|
|
||||||
|
|
||||||
# Commit clones.
|
|
||||||
*'#'*)
|
|
||||||
git init
|
git init
|
||||||
git remote add origin "${url%#*}"
|
git remote add origin "${url%[#@]*}"
|
||||||
|
git fetch --depth=1 origin "$com" || git fetch
|
||||||
git fetch --depth=1 origin "${url##*#}" || git fetch
|
git checkout "${com:-FETCH_HEAD}"
|
||||||
|
} || die "$1" "Failed to clone $src"
|
||||||
git checkout "${url##*#}" ||
|
|
||||||
die "Commit hash ${url##*#} not found"
|
|
||||||
;;
|
|
||||||
|
|
||||||
# Regular clones.
|
|
||||||
*) git clone --depth=1 "$url" .
|
|
||||||
|
|
||||||
esac || die "$1" "Failed to clone $src"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Tarballs of any kind. This is a shell equivalent of
|
# Tarballs of any kind. This is a shell equivalent of
|
||||||
|
Loading…
Reference in New Issue
Block a user