[ADF-4569] Fix affected-libs.sh script (#4734)

* [ADF-4569] Fix affected-libs.sh script

* [ADF-4569] Create new script to check if branch is updated
This commit is contained in:
davidcanonieto
2019-05-17 15:03:22 +01:00
committed by Maurizio Vitale
parent 52c5ec03bc
commit 80da3e9932
4 changed files with 36 additions and 27 deletions

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
eval BRANCH_NAME="" eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
eval DIRECTORY="tmp" eval DIRECTORY="tmp"
show_help() { show_help() {
@@ -40,15 +38,5 @@ then
exit 0 exit 0
fi fi
if [ ! -f ./$DIRECTORY/devhead.txt ]; then echo ${FOLDER_NAME}
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

View File

@@ -1,8 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
eval BRANCH_NAME="" eval BRANCH_NAME=""
eval HEAD_SHA_BRANCH=""
eval SHA_2="HEAD"
eval DIRECTORY="tmp" eval DIRECTORY="tmp"
eval GNU=false eval GNU=false
@@ -43,13 +41,9 @@ then
exit 0 exit 0
fi fi
if [ ! -f ./$DIRECTORY/devhead.txt ]; then ./scripts/check-branch-updated.sh -b $BRANCH_NAME || exit 1;
git merge-base origin/$BRANCH_NAME HEAD > ./$DIRECTORY/devhead.txt
fi
HEAD_SHA_BRANCH="$(cat ./$DIRECTORY/devhead.txt)"
echo ""
echo "Branch name $BRANCH_NAME HEAD sha " $HEAD_SHA_BRANCH
# tmp folder doesn't exist. # tmp folder doesn't exist.
if [ ! -d "$DIRECTORY" ]; then if [ ! -d "$DIRECTORY" ]; then
@@ -58,10 +52,6 @@ if [ ! -d "$DIRECTORY" ]; then
mkdir $DIRECTORY; mkdir $DIRECTORY;
fi fi
if [ ! -f $DIRECTORY/deps.txt ]; then
npm run affected:libs -- $HEAD_SHA_BRANCH "HEAD" > $DIRECTORY/deps.txt || ( echo "This PR needs to be rebased"; exit 1 )
fi
cat $DIRECTORY/deps.txt cat $DIRECTORY/deps.txt
#echo "extensions" > deps.txt #echo "extensions" > deps.txt

33
scripts/check-branch-updated.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
eval BRANCH_NAME=""
branch_name(){
BRANCH_NAME=$1
}
show_help() {
echo "Usage: check-branch-updated.sh"
echo ""
echo "-b branch name"
}
while [[ $1 == -* ]]; do
case "$1" in
-b) branch_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
hash1=$(git show-ref --heads -s development)
hash2=$(git merge-base development $BRANCH_NAME)
[ "${hash1}" = "${hash2}" ] && echo "Branch up to date" || { echo "Branch needs to be rebeased"; exit 1; }
echo "Development branch HEAD sha " $hash1
echo "$BRANCH_NAME branch HEAD sha " $hash2

View File

@@ -39,8 +39,6 @@ else
gnu='' gnu=''
fi fi
git merge-base origin/$BRANCH_NAME HEAD > ./tmp/devhead.txt;
#reset the tmp folder #reset the tmp folder
affected="$(./scripts/affected-libs.sh ${gnu[@]} -b "$BRANCH_NAME")" affected="$(./scripts/affected-libs.sh ${gnu[@]} -b "$BRANCH_NAME")"
echo $affected echo $affected