Enable tracking

This commit is contained in:
Patrick MARIE 2024-10-08 20:35:01 +02:00
parent e1765dcd16
commit 7117b328af
Signed by: mycroft
GPG Key ID: BB519E5CD8E7BFA7
5 changed files with 22 additions and 2 deletions

View File

@ -5,10 +5,15 @@ set -e
REPOSITORY=https://github.com/descartes-underwriting/devops-technical-test-data.git REPOSITORY=https://github.com/descartes-underwriting/devops-technical-test-data.git
BRANCH=main BRANCH=main
DATA_DIR=$(pwd)/data DATA_DIR=$(pwd)/data
# max number of commit to backup
MAX_NUM=0 MAX_NUM=0
# logs!
VERBOSE=0 VERBOSE=0
# ignore tracking. Can be useful to fill missing commits
# if 0 (and -i not used), will continue where it stopped.
IGNORE_TRACK=0
while getopts ":r:b:d:vxn:h" opt while getopts ":r:b:d:vxn:hi" opt
do do
case ${opt} in case ${opt} in
r) r)
@ -25,6 +30,9 @@ do
DATA_DIR=$(pwd)/${DATA_DIR} DATA_DIR=$(pwd)/${DATA_DIR}
fi fi
;; ;;
i)
IGNORE_TRACK=1
;;
n) n)
MAX_NUM=${OPTARG} MAX_NUM=${OPTARG}
;; ;;
@ -62,8 +70,14 @@ cd ${TMPDIR}
git clone ${REPOSITORY} && cd ./* git clone ${REPOSITORY} && cd ./*
CURRENT_COMMIT=""
if test -s ${DATA_DIR}/.track -a ${IGNORE_TRACK} -eq 0
then
CURRENT_COMMIT=$(cat ${DATA_DIR}/.track)..
fi
# List all commit sha, from older to newer; # List all commit sha, from older to newer;
COMMIT_SHAS=$($GIT ${GIT_OPTS[@]} log --reverse --pretty=format:"%H" remotes/origin/${BRANCH}) COMMIT_SHAS=$($GIT ${GIT_OPTS[@]} log --reverse --pretty=format:"%H" remotes/origin/${BRANCH} ${CURRENT_COMMIT})
NUM_ADDED=0 NUM_ADDED=0
@ -124,6 +138,8 @@ do
NUM_ADDED=$((NUM_ADDED + 1)) NUM_ADDED=$((NUM_ADDED + 1))
echo -n ${COMMIT_SHA} > ${DATA_DIR}/.track
if test ${NUM_ADDED} -eq ${MAX_NUM} if test ${NUM_ADDED} -eq ${MAX_NUM}
then then
echo "Max commit to backup reached; stopping." echo "Max commit to backup reached; stopping."

View File

@ -0,0 +1 @@
282180fe7e5d9cbf297f2f0ef813cffe60ce2328

View File

@ -0,0 +1 @@
729e5d2addf0a3566e454ddccf549041f2e9ab17

View File

@ -0,0 +1 @@
46fe26c9dcf2354a0ed3f304ed6818de9606f7b5

View File

@ -0,0 +1 @@
13fe0cca86cc6b12592e794c22e26bf4f3c52f9e