From fd671d9c5430b03bdfa462a23bf3325053f1e4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20L=C3=BCdtke?= Date: Thu, 30 Dec 2021 12:11:15 +0100 Subject: [PATCH] Simplify directory filters --- industrial_ci/src/workspace.sh | 38 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/industrial_ci/src/workspace.sh b/industrial_ci/src/workspace.sh index 23b4e40cf..a268b3ebf 100644 --- a/industrial_ci/src/workspace.sh +++ b/industrial_ci/src/workspace.sh @@ -274,45 +274,29 @@ function ici_apply_directory_filter { local basepath=$1; shift local source=$1; shift local filter=${1-} + local path="$basepath/$source" case "$source" in "") ici_error "source is empty string" ;; - -.) - local file; file=$(basename "$basepath") - ici_log "Removing '${sourcespace:?}/$file'" - ici_guard rm -r "${sourcespace:?}/$file" - ;; -*) - local file="${source:1}" - if [ ! -e "${sourcespace:?}/$file" ]; then - file="$(basename "$basepath")/$file" - fi - ici_log "Removing '${sourcespace:?}/$file'" - ici_guard rm -r "${sourcespace:?}/$file" + ici_log "Removing '${source:1}'" + ici_guard rm -r "${sourcespace:?}/${source:1}" ;; /*) - if [ -d "$source" ]; then - ici_log "Copying '$source'" - ici_import_directory "$sourcespace" "$source" "$filter" - elif [ -f "$source" ]; then - ici_import_file "$sourcespace" "$source" - else - ici_error "'$source' cannot be found" - fi - ;; + path=$source + ;& *) - if [ -d "$basepath/$source" ]; then + if [ -d "$path" ]; then ici_log "Copying '$source'" - ici_import_directory "$sourcespace" "$basepath/$source" "$filter" - elif [ -f "$basepath/$source" ]; then - ici_import_file "$sourcespace" "$basepath/$source" + ici_import_directory "$sourcespace" "$path" "$filter" + elif [ -f "$path" ]; then + ici_import_file "$sourcespace" "$path" else ici_error "cannot read source from '$source'" fi ;; esac - } function ici_filter_directory { @@ -359,6 +343,10 @@ function ici_prepare_sourcespace { ici_log "Copying '$basepath'" ici_import_directory "$sourcespace" "$basepath" "$filter" ;; + -./*) + ici_log "Removing '${source:1}'" + ici_guard rm -r "${sourcespace:?}/$(basename "$basepath")${source:1}" + ;; *) ici_apply_directory_filter "$sourcespace" "$basepath" "$source" "$filter" ;;