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

View File

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