Skip to content

Commit

Permalink
Run the git hook on switch branch only (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-darbinyan authored Jan 6, 2025
1 parent f76c510 commit fe1afcb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/actual_db_schema/git_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit fe1afcb

Please sign in to comment.