Git Hooks: Fix and test binary file moves (#19)
Co-authored-by: Sebastian Parborg <sebastian@blender.org> Reviewed-on: https://projects.blender.org/infrastructure/gitea-custom/pulls/19
This commit is contained in:
45
git-hooks/test/deny_binary/51_move_legacy_file_with_binary.sh
Executable file
45
git-hooks/test/deny_binary/51_move_legacy_file_with_binary.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Test: Show rejected files correctly when moving binary files
|
||||
#
|
||||
# This test is expected to fail since the binary file is supposed
|
||||
# to be covered by Git LFS. This test verifies the reject message
|
||||
# for correctly parsing and displaying the file move.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
SCRIPT_PATH=$(dirname "$SCRIPT")
|
||||
|
||||
. ${SCRIPT_PATH}/functions
|
||||
|
||||
setup_temp_git_identity
|
||||
|
||||
ORIGIN_REPO_DIR=`setup_bare_origin_repository`
|
||||
WORK_GIT_DIR=`clone_repository "${ORIGIN_REPO_DIR}"`
|
||||
|
||||
dd if=/dev/zero of="${WORK_GIT_DIR}/data.bin" bs=1 count=32k
|
||||
git -C "${WORK_GIT_DIR}" add data.bin
|
||||
git -C "${WORK_GIT_DIR}" commit --message "Initial commit"
|
||||
if ! git -C "${WORK_GIT_DIR}" push; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_hook "${ORIGIN_REPO_DIR}" "${SCRIPT_PATH}/../../deny-binary" "pre-receive"
|
||||
|
||||
mkdir -p "${WORK_GIT_DIR}/bindata"
|
||||
git -C "${WORK_GIT_DIR}" mv data.bin bindata/data.bin
|
||||
git -C "${WORK_GIT_DIR}" commit --message "Move binary file"
|
||||
|
||||
set +e
|
||||
PUSH_OUTPUT=$(git -C "${WORK_GIT_DIR}" push 2>&1)
|
||||
PUSH_STATUS=$?
|
||||
set -e
|
||||
|
||||
if [ "${PUSH_STATUS}" -eq 0 ] || echo "${PUSH_OUTPUT}" | grep -q "fatal:"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Test passed!"
|
||||
exit 0
|
||||
@@ -8,3 +8,4 @@ SCRIPT_PATH=$(dirname "$SCRIPT")
|
||||
. "${SCRIPT_PATH}/common/functions"
|
||||
|
||||
run_tests_in_directory "${SCRIPT_PATH}/deny_binary"
|
||||
rm -rf "${SCRIPT_PATH}/deny_binary/tmp"
|
||||
Reference in New Issue
Block a user