mirror of https://github.com/zulip/zulip.git
zanitizer: Support renaming files
(imported from commit 6a094177d652a267b53aa5042110b39fcbf21b42)
This commit is contained in:
parent
49cf7abaed
commit
c0bf02b4c2
|
@ -39,6 +39,7 @@ my %commit_tree = ();
|
||||||
my %scrubbed_blob = ();
|
my %scrubbed_blob = ();
|
||||||
my %scrubbed_file = ();
|
my %scrubbed_file = ();
|
||||||
my %deleted_file = ();
|
my %deleted_file = ();
|
||||||
|
my %renamed_file = ();
|
||||||
|
|
||||||
open FAST_EXPORT, '<', $fast_export_file or die "cannot open $fast_export_file: $!";
|
open FAST_EXPORT, '<', $fast_export_file or die "cannot open $fast_export_file: $!";
|
||||||
$_ = <FAST_EXPORT>;
|
$_ = <FAST_EXPORT>;
|
||||||
|
@ -115,12 +116,15 @@ while (defined $_) {
|
||||||
last;
|
last;
|
||||||
} elsif (/^D (?'file'.*)\n$/s) {
|
} elsif (/^D (?'file'.*)\n$/s) {
|
||||||
$_ = $+{file};
|
$_ = $+{file};
|
||||||
push @delete, {%+} if keep_file;
|
scrub_filename;
|
||||||
|
push @delete, {%+, file => $_} if defined $_;
|
||||||
} elsif (/^M (?'mode'\d+) (?'mark'\S+) (?'file'.*)\n$/s) {
|
} elsif (/^M (?'mode'\d+) (?'mark'\S+) (?'file'.*)\n$/s) {
|
||||||
$_ = $+{file};
|
$_ = $+{file};
|
||||||
if (keep_file) {
|
scrub_filename;
|
||||||
$scrubbed_file{$+{file}} = 1 if exists $scrubbed_blob{$+{mark}};
|
if (defined $_) {
|
||||||
push @modify, {%+};
|
$renamed_file{$+{file}} = $_ if $_ ne $+{file};
|
||||||
|
$scrubbed_file{$_} = 1 if exists $scrubbed_blob{$+{mark}};
|
||||||
|
push @modify, {%+, file => $_};
|
||||||
} else {
|
} else {
|
||||||
$deleted_file{$+{file}} = 1;
|
$deleted_file{$+{file}} = 1;
|
||||||
}
|
}
|
||||||
|
@ -168,5 +172,7 @@ close FAST_EXPORT;
|
||||||
|
|
||||||
print STDERR "Deleted files:\n";
|
print STDERR "Deleted files:\n";
|
||||||
print STDERR " $_\n" for sort keys %deleted_file;
|
print STDERR " $_\n" for sort keys %deleted_file;
|
||||||
|
print STDERR "Renamed files:\n";
|
||||||
|
print STDERR " $_ => $renamed_file{$_}\n" for sort keys %renamed_file;
|
||||||
print STDERR "Scrubbed files:\n";
|
print STDERR "Scrubbed files:\n";
|
||||||
print STDERR " $_\n" for sort keys %scrubbed_file;
|
print STDERR " $_\n" for sort keys %scrubbed_file;
|
||||||
|
|
|
@ -9,7 +9,11 @@ sub scrub_text {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub keep_file {
|
sub keep_file {
|
||||||
!m%^secret-directory/% && !m%settings\.ini$%
|
if (m%^secret-directory/% || m%settings\.ini$%) {
|
||||||
|
undef $_;
|
||||||
|
} else {
|
||||||
|
s/bruce/batman/g;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue