1 #!/bin/bash
2
3 IS_CI="${CI:-false}"
4 GREP_PATTERN=$1
5
6 if [ "$IS_CI" = true ]; then
7 git config --local url."https://github.com/".insteadOf git@github.com:
8 git config --local user.name "Medusajs Bot"
9 git config --local user.email "core@medusa-commerce.com"
10
11 git fetch origin
12 git merge --no-edit origin/master
13
14 if [ $? -ne 0 ]; then
15 echo "Branch has conflicts with master, rolling back test."
16 git merge --abort
17 fi
18
19 git config --local --unset user.name
20 git config --local --unset user.email
21 git config --local --unset url."https://github.com/".insteadOf
22 fi
23
24 FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)"
25
26 if [ "$IS_CI" = true ]; then
27 # reset to previous state
28 git reset --hard $CIRCLE_SHA1
29 fi
30
31 if [ "$FILES_COUNT" -eq 0 ]; then
32 echo "0 files matching '$GREP_PATTERN'; exiting and marking successful."
33 circleci step halt || exit 1
34 else
35 echo "$FILES_COUNT file(s) matching '$GREP_PATTERN'; continuing."
36 fi