Enable pipefail, nounset; Simplify some checks

This commit is contained in:
Patrick MARIE 2024-10-08 21:18:04 +02:00
parent 8324384f88
commit 010c1f65ab
Signed by: mycroft
GPG Key ID: BB519E5CD8E7BFA7
2 changed files with 9 additions and 5 deletions

View File

@ -61,7 +61,11 @@ new commit: 46fe26c9dcf2354a0ed3f304ed6818de9606f7b5
new commit: 21e5331d1c0256701bb90cf017e519d54a88f618
new commit: 47998b5317e66b3bd456cfb07268c93e223704f2
...
done: 1342 commits
done: 4307 commits
$ ls -ld all/* | wc -l
4307
```

View File

@ -1,6 +1,8 @@
#!/bin/sh
set -e
set -o errexit
set -o nounset
set -o pipefail
REPOSITORY=https://github.com/descartes-underwriting/devops-technical-test-data.git
BRANCH=main
@ -116,9 +118,7 @@ do
fi
# Retrieve file state (Added, Modified, Deleted)
# Using basic regex as we want to avoid checking '()' or other complex regex patterns.
# This is suboptimal and error prone. But it passes the full backup :-)
STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} | grep -G "^..${FILE}\$" | cut -f1)
STATE=$(${GIT} ${GIT_OPTS[@]} show --name-status --pretty= ${COMMIT_SHA} -- "${FILE}" | cut -f1)
if test "${STATE}" != "D"
then