Compare commits

...

2 commits

Author SHA1 Message Date
d5770bc731 Update sourcezap-{clone,pull}
Some checks are pending
sourcezap / shellcheck (push) Waiting to run
Reduce the visual noise generated by set -x
2024-07-19 03:08:12 -03:00
d33cd6628f 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.
2024-07-19 03:08:02 -03:00
9 changed files with 19 additions and 49 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()
@ -43,10 +43,8 @@ if [ -e "${gitdir}/.git" ]; then
exit 1
fi
set -x
git clone "${giturl}" "${gitdir}"
cd "${gitdir}"
git config core.filemode off
git checkout -t origin/"${branch}"
set +x
printok "clone complete"

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()
@ -42,9 +42,7 @@ if [ ! -e "${gitdir}/.git" ]; then
exit 1
fi
set -x
cd "${gitdir}"
branch=$(git branch --show-current)
git pull --rebase origin "${branch}"
set +x
printok "pull complete"

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 ${@}