use of WORKING_DIRECTORY and other global readonly variables
This commit is contained in:
parent
e355cbe4ab
commit
9ceabd922d
42
git_helpers
42
git_helpers
@ -57,21 +57,32 @@ revert_to_commit_before_pull () {
|
||||
}
|
||||
# revert_to_commit_before_pull
|
||||
|
||||
# clone the customer repository in ./UpdateController/workspace.
|
||||
# clone the customer repository in ./workspace.
|
||||
# this is done only once.
|
||||
#
|
||||
# Cloning into 'customer_281'...
|
||||
# remote: Enumerating objects: 1087, done.
|
||||
# remote: Counting objects: 100% (1087/1087), done.
|
||||
# remote: Compressing objects: 100% (946/946), done.
|
||||
# remote: Total 1087 (delta 404), reused 0 (delta 0), pack-reused 0
|
||||
# Receiving objects: 100% (1087/1087), 103.27 KiB | 873.00 KiB/s, done.
|
||||
# Resoving deltas: 100% (410/410), done.
|
||||
#
|
||||
clone_customer_repository () {
|
||||
local func="${FUNCNAME[0]}"
|
||||
if [ "$PWD" = "$working_directory" ]; then
|
||||
if ! [[ -d "./$workspace_dir" ]]; then
|
||||
{ mkdir -p ./$workspace_dir; }
|
||||
if [ "$PWD" = "$WORKING_DIRECTORY" ]; then
|
||||
if ! [[ -d "./$WORKSPACE_DIR" ]]; then
|
||||
{ mkdir -p ./$WORKSPACE_DIR; }
|
||||
fi
|
||||
# check if the directory is empty. If so, clone the
|
||||
# customer repository
|
||||
if ! find ./$workspace_dir -mindepth 1 -maxdepth 1 | read; then
|
||||
if ! find ./$WORKSPACE_DIR -mindepth 1 -maxdepth 1 | read; then
|
||||
log_debug "$func:${LINENO} cloning ${1} ..."
|
||||
if { cd "./$workspace_dir" ; }; then
|
||||
if cd "./$WORKSPACE_DIR"
|
||||
then
|
||||
$(exec_git_command git clone "$1")
|
||||
if [ $? -eq 0 ]; then
|
||||
CLONE_CUSTOMER_REPOSITORY=true
|
||||
log_debug "$func:${LINENO} cloning ${1} done"
|
||||
cd - ; return 0
|
||||
fi
|
||||
@ -80,11 +91,11 @@ clone_customer_repository () {
|
||||
else
|
||||
# the directory is not empty, so we assume the
|
||||
# customer-repository has been cloned already
|
||||
if ! [[ -d "./${workspace_dir}/$customer_id" ]]; then
|
||||
log_fatal "$func:${LINENO} "\
|
||||
"wrong repository: $(ls -d './${workspace_dir}/*')"
|
||||
if ! [[ -d "./${WORKSPACE_DIR}/$CUSTOMER_ID" ]]; then
|
||||
log_fatal "$func:${LINENO} $PWD $WORKSPACE_DIR/$CUSTOMER_ID"\
|
||||
"wrong repository: $(ls -d './${WORKSPACE_DIR}/*')"
|
||||
else
|
||||
local __m="./${workspace_dir}/$customer_id exists"
|
||||
local __m="./${WORKSPACE_DIR}/$CUSTOMER_ID exists"
|
||||
log_debug "$func:${LINENO} $__m"
|
||||
return 0
|
||||
fi
|
||||
@ -96,12 +107,10 @@ clone_customer_repository () {
|
||||
# https://git.mimbach49.de/GerhardHoffmann/customer_281.git
|
||||
|
||||
cd_customer_repository () {
|
||||
# has to be called in ./UpdateController
|
||||
local func="${FUNCNAME[0]}"
|
||||
current_dir=${PWD##*/}
|
||||
current_dir="./${current_dir:-/}"
|
||||
if [ "$current_dir" = "./UpdateController" ]; then
|
||||
repository_dir="./workspace/${customer_id}"
|
||||
# has to be called in WORKING_DIRECTORY
|
||||
if [ "$PWD" = "${WORKING_DIRECTORY}" ]; then
|
||||
repository_dir="./$WORKSPACE_DIR/$CUSTOMER_ID"
|
||||
if ! [[ -d "$repository_dir" ]]; then
|
||||
log_crit "$func:${LINENO}: $repository_dir does not exist!"
|
||||
return 1
|
||||
@ -126,7 +135,6 @@ cd_home () {
|
||||
}
|
||||
|
||||
pull_customer_repository () {
|
||||
# has to be called in ./UpdateController
|
||||
local func="${FUNCNAME[0]}"
|
||||
|
||||
if ! cd_customer_repository ; then
|
||||
@ -245,7 +253,7 @@ changed_file_names () {
|
||||
git_res=${git_res//[$'\r\n\t']/ }
|
||||
log_debug "$func:${LINENO}: git_res=$git_res"
|
||||
local file_names=""
|
||||
for f in ${known_files[@]} ; do
|
||||
for f in ${KNOWN_FILES[@]} ; do
|
||||
if grep -qE ".*\s+${f}\s+.*" <<< $git_res; then
|
||||
if ! [ -z $file_names ]; then
|
||||
file_names="$f $file_names"
|
||||
|
Loading…
Reference in New Issue
Block a user