Skip to content

Commit

Permalink
Simplify directory filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias-luedtke committed Dec 30, 2021
1 parent e33ddb5 commit 13aa5ed
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions industrial_ci/src/workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
;;
Expand Down

0 comments on commit 13aa5ed

Please sign in to comment.