kiss: Add shallow commit cloning
This commit is contained in:
parent
a39e9d2410
commit
c1bdf283f2
18
kiss
18
kiss
|
@ -250,22 +250,26 @@ pkg_extract() {
|
||||||
url=${src##git+}
|
url=${src##git+}
|
||||||
log "$1" "Cloning ${url%[@#]*}"
|
log "$1" "Cloning ${url%[@#]*}"
|
||||||
|
|
||||||
|
# Intelligently clone git repositories, pulling down as little
|
||||||
|
# as possible. All clones are done using '--depth 1'. Commit
|
||||||
|
# clones aren't supported by every remote (GitHub/GitLab support
|
||||||
|
# them) so a fallback is available.
|
||||||
case $url in
|
case $url in
|
||||||
# If a branch was given, shallow clone it directly.
|
# Branch clones.
|
||||||
# This speeds things up as we don't have to grab
|
|
||||||
# a lot of unneeded commits.
|
|
||||||
*'@'*) git clone --depth=1 -b "${src##*@}" "${url%@*}" . ;;
|
*'@'*) git clone --depth=1 -b "${src##*@}" "${url%@*}" . ;;
|
||||||
|
|
||||||
# If a commit was given, clone all branches as the
|
# Commit clones.
|
||||||
# given commit may not be in master.
|
|
||||||
*'#'*)
|
*'#'*)
|
||||||
git clone "${url%#*}" .
|
git init
|
||||||
|
git remote add origin "${url%#*}"
|
||||||
|
|
||||||
|
git fetch --depth=1 origin "${url##*#}" || git fetch
|
||||||
|
|
||||||
git checkout "${url##*#}" ||
|
git checkout "${url##*#}" ||
|
||||||
die "Commit hash ${url##*#} not found"
|
die "Commit hash ${url##*#} not found"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Simply shallow clone everything else.
|
# Regular clones.
|
||||||
*) git clone --depth=1 "$url" .
|
*) git clone --depth=1 "$url" .
|
||||||
|
|
||||||
esac || die "$1" "Failed to clone $src"
|
esac || die "$1" "Failed to clone $src"
|
||||||
|
|
Loading…
Reference in New Issue