diff --git a/lib/actual_db_schema/git_hooks.rb b/lib/actual_db_schema/git_hooks.rb index 3364b28..9f666ee 100644 --- a/lib/actual_db_schema/git_hooks.rb +++ b/lib/actual_db_schema/git_hooks.rb @@ -15,6 +15,11 @@ class GitHooks # rubocop:disable Metrics/ClassLength # ActualDbSchema post-checkout hook (ROLLBACK) # Runs db:rollback_branches on branch checkout. + # Check if this is a file checkout or creating a new branch + if [ "$3" == "0" ] || [ "$1" == "$2" ]; then + exit 0 + fi + if [ -f ./bin/rails ]; then if [ -n "$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED" ]; then GIT_HOOKS_ENABLED="$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED" @@ -34,6 +39,11 @@ class GitHooks # rubocop:disable Metrics/ClassLength # ActualDbSchema post-checkout hook (MIGRATE) # Runs db:migrate on branch checkout. + # Check if this is a file checkout or creating a new branch + if [ "$3" == "0" ] || [ "$1" == "$2" ]; then + exit 0 + fi + if [ -f ./bin/rails ]; then if [ -n "$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED" ]; then GIT_HOOKS_ENABLED="$ACTUAL_DB_SCHEMA_GIT_HOOKS_ENABLED"