update ciignore to take circleci compare url (#158)

This commit is contained in:
Shahidh K Muhammed 2018-07-18 11:16:52 +05:30 committed by GitHub
parent 92935bed40
commit 3cb62622b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,9 +14,20 @@ if [[ ! -a "$ROOT/.ciignore" ]]; then
exit # If .ciignore doesn't exists, just quit this script
fi
changes="$(git diff-tree --no-commit-id --name-only -r origin/master..HEAD)"
# If branch is master, diff with origin/master will always be empty. Depend on
# CIRCLE_COMPARE_URL first and if its not set, check for diff with master.
if [[ ! -z "$CIRCLE_COMPARE_URL" ]]; then
# CIRCLE_COMPARE_URL is not empty, use it to get the diff
COMMIT_RANGE=$(echo $CIRCLE_COMPARE_URL | sed 's:^.*/compare/::g')
echo "Diff: $COMMIT_RANGE"
changes="$(git diff $COMMIT_RANGE --name-only)"
else
# CIRCLE_COMPARE_URL is not set, diff with origin/master
echo "Diff: origin/master..HEAD"
changes="$(git diff-tree --no-commit-id --name-only -r origin/master..HEAD)"
fi
echo "CHANGES FROM ORIGIN/MASTER:"
echo "Changes in this build:"
echo $changes
echo