Created
December 4, 2019 17:23
-
-
Save Ch4s3/9078c0f6649e6913dff2a2cf78b74f72 to your computer and use it in GitHub Desktop.
check_for_migrations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file_changes="$(git diff --name-only $(git merge-base master HEAD))" | |
migration_files="$(echo $file_changes | grep -c /migrations/)" | |
application_files="$(echo $file_changes | grep -c -v /migrations/ --include \*.ex --include \*.exs)" | |
echo "checking for migrations and apllication changes" | |
if (($migration_files == 0)) && (($application_files > 0)); | |
then | |
echo "Only Application Changes. OK" | |
exit 0 | |
elif (("$migration_files" > 0)) && (("$application_files" == 0)); | |
then | |
echo "Only Migrations. OK" | |
exit 0 | |
elif (("$migration_files" == 0)) && (("$application_files" == 0)) | |
then | |
echo "No new code or migrations. OK" | |
exit 0 | |
else | |
echo "PR must contain either code or migrations, but not both" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment