2 ###############################################################################
9 Allows you to either use an existing file named <file>.utf8.clean or a
10 named [cleaned file] as if it were the one created by mig-clean
12 Note that the clean file, however specified, should contain headers. The
13 remaining tools in the chain will expect this.
17 B<mig-skip-clean> <file> [cleaned file]
21 ###############################################################################
26 HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA
27 MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR
33 my $mig_bin = "$FindBin::Bin/";
34 use lib "$FindBin::Bin/";
37 pod2usage(-verbose => 2) if ! ($ARGV[0]||$ARGV[1]) || $ARGV[0] eq '--help';
39 Mig::die_if_no_env_migschema();
40 Mig::die_if_mig_tracking_table_does_not_exist();
42 my $file = abs_path($ARGV[0]);
45 $clean_file = abs_path($ARGV[1]);
49 if ($clean_file && ! $clean_file =~ /^$MIGBASEWORKDIR/) {
50 die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $clean_file\n";
53 if ($file =~ /^$MIGBASEWORKDIR/) {
54 skip_clean($file,$clean_file);
56 die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $file\n";
61 ###############################################################################
65 my $clean_file = shift;
67 my $tracked_file_id = Mig::check_for_tracked_file($file);
68 if ($tracked_file_id) {
69 my $data = Mig::status_this_file($file);
71 if (! $data->{'utf8_filename'}) {
72 die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n";
75 my $utf8_file = $data->{'utf8_filename'};
76 if (! -e $utf8_file) {
77 die "missing file: $utf8_file\n";
80 print "skipping cleaning of tracked file: $file\n";
82 my $dbh = Mig::db_connect();
84 $clean_file = $utf8_file . '.clean';
86 if (! -e $clean_file) {
87 die "clean file does not exist: $clean_file\n";
91 UPDATE $MIGSCHEMA.tracked_file
92 SET clean_filename = " . $dbh->quote($clean_file) . "
93 WHERE base_filename = " . $dbh->quote($file) . "
95 ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n";
96 Mig::db_disconnect($dbh);
98 die "File not currently tracked: $file\n";