Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge latest changes when asserting changes #22539

Merged
merged 10 commits into from
Mar 25, 2020
Merged
24 changes: 24 additions & 0 deletions scripts/assert-changed-files.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
#!/bin/bash

IS_CI="${CI:-false}"
GREP_PATTERN=$1

if [ "$IS_CI" = true ]; then
git config --local url."https://github.com/".insteadOf git@github.com:
git config --local user.name "GatsbyJS Bot"
git config --local user.email "core-team@gatsbyjs.com"

git fetch origin
git merge --no-edit origin/master

if [ $? -ne 0 ]; then
echo "Branch has conflicts with master, rolling back test."
git merge --abort
fi

git config --local --unset user.name
git config --local --unset user.email
git config --local --unset url."https://github.com/".insteadOf
fi

FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)"

# reset to previous state
git reset --hard HEAD@{1}

if [ "$FILES_COUNT" -eq 0 ]; then
echo "0 files matching '$GREP_PATTERN'; exiting and marking successful."
circleci step halt || exit 1
else
echo "$FILES_COUNT file(s) matching '$GREP_PATTERN'; continuing."
fi