Skip to content

Instantly share code, notes, and snippets.

@Ch4s3
Created December 4, 2019 17:23
Show Gist options
  • Save Ch4s3/9078c0f6649e6913dff2a2cf78b74f72 to your computer and use it in GitHub Desktop.
Save Ch4s3/9078c0f6649e6913dff2a2cf78b74f72 to your computer and use it in GitHub Desktop.
check_for_migrations
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