alfresco-ng2-components/scripts/affected-folder.sh
gmandakini fca9e51c16 [ADF-3401] Filter facets are not reseted when updating the search query (#4425)
* C299200 automated

* Test package version

* Save the head of development into a tmp file (this will avoid error in case of rebase meanwhile the pipeline is running)
Remove the -gnu in the wrong position

* Update test-e2e-lib.sh

* Print adf version on each step

* Print adf version on each step

* Add console log and skip install on the unit test demo shell

* Remove the print dependendy
2019-03-13 10:39:55 +00:00

55 lines
1022 B
Bash
Executable File

#!/usr/bin/env bash
eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
eval DIRECTORY="tmp"
show_help() {
echo "Usage: affected-folder.sh"
echo ""
echo "-b branch name"
echo "-folder"
}
branch_name(){
BRANCH_NAME=$1
}
folder_name(){
FOLDER_NAME=$1
}
while [[ $1 == -* ]]; do
case "$1" in
-b) branch_name $2; shift 2;;
-f) folder_name $2; shift 2;;
-*) echo "invalid option: $1" 1>&2; show_help; exit 0;;
esac
done
if [[ "$BRANCH_NAME" == "" ]]
then
echo "The branch name is mandatory"
exit 0
fi
if [[ "$FOLDER_NAME" == "" ]]
then
echo "The folder name is mandatory"
exit 0
fi
if [ ! -f ./$DIRECTORY/devhead.txt ]; then
git merge-base origin/$BRANCH_NAME HEAD > ./$DIRECTORY/devhead.txt
fi
HEAD_SHA_BRANCH="$(git merge-base origin/$BRANCH_NAME HEAD)"
#echo "Branch name $BRANCH_NAME HEAD sha " $HEAD_SHA_BRANCH
if git diff --name-only $HEAD_SHA_BRANCH HEAD | grep "^${FOLDER_NAME}" &> /dev/null
then
echo ${FOLDER_NAME}
fi