Skip to content

Instantly share code, notes, and snippets.

@Ch4s3
Created December 4, 2019 17:23
Show Gist options
  • Select an option

  • Save Ch4s3/9078c0f6649e6913dff2a2cf78b74f72 to your computer and use it in GitHub Desktop.

Select an option

Save Ch4s3/9078c0f6649e6913dff2a2cf78b74f72 to your computer and use it in GitHub Desktop.

Revisions

  1. Ch4s3 created this gist Dec 4, 2019.
    22 changes: 22 additions & 0 deletions check_migrations.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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