From 8f51727d95a70058e1b7db06a022b6cd6b12198e Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Thu, 30 Aug 2018 08:28:15 +0200 Subject: Backport schema_changed.sh from EE which prints the diff if the schema is different --- scripts/schema_changed.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/schema_changed.sh b/scripts/schema_changed.sh index 5de2b35571d..b5e510c2367 100644 --- a/scripts/schema_changed.sh +++ b/scripts/schema_changed.sh @@ -1,9 +1,14 @@ -function schema_changed() { - if [[ ! -z `git diff --name-only -- db/schema.rb` ]]; then - echo "db/schema.rb after rake db:migrate:reset is different from one in the repository" +#!/bin/sh + +schema_changed() { + if [ ! -z "$(git diff --name-only -- db/schema.rb)" ]; then + printf "db/schema.rb after rake db:migrate:reset is different from one in the repository" + printf "The diff is as follows:\n" + diff=$(git diff -p --binary -- db/schema.rb) + printf "%s" "$diff" exit 1 else - echo "db/schema.rb after rake db:migrate:reset matches one in the repository" + printf "db/schema.rb after rake db:migrate:reset matches one in the repository" fi } -- cgit v1.2.3