fixed issue because git changed behavior of exit code: 'git push --dry-run'

This commit is contained in:
m8in committed 2026-10-07 23:38:59 +02:00
1 parent a9450ae8b4
commit e6cc70492b
1 file changed
+10 -12
+10 -12
View File
@@ -7,20 +7,18 @@ source /cis/core/base.module.sh
function checkPermissions() { function checkPermissions() {
local _FOLDER _RIGHTS local -r _FOLDER="${1:?"Missing first parameter FOLDER"}"
_FOLDER="${1:?"Missing first parameter FOLDER"}" local -r _RIGHTS="${2:?"Missing second parameter RIGHTS"}"
_RIGHTS="${2:?"Missing second parameter RIGHTS"}"
readonly _FOLDER _RIGHTS
[ "${_RIGHTS}" == "readonly" ] \ local -r _TESTBRANCH="write-test-branch-$(date +%s)"
&& [ -d "${_FOLDER}.git" ] \
&& ! git -C "${_FOLDER}" push --dry-run &> /dev/null \
&& return 0
[ "${_RIGHTS}" == "writable" ] \ if [ -d "${_FOLDER}.git" ] && git -C "${_FOLDER}" push origin HEAD:refs/heads/${_TESTBRANCH} &> /dev/null; then
&& [ -d "${_FOLDER}.git" ] \ # Cleanup immediately
&& git -C "${_FOLDER}" push --dry-run &> /dev/null \ git -C "${_FOLDER}" push origin :${_TESTBRANCH} &> /dev/null
&& return 0 [ "${_RIGHTS}" == "writable" ] && return 0
else
[ "${_RIGHTS}" == "readonly" ] && return 0
fi
echo "FAIL: The rights of the repository are incorrect: ("$(readlink -f ${0})")" >&2 echo "FAIL: The rights of the repository are incorrect: ("$(readlink -f ${0})")" >&2
echo " - '${_FOLDER}' is not '${_RIGHTS}'" >&2 echo " - '${_FOLDER}' is not '${_RIGHTS}'" >&2