From 3cb62622b24823540f0be8edb775a8dfbd53ffbf Mon Sep 17 00:00:00 2001 From: Shahidh K Muhammed Date: Wed, 18 Jul 2018 11:16:52 +0530 Subject: [PATCH] update ciignore to take circleci compare url (#158) --- .circleci/ciignore.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.circleci/ciignore.sh b/.circleci/ciignore.sh index a09b3ba42f9..47eab8c8cf0 100755 --- a/.circleci/ciignore.sh +++ b/.circleci/ciignore.sh @@ -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