Replace utils/gitexec with utils/git/run

This commit is contained in:
0x1eef 2024-07-21 21:28:46 -03:00
parent ec0fa2f93e
commit c2a3578a55
11 changed files with 50 additions and 94 deletions

View file

@ -5,17 +5,13 @@ set -e
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
git="${libexec}"/utils/git/run
giturl=$1
gitdir=$2
branch=$3
##
# functions
git()
{
"${libexec}"/utils/gitexec "${1}"
}
printok() {
"${libexec}"/utils/printok "${1}"
}
@ -41,8 +37,8 @@ if [ -e "${gitdir}/.git" ]; then
exit 1
fi
git clone "${giturl}" "${gitdir}"
"${git}" clone "${giturl}" "${gitdir}"
cd "${gitdir}"
git config core.filemode off
git checkout -t origin/"${branch}"
"${git}" config core.filemode off
"${git}" checkout -t origin/"${branch}"
printok "clone complete"

View file

@ -6,6 +6,7 @@ set -e
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
mode=u=rwX,g=rX,o=
git="${libexec}"/utils/git/run
gitdir=$1
installdir=$2
revfile=$3
@ -15,8 +16,8 @@ revfile=$3
perform_update()
{
rev=$(cat "${revfile}")
add=$("${libexec}"/utils/git-changed-files "${gitdir}" "${rev}")
del=$("${libexec}"/utils/git-removed-files "${gitdir}" "${rev}")
add=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}")
del=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}")
for file in ${del}; do
target="${installdir}/${file}"
parent=$(dirname "${target}")
@ -72,7 +73,7 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
umask ${mode}
umask "${mode}"
cd "${gitdir}"
run_install "-d" "${installdir}"
chmod ${mode} "${installdir}"
@ -81,5 +82,5 @@ if [ -e "${revfile}" ]; then
else
perform_install
fi
"${libexec}"/utils/git-rev "${gitdir}" > "${revfile}"
"${git}" rev-parse HEAD > "${revfile}"
printok "install complete"

View file

@ -5,15 +5,11 @@ set -e
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
git="${libexec}"/utils/git/run
gitdir=$1
##
# functions
git()
{
"${libexec}"/utils/git "${@}"
}
printok() {
"${libexec}"/utils/printok "${1}"
}
@ -40,6 +36,6 @@ if [ ! -e "${gitdir}/.git" ]; then
fi
cd "${gitdir}"
branch=$(gitexec "branch --show-current")
gitexec "pull --rebase origin ${branch}"
branch=$("${git}" branch --show-current)
"${git}" pull --rebase origin "${branch}"
printok "pull complete"

View file

@ -1,22 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
gitdir=$1
commit=$2
##
# functions
diff()
{
"${libexec}"/utils/gitdiff ${@}
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=A" "${commit}" "HEAD"
diff "--name-only" "--diff-filter=M" "${commit}" "HEAD"

View file

@ -1,21 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
gitdir=$1
commit=$2
##
# functions
diff()
{
"${libexec}"/utils/gitdiff ${@}
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=D" "${commit}" "HEAD"

View file

@ -1,20 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
gitdir=$1
##
# functions
gitexec()
{
"${libexec}"/utils/gitexec "${1}"
}
##
# main
cd "${gitdir}"
gitexec "rev-parse HEAD"

View file

@ -0,0 +1,16 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
libexec="${localbase}"/libexec/portzap
git="${libexec}"/utils/git/run
gitdir=$1
commit=$2
##
# main
cd "${gitdir}"
"${git}" diff -l0 --name-only --diff-filter=A "${commit}" "HEAD"
"${git}" diff -l0 --name-only --diff-filter=M "${commit}" "HEAD"

View file

@ -0,0 +1,15 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../../..)}
libexec="${localbase}"/libexec/portzap
git="${libexec}"/utils/git/run
gitdir=$1
commit=$2
##
# main
cd "${gitdir}"
"${git}" diff -l0 --name-only --diff-filter=D "${commit}" "HEAD"

View file

@ -10,4 +10,4 @@ mode=u=rwX,g=rX,o=
# main
doas -n \
-u _portzap \
/bin/sh -c "umask ${mode}; ${git} ${1}"
/bin/sh -c "umask ${mode}; ${git} ${*}"

View file

@ -1,11 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/portzap
##
# main
"${libexec}"/utils/gitexec diff -l0 ${@}

View file

@ -1,4 +1,10 @@
v?.?.?
| Replace utils/gitexec with utils/git/run
After this change, we talk to git via utils/git/run
| Add utils/git
A dedicated directory for git-related scripts
| Remove "set -x"
After this change, portzap emits less output