diff --git a/scripts/backup.sh b/scripts/backup.sh index 24019e2..e2bcf6e 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -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" diff --git a/scripts/tests.sh b/scripts/tests.sh index 354d1df..a832b90 100644 --- a/scripts/tests.sh +++ b/scripts/tests.sh @@ -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" diff --git a/tests/tests_cases/99/1062211ce168f2baa6fa56fb9845d320f8c16e27/.gitkeep b/tests/tests_cases/99/1062211ce168f2baa6fa56fb9845d320f8c16e27/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests_cases/99/24a6034e58d7144e7242d2cec29224c0e2ae13c8/README.md b/tests/tests_cases/99/24a6034e58d7144e7242d2cec29224c0e2ae13c8/README.md new file mode 100644 index 0000000..7e0827a --- /dev/null +++ b/tests/tests_cases/99/24a6034e58d7144e7242d2cec29224c0e2ae13c8/README.md @@ -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 diff --git a/tests/tests_cases/99/3636fb4973a42a2f54bb7eb4b41026fd844eac12/README.md b/tests/tests_cases/99/3636fb4973a42a2f54bb7eb4b41026fd844eac12/README.md new file mode 100644 index 0000000..acad10a --- /dev/null +++ b/tests/tests_cases/99/3636fb4973a42a2f54bb7eb4b41026fd844eac12/README.md @@ -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 diff --git a/tests/tests_cases/99/48f0625c140673d941cde0c1110410f1176d8a1d/README.md b/tests/tests_cases/99/48f0625c140673d941cde0c1110410f1176d8a1d/README.md new file mode 100644 index 0000000..c1224ad --- /dev/null +++ b/tests/tests_cases/99/48f0625c140673d941cde0c1110410f1176d8a1d/README.md @@ -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 diff --git a/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/ANOTHER.md b/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/ANOTHER.md new file mode 100644 index 0000000..46c2666 --- /dev/null +++ b/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/ANOTHER.md @@ -0,0 +1 @@ +Tue Oct 8 07:25:44 PM CEST 2024 diff --git a/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/README.md b/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/README.md new file mode 100644 index 0000000..6726d17 --- /dev/null +++ b/tests/tests_cases/99/5b4f339d537cc4726f541fdf5298578bc9a5bf63/README.md @@ -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 diff --git a/tests/tests_cases/99/778bdc749ce9ccba0fbc4ea9ecc223944a414004/.gitkeep b/tests/tests_cases/99/778bdc749ce9ccba0fbc4ea9ecc223944a414004/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests_cases/99/b6c46e977b1d54ecdd13c76c529a01e5ddc2b782/README.md b/tests/tests_cases/99/b6c46e977b1d54ecdd13c76c529a01e5ddc2b782/README.md new file mode 100644 index 0000000..c1eaba9 --- /dev/null +++ b/tests/tests_cases/99/b6c46e977b1d54ecdd13c76c529a01e5ddc2b782/README.md @@ -0,0 +1,2 @@ +Tue Oct 8 07:24:47 PM CEST 2024 +Tue Oct 8 07:25:12 PM CEST 2024 diff --git a/tests/tests_cases/99/c0ae6c494be189fb91097066a21fe922ed0b1fef/README.md b/tests/tests_cases/99/c0ae6c494be189fb91097066a21fe922ed0b1fef/README.md new file mode 100644 index 0000000..88b2d87 --- /dev/null +++ b/tests/tests_cases/99/c0ae6c494be189fb91097066a21fe922ed0b1fef/README.md @@ -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 diff --git a/tests/tests_cases/99/e4dc801cc5fd64742bd6e099a4aab549ece26c47/README.md b/tests/tests_cases/99/e4dc801cc5fd64742bd6e099a4aab549ece26c47/README.md new file mode 100644 index 0000000..a0a0e28 --- /dev/null +++ b/tests/tests_cases/99/e4dc801cc5fd64742bd6e099a4aab549ece26c47/README.md @@ -0,0 +1 @@ +Tue Oct 8 07:24:47 PM CEST 2024