Handle multiple files
This commit is contained in:
parent
2cc5a819d7
commit
ae2579de3f
@ -69,10 +69,10 @@ do
|
||||
|
||||
# There are malformed files names that are creating complex filenames to parse.
|
||||
# Those malformed filenames are double quotes, so to remove quotes, -c core.quotepath=false
|
||||
# and -z are used. sed 's/\x0//g' is removing the null byte
|
||||
FILES=$($GIT ${GIT_OPTS[@]} show --pretty= --name-only -z ${COMMIT_SHA} | sed 's/\x0//g')
|
||||
# and -z are used. sed 's/\x0/\n/g' is replacing the null byte by a return to line
|
||||
FILES=$($GIT ${GIT_OPTS[@]} show --pretty= --name-only -z ${COMMIT_SHA} | sed 's/\x0/\n/g')
|
||||
|
||||
if test -z ${FILES}
|
||||
if test -z "${FILES}"
|
||||
then
|
||||
# merge commit, etc. There is no file here.
|
||||
echo "No file was found in commit ${COMMIT_SHA}"
|
||||
@ -92,7 +92,7 @@ do
|
||||
fi
|
||||
|
||||
# Retrieve file state (Added, Modified, Deleted)
|
||||
STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} | grep -E '^..${FILE}$' | cut -f1)
|
||||
STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} | grep -E "^..${FILE}\$" | cut -f1)
|
||||
|
||||
if test "${STATE}" != "D"
|
||||
then
|
||||
@ -119,5 +119,5 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
echo "done: ${NUM_ADDED}"
|
||||
echo "done: ${NUM_ADDED} commits"
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
run_test() {
|
||||
echo "Running backup on branch main; dest $1; num: $2..."
|
||||
/bin/bash scripts/backup.sh -b main -d $1 -n $2
|
||||
echo "Running backup on branch main; repo $1 dest $2; num: $3..."
|
||||
/bin/bash scripts/backup.sh -b main -r $1 -d $2 -n $3
|
||||
echo
|
||||
diff -r $1 tests/tests_cases/$2
|
||||
diff -r $2 tests/tests_cases/$3
|
||||
if test $? -ne 0
|
||||
then
|
||||
echo "Test fail"
|
||||
@ -19,8 +19,10 @@ TMPDIR=$(mktemp -d)
|
||||
|
||||
cd ${ROOTDIR}
|
||||
|
||||
run_test ${TMPDIR}/1 1
|
||||
run_test ${TMPDIR}/2 2
|
||||
run_test ${TMPDIR}/10 10
|
||||
run_test https://github.com/descartes-underwriting/devops-technical-test-data.git ${TMPDIR}/1 1
|
||||
run_test https://github.com/descartes-underwriting/devops-technical-test-data.git ${TMPDIR}/2 2
|
||||
run_test https://github.com/descartes-underwriting/devops-technical-test-data.git ${TMPDIR}/10 10
|
||||
|
||||
run_test https://github.com/mycroft/sample-repository.git ${TMPDIR}/test_sample 99
|
||||
|
||||
echo "All tests were OK"
|
||||
|
@ -0,0 +1,7 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
||||
Tue Oct 8 07:25:47 PM CEST 2024
|
||||
Tue Oct 8 07:26:17 PM CEST 2024
|
||||
Tue Oct 8 07:26:54 PM CEST 2024
|
||||
Tue Oct 8 07:27:21 PM CEST 2024
|
||||
Tue Oct 8 07:27:45 PM CEST 2024
|
@ -0,0 +1,5 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
||||
Tue Oct 8 07:25:47 PM CEST 2024
|
||||
Tue Oct 8 07:26:17 PM CEST 2024
|
||||
Tue Oct 8 07:26:54 PM CEST 2024
|
@ -0,0 +1,6 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
||||
Tue Oct 8 07:25:47 PM CEST 2024
|
||||
Tue Oct 8 07:26:17 PM CEST 2024
|
||||
Tue Oct 8 07:26:54 PM CEST 2024
|
||||
Tue Oct 8 07:27:21 PM CEST 2024
|
@ -0,0 +1 @@
|
||||
Tue Oct 8 07:25:44 PM CEST 2024
|
@ -0,0 +1,3 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
||||
Tue Oct 8 07:25:47 PM CEST 2024
|
@ -0,0 +1,2 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
@ -0,0 +1,4 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
||||
Tue Oct 8 07:25:12 PM CEST 2024
|
||||
Tue Oct 8 07:25:47 PM CEST 2024
|
||||
Tue Oct 8 07:26:17 PM CEST 2024
|
@ -0,0 +1 @@
|
||||
Tue Oct 8 07:24:47 PM CEST 2024
|
Loading…
Reference in New Issue
Block a user