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]);
47 if ($clean_file && ! $clean_file =~ /^$MIGBASEWORKDIR/) {
48 die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $clean_file\n";
51 if ($file =~ /^$MIGBASEWORKDIR/) {
52 skip_clean($file,$clean_file);
54 die "File falls outside of MIGWORKDIR ($MIGWORKDIR): $file\n";
59 ###############################################################################
63 my $clean_file = shift;
65 my $tracked_file_id = Mig::check_for_tracked_file($file);
66 if ($tracked_file_id) {
67 my $data = Mig::status_this_file($file);
69 if (! $data->{'utf8_filename'}) {
70 die "mig-iconv or mig-skip-iconv needed for UTF8 version of file: $file\n";
73 my $utf8_file = $data->{'utf8_filename'};
74 if (! -e $utf8_file) {
75 die "missing file: $utf8_file\n";
78 print "skipping cleaning of tracked file: $file\n";
80 my $dbh = Mig::db_connect();
82 $clean_file = $utf8_file . '.clean';
84 if (! -e $clean_file) {
85 die "clean file does not exist: $clean_file\n";
89 UPDATE $MIGSCHEMA.tracked_file
90 SET clean_filename = " . $dbh->quote($clean_file) . "
91 WHERE base_filename = " . $dbh->quote($file) . "
93 ") || die "Error inserting into table $MIGSCHEMA.tracked_file: $!\n";
94 Mig::db_disconnect($dbh);
96 die "File not currently tracked: $file\n";