forked from kiss-community/kiss
kiss: git caching
This commit is contained in:
parent
b14526b9bf
commit
755838425f
42
kiss
42
kiss
@ -358,6 +358,8 @@ pkg_source_resolve() {
|
||||
# Git repository.
|
||||
if null "${2##git+*}"; then
|
||||
_res=$2
|
||||
_des=$src_dir/$1/${3:+"$3/"}${2##*/}
|
||||
_des=${_des%[@#]*}
|
||||
|
||||
# Remote source (cached).
|
||||
elif [ -f "$src_dir/$1/${3:+"$3/"}${2##*/}" ]; then
|
||||
@ -410,12 +412,16 @@ pkg_source() {
|
||||
# arg4: resolved source
|
||||
run_hook pre-source "$1" "$src" "$_fnr"
|
||||
|
||||
case $_res in url+*)
|
||||
# Create directory structure in source cache. This prevents cache
|
||||
# conflicts between identical sources with differing dests.
|
||||
mkcd "${_des%/*}"
|
||||
case $_res in
|
||||
url+*)
|
||||
mkcd "${_des%/*}"
|
||||
pkg_source_get "$_des" "${_res##url+}"
|
||||
;;
|
||||
|
||||
pkg_source_get "$_des" "${_res##url+}"
|
||||
git+*)
|
||||
mkcd "$_des"
|
||||
pkg_source_git "${_res##git+}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# arg1: post-source
|
||||
@ -443,19 +449,21 @@ pkg_source_get() {
|
||||
}
|
||||
|
||||
pkg_source_git() {
|
||||
# This magic will shallow clone branches, commits or the
|
||||
# regular repository. It correctly handles cases where a
|
||||
# shallow clone is not possible.
|
||||
log "$repo_name" "Cloning $1"
|
||||
com=${1##*[@#]}
|
||||
com=${com#${1%[#@]*}}
|
||||
|
||||
# Split the source into URL + OBJECT (branch or commit).
|
||||
url=$1
|
||||
com=${url##*[@#]}
|
||||
com=${com#${url%[#@]*}}
|
||||
log "$repo_name" "Checking out ${com:-FETCH_HEAD}"
|
||||
|
||||
[ -d .git ] || {
|
||||
git init
|
||||
git remote add origin "${1%[#@]*}"
|
||||
}
|
||||
|
||||
# Only fetch latest changes if not <url>[#]<sha|tag>.
|
||||
case $1 in *"#$com") ;; *)
|
||||
git fetch -t --filter=tree:0 origin "$com" || git fetch -t
|
||||
esac
|
||||
|
||||
git init
|
||||
git remote add origin "${url%[#@]*}"
|
||||
git fetch -t --filter=tree:0 origin "$com" || git fetch -t
|
||||
git -c advice.detachedHead=0 checkout "${com:-FETCH_HEAD}"
|
||||
}
|
||||
|
||||
@ -527,7 +535,7 @@ pkg_extract() {
|
||||
|
||||
case $_res in
|
||||
git+*)
|
||||
pkg_source_git "${_res##git+}"
|
||||
cp -LRf "$_des/." .
|
||||
;;
|
||||
|
||||
*.tar|*.tar.??|*.tar.???|*.tar.????|*.t?z)
|
||||
|
Loading…
Reference in New Issue
Block a user