kiss: shallow branch support
This commit is contained in:
parent
d9109773d0
commit
5cfbe0277d
43
kiss
43
kiss
|
@ -187,22 +187,27 @@ pkg_sources() {
|
||||||
|
|
||||||
mkdir -p "$mak_dir/$1/$dest"
|
mkdir -p "$mak_dir/$1/$dest"
|
||||||
|
|
||||||
# Run in a subshell to keep variables local.
|
# Run in a subshell to keep the variables, path and
|
||||||
|
# argument list local to each loop iteration.
|
||||||
(
|
(
|
||||||
repo_src=${src##git+}
|
repo_src=${src##git+}
|
||||||
|
|
||||||
log "$1" "Cloning ${repo_src%#*}"
|
log "$1" "Cloning ${repo_src%[@#]*}"
|
||||||
|
|
||||||
# If a commit hash or branch was given, grab the latest
|
# Git has no option to clone a repository to a
|
||||||
# commit from all branches. This gives a speed-up when
|
# specific location so we must do it ourselves
|
||||||
# wanting to checkout a specific branch.
|
# beforehand.
|
||||||
[ "${src##*#*}" ] ||
|
cd "$mak_dir/$1/$dest" || die 2>/dev/null
|
||||||
branch=--no-single-branch
|
|
||||||
|
# If a branch was given, shallow clone it directly.
|
||||||
|
# This speeds things up as we don't have to grab
|
||||||
|
# a lot of unneeded commits.
|
||||||
|
[ "${src##*@*}" ] && set -- ||
|
||||||
|
set -- -b "${src##*@}" "${repo_src%@*}"
|
||||||
|
|
||||||
# Always do a shallow clone as we will unshallow it if
|
# Always do a shallow clone as we will unshallow it if
|
||||||
# needed later (when a commit is desired).
|
# needed later (when a commit is desired).
|
||||||
cd "$mak_dir/$1/$dest" &&
|
git clone --depth=1 "${@:-${repo_src%#*}}" .
|
||||||
git clone --depth=1 "${branch:---}" "${repo_src%#*}" .
|
|
||||||
|
|
||||||
) || die "$1" "Failed to clone $src"
|
) || die "$1" "Failed to clone $src"
|
||||||
|
|
||||||
|
@ -241,19 +246,15 @@ pkg_extract() {
|
||||||
log "Checking out ${src##*#}"
|
log "Checking out ${src##*#}"
|
||||||
|
|
||||||
(
|
(
|
||||||
set -- git -c advice.detachedHead=false checkout
|
# A commit was requested, unshallow the repository.
|
||||||
|
# This will convert it to a regular repository with
|
||||||
|
# full history.
|
||||||
|
git fetch --unshallow
|
||||||
|
|
||||||
# Try to checkout the commit or branch. If it fails,
|
# Try to checkout the repository. If we fail here,
|
||||||
# unshallow the repository as we're dealing with a
|
# the requested commit doesn't exist.
|
||||||
# specific commit.
|
git -c advice.detachedHead=false checkout "${src##*#}" ||
|
||||||
"$@" "${src##*#}" >/dev/null 2>&1 ||
|
die "Commit hash ${src##*#} doesn't exist"
|
||||||
git fetch --unshallow
|
|
||||||
|
|
||||||
# Checkout the repository a second time. If this
|
|
||||||
# fails, the desired commit or branch doesn't exist.
|
|
||||||
# This will do nothing if the above checkout succeeded.
|
|
||||||
"$@" "${src##*#}" 2>/dev/null ||
|
|
||||||
die "${src##*#} doesn't exist"
|
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue