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
|
||||
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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
doas -n \
|
||||
-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?.?.?
|
||||
|
||||
| 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
|
||||
|
|
Loading…
Reference in a new issue