Add utils/git directory

Group git-related utilities under one directory.
The utils/git/run script runs git as the '_sourcezap'
user, and it is how we talk to git.
This commit is contained in:
0x1eef 2024-07-19 02:42:02 -03:00
parent d4a18461ca
commit d33cd6628f
9 changed files with 19 additions and 45 deletions

View file

@ -12,7 +12,7 @@ branch=$2
# functions
git()
{
"${libexec}"/utils/git "${@}"
"${libexec}"/utils/git/run "${@}"
}
printok()
@ -38,7 +38,7 @@ if ! "${libexec}"/utils/issourcezap-member > /dev/null 2>&1; then
fi
if [ ! -e "${gitdir}/.git" ]; then
printerr "try 'portzap clone' instead"
printerr "try 'sourcezap clone' instead"
exit 1
fi

View file

@ -13,7 +13,7 @@ branch=$3
# functions
git()
{
"${libexec}"/utils/git "${@}"
"${libexec}"/utils/git/run "${@}"
}
printok()

View file

@ -15,8 +15,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}")
@ -63,6 +63,11 @@ run_install()
install -o root -g _sourcezap -m "${mode}" -v "$@"
}
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
@ -91,5 +96,5 @@ if [ -e "${revfile}" ]; then
else
perform_install
fi
"${libexec}"/utils/git-rev "${gitdir}" > "${revfile}"
"${libexec}"/utils/git/run rev-parse HEAD > "${revfile}"
printok "install complete"

View file

@ -11,7 +11,7 @@ gitdir=$1
# functions
git()
{
"${libexec}"/utils/git "${@}"
"${libexec}"/utils/git/run "${@}"
}
printok()

View file

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

View file

@ -10,13 +10,13 @@ commit=$2
##
# functions
diff()
git()
{
"${libexec}"/utils/gitdiff ${@}
"${libexec}"/utils/git/run "${@}"
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=A" "${commit}" "HEAD"
diff "--name-only" "--diff-filter=M" "${commit}" "HEAD"
git diff -l0 --name-only --diff-filter=A "${commit}" "HEAD"
git diff -l0 --name-only --diff-filter=M "${commit}" "HEAD"

View file

@ -10,12 +10,12 @@ commit=$2
##
# functions
diff()
git()
{
"${libexec}"/utils/gitdiff ${@}
"${libexec}"/utils/git/run "${@}"
}
##
# main
cd "${gitdir}"
diff "--name-only" "--diff-filter=D" "${commit}" "HEAD"
git diff -l0 --name-only --diff-filter=D "${commit}" "HEAD"

View file

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