alfresco-ng2-components/scripts/affected-folder.sh
Maurizio Vitale f0dff4d011 Travis cache (#3972)
* Use name instead of env

* Enable cache dist

* enable only master and dev

* rename e2e lib

* add nx and smart build

* disable packaging and create demo shell stages

* use same name

* Enable affected e2e for core and process

* Enable affected libs check on all the e2e

* fix e2e condition

* Enable unit tests

* Manage case deps not present

* add name typo

* add affected folder to check e2e

* change an e2e test

* remove branch typo

* Update .travis.yml
2018-11-19 13:28:02 +00:00

50 lines
883 B
Bash
Executable File

#!/usr/bin/env bash
eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
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
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