1 #!/bin/bash
2
3 # Stackoverflow: How do I programmatically determine if there are uncommitted changes?
4 # https://stackoverflow.com/questions/3878624/how-do-i-programmatically-determine-if-there-are-uncommitted-changes
5
6 IS_CI="${CI:-false}"
7
8 if [ "$IS_CI" = true ]; then
9 git config --local url."https://github.com/".insteadOf git@github.com:
10 git config --local user.name "Medusajs Bot"
11 git config --local user.email "core@medusa-commerce.com"
12 fi
13
14 FILE_CHANGES=$(git status --porcelain=v1 | grep 'packages/generated')
15 FILE_CHANGES_COUNT=$(git status --porcelain=v1 | grep 'packages/generated' | wc -l)
16
17 if [ "$IS_CI" = true ]; then
18 git config --local --unset user.name
19 git config --local --unset user.email
20 git config --local --unset url."https://github.com/".insteadOf
21 fi
22
23 if [ "$FILE_CHANGES_COUNT" -ne 0 ]; then
24 echo "$FILE_CHANGES"
25 echo "Latest codegen build was not committed. Run 'yarn build' and commit generated files."
26 exit 1
27 else
28 echo "All has been committed."
29 exit 0
30 fi