Enable tracking
This commit is contained in:
parent
e1765dcd16
commit
7117b328af
@ -5,10 +5,15 @@ set -e
|
||||
REPOSITORY=https://github.com/descartes-underwriting/devops-technical-test-data.git
|
||||
BRANCH=main
|
||||
DATA_DIR=$(pwd)/data
|
||||
# max number of commit to backup
|
||||
MAX_NUM=0
|
||||
# logs!
|
||||
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
|
||||
case ${opt} in
|
||||
r)
|
||||
@ -25,6 +30,9 @@ do
|
||||
DATA_DIR=$(pwd)/${DATA_DIR}
|
||||
fi
|
||||
;;
|
||||
i)
|
||||
IGNORE_TRACK=1
|
||||
;;
|
||||
n)
|
||||
MAX_NUM=${OPTARG}
|
||||
;;
|
||||
@ -62,8 +70,14 @@ cd ${TMPDIR}
|
||||
|
||||
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;
|
||||
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
|
||||
|
||||
@ -124,6 +138,8 @@ do
|
||||
|
||||
NUM_ADDED=$((NUM_ADDED + 1))
|
||||
|
||||
echo -n ${COMMIT_SHA} > ${DATA_DIR}/.track
|
||||
|
||||
if test ${NUM_ADDED} -eq ${MAX_NUM}
|
||||
then
|
||||
echo "Max commit to backup reached; stopping."
|
||||
|
1
tests/tests_cases/1/.track
Normal file
1
tests/tests_cases/1/.track
Normal file
@ -0,0 +1 @@
|
||||
282180fe7e5d9cbf297f2f0ef813cffe60ce2328
|
1
tests/tests_cases/10/.track
Normal file
1
tests/tests_cases/10/.track
Normal file
@ -0,0 +1 @@
|
||||
729e5d2addf0a3566e454ddccf549041f2e9ab17
|
1
tests/tests_cases/2/.track
Normal file
1
tests/tests_cases/2/.track
Normal file
@ -0,0 +1 @@
|
||||
46fe26c9dcf2354a0ed3f304ed6818de9606f7b5
|
1
tests/tests_cases/99/.track
Normal file
1
tests/tests_cases/99/.track
Normal file
@ -0,0 +1 @@
|
||||
13fe0cca86cc6b12592e794c22e26bf4f3c52f9e
|
Loading…
Reference in New Issue
Block a user