mirror of
https://github.com/m8tin/cis.git
synced 2026-11-02 14:17:24 +01:00
fixed issue because git changed behavior of exit code: 'git push --dry-run'
This commit is contained in:
1 file changed
+10
-12
@@ -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
|
||||||
|
|||||||
Reference in new issue
Block a user