Replace utils/gitexec with utils/git/run
This commit is contained in:
parent
ec0fa2f93e
commit
c2a3578a55
11 changed files with 50 additions and 94 deletions
|
@ -5,17 +5,13 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/portzap
|
libexec="${localbase}"/libexec/portzap
|
||||||
|
git="${libexec}"/utils/git/run
|
||||||
giturl=$1
|
giturl=$1
|
||||||
gitdir=$2
|
gitdir=$2
|
||||||
branch=$3
|
branch=$3
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
git()
|
|
||||||
{
|
|
||||||
"${libexec}"/utils/gitexec "${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
printok() {
|
printok() {
|
||||||
"${libexec}"/utils/printok "${1}"
|
"${libexec}"/utils/printok "${1}"
|
||||||
}
|
}
|
||||||
|
@ -41,8 +37,8 @@ if [ -e "${gitdir}/.git" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git clone "${giturl}" "${gitdir}"
|
"${git}" clone "${giturl}" "${gitdir}"
|
||||||
cd "${gitdir}"
|
cd "${gitdir}"
|
||||||
git config core.filemode off
|
"${git}" config core.filemode off
|
||||||
git checkout -t origin/"${branch}"
|
"${git}" checkout -t origin/"${branch}"
|
||||||
printok "clone complete"
|
printok "clone complete"
|
||||||
|
|
|
@ -6,6 +6,7 @@ set -e
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/portzap
|
libexec="${localbase}"/libexec/portzap
|
||||||
mode=u=rwX,g=rX,o=
|
mode=u=rwX,g=rX,o=
|
||||||
|
git="${libexec}"/utils/git/run
|
||||||
gitdir=$1
|
gitdir=$1
|
||||||
installdir=$2
|
installdir=$2
|
||||||
revfile=$3
|
revfile=$3
|
||||||
|
@ -15,8 +16,8 @@ revfile=$3
|
||||||
perform_update()
|
perform_update()
|
||||||
{
|
{
|
||||||
rev=$(cat "${revfile}")
|
rev=$(cat "${revfile}")
|
||||||
add=$("${libexec}"/utils/git-changed-files "${gitdir}" "${rev}")
|
add=$("${libexec}"/utils/git/get-changed-files "${gitdir}" "${rev}")
|
||||||
del=$("${libexec}"/utils/git-removed-files "${gitdir}" "${rev}")
|
del=$("${libexec}"/utils/git/get-removed-files "${gitdir}" "${rev}")
|
||||||
for file in ${del}; do
|
for file in ${del}; do
|
||||||
target="${installdir}/${file}"
|
target="${installdir}/${file}"
|
||||||
parent=$(dirname "${target}")
|
parent=$(dirname "${target}")
|
||||||
|
@ -72,7 +73,7 @@ if [ "$(id -u)" != "0" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umask ${mode}
|
umask "${mode}"
|
||||||
cd "${gitdir}"
|
cd "${gitdir}"
|
||||||
run_install "-d" "${installdir}"
|
run_install "-d" "${installdir}"
|
||||||
chmod ${mode} "${installdir}"
|
chmod ${mode} "${installdir}"
|
||||||
|
@ -81,5 +82,5 @@ if [ -e "${revfile}" ]; then
|
||||||
else
|
else
|
||||||
perform_install
|
perform_install
|
||||||
fi
|
fi
|
||||||
"${libexec}"/utils/git-rev "${gitdir}" > "${revfile}"
|
"${git}" rev-parse HEAD > "${revfile}"
|
||||||
printok "install complete"
|
printok "install complete"
|
||||||
|
|
|
@ -5,15 +5,11 @@ set -e
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/portzap
|
libexec="${localbase}"/libexec/portzap
|
||||||
|
git="${libexec}"/utils/git/run
|
||||||
gitdir=$1
|
gitdir=$1
|
||||||
|
|
||||||
##
|
##
|
||||||
# functions
|
# functions
|
||||||
git()
|
|
||||||
{
|
|
||||||
"${libexec}"/utils/git "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
printok() {
|
printok() {
|
||||||
"${libexec}"/utils/printok "${1}"
|
"${libexec}"/utils/printok "${1}"
|
||||||
}
|
}
|
||||||
|
@ -40,6 +36,6 @@ if [ ! -e "${gitdir}/.git" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "${gitdir}"
|
cd "${gitdir}"
|
||||||
branch=$(gitexec "branch --show-current")
|
branch=$("${git}" branch --show-current)
|
||||||
gitexec "pull --rebase origin ${branch}"
|
"${git}" pull --rebase origin "${branch}"
|
||||||
printok "pull complete"
|
printok "pull complete"
|
||||||
|
|
|
@ -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"
|
|
|
@ -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"
|
|
|
@ -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"
|
|
16
libexec/portzap/utils/git/get-changed-files
Normal file
16
libexec/portzap/utils/git/get-changed-files
Normal 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"
|
15
libexec/portzap/utils/git/get-removed-files
Normal file
15
libexec/portzap/utils/git/get-removed-files
Normal 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"
|
|
@ -10,4 +10,4 @@ mode=u=rwX,g=rX,o=
|
||||||
# main
|
# main
|
||||||
doas -n \
|
doas -n \
|
||||||
-u _portzap \
|
-u _portzap \
|
||||||
/bin/sh -c "umask ${mode}; ${git} ${1}"
|
/bin/sh -c "umask ${mode}; ${git} ${*}"
|
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
##
|
|
||||||
# variables
|
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
|
||||||
libexec="${localbase}"/libexec/portzap
|
|
||||||
|
|
||||||
##
|
|
||||||
# main
|
|
||||||
"${libexec}"/utils/gitexec diff -l0 ${@}
|
|
|
@ -1,4 +1,10 @@
|
||||||
v?.?.?
|
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"
|
| Remove "set -x"
|
||||||
After this change, portzap emits less output
|
After this change, portzap emits less output
|
||||||
|
|
Loading…
Reference in a new issue