Skip to content
Snippets Groups Projects
Commit e7fa813a authored by Jorge Moratinos's avatar Jorge Moratinos
Browse files

Merge branch 'OCF18-clean-script-to-remove-temporal-files-git-ignored-files' into 'staging'

Ocf18 clean script to remove temporal files git ignored files

See merge request !12
parents 42146d38 1dba8224
No related branches found
No related tags found
2 merge requests!43Staging to Main for Release 1,!12Ocf18 clean script to remove temporal files git ignored files
Pipeline #5146 failed
...@@ -29,6 +29,7 @@ monitoring/tempo/tempo-data/* ...@@ -29,6 +29,7 @@ monitoring/tempo/tempo-data/*
docs/testing_with_postman/*node_modules* docs/testing_with_postman/*node_modules*
docs/testing_with_postman/Responses
docs/testing_with_postman/package-lock.json docs/testing_with_postman/package-lock.json
results results
......
#!/bin/bash
help() {
echo "Usage: $1 <options>"
echo " -c : Clean capif services tmp files"
echo " -m : Clean monitoring service tmp files"
echo " -t : Clean robot-test service tmp files"
echo " -d : Clean docs folder tmp files"
echo " -a : Clean all tmp files"
echo " -h : show this help"
exit 1
}
if [[ $# -lt 1 ]]
then
echo "You must specify an option before run script."
help
fi
FILES=()
echo "${FILES[@]}"
# Read params
while getopts "cmtdah" opt; do
case $opt in
c)
echo "Remove capif services temporary files"
FILES+=("services")
;;
m)
echo "Remove monitoring service temporary files"
FILES+=("monitoring")
;;
t)
echo "Remove robot-test service temporary files"
FILES+=("tests")
;;
d)
echo "Remove docs folder temporary files"
FILES+=("docs")
;;
a)
echo "Remove all temporary files"
FILES=("services" "monitoring" "tests" "docs")
;;
h)
help
;;
\?)
echo "Not valid option: -$OPTARG" >&2
help
exit 1
;;
:)
echo "The -$OPTARG option requires an argument." >&2
help
exit 1
;;
esac
done
echo "after check"
echo "${FILES[@]}"
cd ..
for FILE in "${FILES[@]}"; do
echo "Remove temporary files for $FILE"
tmp_files=$(git ls-files . --ignored --exclude-standard --others --directory | grep $FILE)
if [[ $tmp_files ]]; then
sudo rm -r $tmp_files
status=$?
if [ $status -eq 0 ]; then
echo "*** Removed tmp files from $FILE ***"
else
echo "*** Some files from $FILE failed on removing ***"
fi
else
echo "No files found"
fi
done
echo "Remove tmp files complete."
cd ./services
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment