diff options
author | Parabola git <git@parabola.nu> | 2020-03-14 03:00:02 +0000 |
---|---|---|
committer | Parabola git <git@parabola.nu> | 2020-03-14 03:00:02 +0000 |
commit | c40b248711cc00798425a06db34ed57bc9e86d66 (patch) | |
tree | ff2ba8d12460d775725ff4b4494918a3b0d6d2b8 | |
parent | aef036a5df076d15926be9b2dfd5fac5a12293d3 (diff) |
Update from cron
-rwxr-xr-x | abslibre/blacklist.git/hooks/pre-receive | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/abslibre/blacklist.git/hooks/pre-receive b/abslibre/blacklist.git/hooks/pre-receive index 3a0376d..356f24e 100755 --- a/abslibre/blacklist.git/hooks/pre-receive +++ b/abslibre/blacklist.git/hooks/pre-receive @@ -12,6 +12,10 @@ readonly LOG_BLACKLIST_GIT_HOOK=1 readonly CLONE_DIR=/home/autobuilder/packages/blacklist-validate-git-hook readonly LOG_DIR=/var/log/blacklist-validate-git-hook readonly SHA_REGEX='^([0-9a-f]{40})$' +readonly VALIDATION_SCRIPT=check.sh +readonly PERMS_ERR_MSG="could not create checkout directory: ${CLONE_DIR}" +readonly CHECKOUT_ERR_MSG="working tree does not appear to be the blacklist.git repo" +readonly FAIL_MSG="validation failed for ref: %s - did you run ${VALIDATION_SCRIPT}?" ## logging ## @@ -62,9 +66,8 @@ LogParseRefData "${ref_data}" ${prev_sha} ${curr_sha} ${ref_file} ${repo} ${ref} (( ! ${is_deletion} )) || return 0 - [[ -f ${CLONE_DIR}/blacklist.txt ]] && \ - [[ -f ${CLONE_DIR}/check.sh ]] || return 1 - + ! mkdir -p "${CLONE_DIR}" && echo "${PERMS_ERR_MSG}" && return 1 + cd ${CLONE_DIR} # local tmp_dir=$(mktemp --directory --tmpdir=/tmp blacklist-validate-git-hook-XXXXXXXXXX) #pwd @@ -73,22 +76,21 @@ LogParseRefData "${ref_data}" ${prev_sha} ${curr_sha} ${ref_file} ${repo} ${ref} ( GIT_WORK_TREE=${CLONE_DIR}/ GIT_DIR=${CLONE_DIR}/.git -git log -1 --oneline -git log -1 --oneline $prev_sha -git log -1 --oneline $curr_sha -#GIT_WORK_TREE=${CLONE_DIR}/ GIT_DIR=${CLONE_DIR}/.git git fetch local-git-home - git fetch local-git-home git checkout ${curr_sha} . ) + ! [[ -f ${CLONE_DIR}/blacklist.txt ]] && \ + ! [[ -x ${CLONE_DIR}/${VALIDATION_SCRIPT} ]] && echo "${CHECKOUT_ERR_MSG}" && return 1 + + ! ./check.sh && echo "${FAIL_MSG}${ref}" && return 1 -echo "prev_sha=$prev_sha curr_sha=$curr_sha" +#echo "prev_sha=$prev_sha curr_sha=$curr_sha" #ls #git branch #pwd ; ls -al # rm -rf ${tmp_dir} -echo "ok tmp_dir=$tmp_dir" +echo "ok?=$? tmp_dir=$tmp_dir" } |