diff options
-rw-r--r-- | src/blogc-git-receiver/pre-receive.c | 5 | ||||
-rwxr-xr-x | tests/blogc-git-receiver/check_pre_receive.sh.in | 22 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/blogc-git-receiver/pre-receive.c b/src/blogc-git-receiver/pre-receive.c index 99e15dd..954c379 100644 --- a/src/blogc-git-receiver/pre-receive.c +++ b/src/blogc-git-receiver/pre-receive.c @@ -104,6 +104,11 @@ bgr_pre_receive_hook(int argc, char *argv[]) return 1; } char *repo_dir = dirname(real_hooks_dir); + if (0 != chdir(repo_dir)) { + fprintf(stderr, "error: failed to change to repository root\n"); + free(real_hooks_dir); + return 1; + } char *htdocs_sym = bc_strdup_printf("%s/htdocs", repo_dir); free(real_hooks_dir); if (0 != access(htdocs_sym, F_OK)) { diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in index b9aec45..d70e04a 100755 --- a/tests/blogc-git-receiver/check_pre_receive.sh.in +++ b/tests/blogc-git-receiver/check_pre_receive.sh.in @@ -151,12 +151,24 @@ HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/pre-receive 2>&1 | tee "${TEMP}/outp [[ "${DEST}" != "$(readlink htdocs)" ]] [[ ! -e "${DEST}" ]] -DEST="$(readlink htdocs)" -HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./hooks/pre-receive 2>&1 | tee "${TEMP}/output.txt" +cd .. -[[ -h htdocs ]] -[[ "$(cat htdocs/foo.txt)" == "lol" ]] -[[ "${DEST}" != "$(readlink htdocs)" ]] +DEST="$(readlink foo3.git/htdocs)" +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./foo3.git/hooks/pre-receive 2>&1 | tee "${TEMP}/output.txt" + +[[ -h foo3.git/htdocs ]] +[[ "$(cat foo3.git/htdocs/foo.txt)" == "lol" ]] +[[ "${DEST}" != "$(readlink foo3.git/htdocs)" ]] +[[ ! -e "${DEST}" ]] + +cd .. + +DEST="$(readlink repos/foo3.git/htdocs)" +HOME="${TEMP}" ${TESTS_ENVIRONMENT} ./repos/foo3.git/hooks/pre-receive 2>&1 | tee "${TEMP}/output.txt" + +[[ -h repos/foo3.git/htdocs ]] +[[ "$(cat repos/foo3.git/htdocs/foo.txt)" == "lol" ]] +[[ "${DEST}" != "$(readlink repos/foo3.git/htdocs)" ]] [[ ! -e "${DEST}" ]] rm "${TEMP}/output.txt" |