sourced log_helpers.sh

This commit is contained in:
Gerhard Hoffmann 2022-06-05 07:28:14 +02:00
parent 9ab5b23e10
commit 26b2fad1e6

View File

@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
# set -x # set -x
source ./log_helpers.sh
GIT_SSL_NO_VERIFY=true GIT_SSL_NO_VERIFY=true
commit_before_pull="" commit_before_pull=""
@ -36,6 +38,7 @@ revert_to_commit_before_pull () {
# clone the customer repository in ./UpdateController/workspace. # clone the customer repository in ./UpdateController/workspace.
# this is done only once. # this is done only once.
clone_customer_repository () { clone_customer_repository () {
local func="${FUNCNAME[0]}"
current_dir=${PWD##*/} current_dir=${PWD##*/}
current_dir="./${current_dir:-/}" current_dir="./${current_dir:-/}"
if [ "$current_dir" = "./UpdateController" ]; then if [ "$current_dir" = "./UpdateController" ]; then
@ -45,29 +48,46 @@ clone_customer_repository () {
# check if the directory is empty. If so, clone the # check if the directory is empty. If so, clone the
# customer repository # customer repository
if ! find ./workspace -mindepth 1 -maxdepth 1 | read; then if ! find ./workspace -mindepth 1 -maxdepth 1 | read; then
echo "cloning ${1} ..." log_debug "$func: cloning ${1} ..."
( cd ./workspace && git clone "$1" ; ) ( cd ./workspace && git clone "$1" ; )
if [ $? -eq 0 ]; then
log_debug "$func: cloning ${1} done"
return 0
fi
fi fi
fi fi
return 1
} }
# clone_customer_repository https://git.mimbach49.de/GerhardHoffmann/customer_281.git # clone_customer_repository https://git.mimbach49.de/GerhardHoffmann/customer_281.git
pull_customer_repository () { pull_customer_repository () {
# has to be called in ./UpdateController # has to be called in ./UpdateController
local func="${FUNCNAME[0]}"
current_dir=${PWD##*/} current_dir=${PWD##*/}
current_dir="./${current_dir:-/}" current_dir="./${current_dir:-/}"
if [ "$current_dir" = "./UpdateController" ]; then if [ "$current_dir" = "./UpdateController" ]; then
repository_dir="./workspace/$1" repository_dir="./workspace/$1"
if ! [[ -d "$repository_dir" ]]; then if ! [[ -d "$repository_dir" ]]; then
printf "%s\n" "$repository_dir does not exist!" >&2 log_crit "$func: $repository_dir does not exist!"
return 1 return 1
fi fi
if [ "$(cd $repository_dir && git pull)" = "Already up to date." ]; then message=$(cd $repository_dir && git pull)
printf "%s\n" "$repository_dir already up to date." >&2 if [ "$message" = "Already up to date." ]; then
log_warn "$func: $repository_dir already up to date."
return 1 return 1
fi fi
log_info "$func: $message"
# Updating a6dd5d7..46d6b37
while IFS= read -r $line; do
echo "$line"
# sed -E 's/(Updating\s+)([[:xdigit:]]+)(..)([[:xdigit:]]+).*?/\2 \4/'
done < <(printf "%s\n" "$message")
else else
printf "%s\n" "${FUNCNAME[0]} not called in ./UpdateController" >&2 log_crit "$func not called in ./UpdateController"
return 1 return 1
fi fi