1
0

dotfiles: improve forge selection

This commit is contained in:
Konstantin Demin 2024-07-05 17:51:22 +03:00
parent 4112913166
commit 0ae83ee81b
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0
2 changed files with 29 additions and 11 deletions

View File

@ -47,25 +47,41 @@ fetch() {
return 1
}
test_forge() {
fetch "$1" "$2" || return 1
[ "$(head -n 1 "$2")" = '*' ] || return 1
return 0
}
select_forge() {
unset uri_gitignore uri_repo uri_tarball
__t=$(mktemp)
## try with git.krd.sh
while [ -z "${uri_repo}" ] ; do
t_gitignore="${uri_krdsh}/raw/branch/${git_branch}/${f_gitignore}"
if fetch "${t_gitignore}" >/dev/null ; then
test_forge "${t_gitignore}" "${__t}" || break
uri_repo="${uri_krdsh}.git"
uri_gitignore="${t_gitignore}"
uri_tarball="${uri_krdsh}/archive/${git_branch}.tar.gz"
unset t_gitignore
return
fi
break
done
## try with github.com
while [ -z "${uri_repo}" ] ; do
t_gitignore="${uri_github}/raw/${git_branch}/${f_gitignore}"
if fetch "${t_gitignore}" >/dev/null ; then
test_forge "${t_gitignore}" "${__t}" || break
uri_repo="${uri_github}.git"
uri_gitignore="${t_gitignore}"
uri_tarball="${uri_github}/archive/refs/heads/${git_branch}.tar.gz"
break
done
rm -f "${__t}" ; unset __t
unset t_gitignore
return
if [ -n "${uri_repo}" ] ; then
return 0
fi
echo 'no forge is available to fetch URLs' >&2
return 1
@ -181,7 +197,9 @@ git_config() {
git config --unset pull.ff || :
## size optimization
git config core.compression 9
git config core.looseCompression 6
git config pack.compression 9
git config pack.threads 2
## generic
git config receive.denyNonFastForwards true
}

View File

@ -1,7 +1,7 @@
#!/bin/zsh
dotfiles-update() {
"${ZSHU[d_dotfiles]}/install.sh" "$@"
"${ZSHU[d_dotfiles]}/install.sh" "$@" || return $?
}
dotfiles-git() { (
@ -49,7 +49,7 @@ z-zwc-flush() {
}
z-update() {
dotfiles-update
dotfiles-update || return $?
z-cache-flush
}