More make-db-patch goodness: wrap existing
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 18 May 2011 12:21:53 +0000 (08:21 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 18 May 2011 14:19:23 +0000 (10:19 -0400)
--wrap option will take an existing file and wrap it properly.
When --wrap is specified --from is ignored.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>

Open-ILS/src/sql/Pg/make-db-patch.pl

index 663b901..505dd4a 100755 (executable)
@@ -23,6 +23,7 @@ use Getopt::Long;
 my $db_patch_num;
 my $patch_name;
 my $patch_from;
+my $patch_wrap;
 my @deprecates;
 my @supersedes;
 
@@ -31,6 +32,7 @@ GetOptions(
     'num=i' => \$db_patch_num,
     'name=s' => \$patch_name,
     'from=s' => \$patch_from,
+    'wrap=s' => \$patch_wrap,
     'deprecates=i' => \@deprecates,
     'supersedes=i' => \@supersedes,
 ) or exit_usage();
@@ -97,7 +99,8 @@ if (@deprecates or @supersedes) {
 }
 
 my $patch_init_contents;
-$patch_init_contents = `git diff $patch_from -- ./[0-9][0-9][0-9].*.sql | sed -e '/^[^+\@-]/d' -e '/^\\(--- a\\|+++ b\\)/d' -e 's/^+//'` if ($patch_from ne '');
+$patch_init_contents = `git diff $patch_from -- ./[0-9][0-9][0-9].*.sql | sed -e '/^[^+\@-]/d' -e '/^\\(--- a\\|+++ b\\)/d' -e 's/^+//'` if ($patch_from ne '' && ! defined $patch_wrap);
+$patch_init_contents = `cat $patch_wrap` if (defined $patch_wrap && $patch_wrap ne '');
 
 print OUT <<_FOOTER_;
 
@@ -126,6 +129,7 @@ Make template for a DB patch SQL file.
     --deprecates   patch(es) deprecated by this update
     --supersedes   patch(es) superseded by this update
     --from         git refspec to compare against
+    --wrap         existing file to wrap (overrides --from)
 _HELP_
     exit 0;
 }