Skip to content

Commit

Permalink
(#215) Prevent rm_non_git_files from rm'ing user's config/env-files
Browse files Browse the repository at this point in the history
This commit attempts to improve the behaviour of the rm_non_git_files
sub-command of run_example.sh . The objective of this command is to
clean-up build-outputs and other [stale] artifacts that may have been
produced by a prior execution of this script. We may be, inadvertently,
also deleting user's config-/env-files that reside in the project's
sub-tree. This commit changes the behaviour of rm_non_git_files to
now only delete the files registered in the .gitignore list.

Also, now "--dry-run rm_non_git_files" will only print an info message
without actually deleting all affected files.
  • Loading branch information
gapisback committed Nov 6, 2023
1 parent 2d3a6fe commit 4bbe585
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sample_apps/run_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function usage() {
echo " To run an individual step of the ${SampleAppName} : ./${Me} ${SampleAppName} <step name>"
echo " "
# Indentation to align with previous output lines.
echo " Cleanup stale artifacts from build area : ./${Me} rm_non_git_files"
echo " Cleanup artifacts and stale outputs from build area : ./${Me} rm_non_git_files"
echo " Show the environment used to build-and-run a program: ./${Me} ${SampleAppName} show_env"

local test_app="simple_app_under_oe"
Expand All @@ -203,7 +203,7 @@ function usage() {
echo " Setup and run the simple_app_under_oe program : ./${Me} --dry-run ${test_app}"
echo " Setup simple_app_under_oe program : ./${Me} --dry-run ${test_app} setup"
echo " Run and test the simple_app_under_oe program : ./${Me} --dry-run ${test_app} run_test"
echo " Cleanup stale artifacts from build area : ./${Me} --dry-run rm_non_git_files"
echo " Cleanup artifacts and outputs from build area : ./${Me} --dry-run rm_non_git_files"
echo " "
echo "Options meant for developer usage:"
echo " --no-cleanup : When errors occur, suppress executing cleanup.sh, which will kill active processes."
Expand Down Expand Up @@ -641,10 +641,16 @@ function run_popd() {
# Deep-clean the build-env to remove artifacts (e.g. generated files, binaries
# etc.) that may have been produced by other steps. We run this to ensure
# that this script will run successfully w/o any dependencies on executing
# some prior steps.
# some prior steps. This function will rm files that are listed in the
# .gitignore file for this project. This way we won't delete any user's
# config-/env-files saved for this project.
# ###########################################################################
function rm_non_git_files() {
run_cmd
echo "${Me}: Delete all files not tracked by git that are also ignored."
if [ $DryRun -eq 1 ]; then
return
fi
run_pushd "${CERT_PROTO}"

local MbedTLS_dir_exists=0
Expand Down Expand Up @@ -674,12 +680,6 @@ function rm_non_git_files() {
Islet_lib_exists=1
fi

echo "${Me}: Delete all files not tracked by git"

# shellcheck disable=SC2046
run_cmd rm -rf $(git ls-files . --exclude-standard --others)

echo "${Me}: Delete all files not tracked by git that are also ignored"
# shellcheck disable=SC2046
run_cmd rm -rf $(git ls-files . --exclude-standard --others --ignored)

Expand Down

0 comments on commit 4bbe585

Please sign in to comment.