-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item14033: accidentally deleted this file
git did, not me
- Loading branch information
1 parent
3239076
commit 82175c0
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! /usr/bin/env perl | ||
# | ||
# Use this script from the root of your foswiki "distro" clone, or an extension clone | ||
# prior to committing changes. It lists all modified .txt files, and will make the following changes | ||
# - Topic and attachment dates sete to the current timestamp | ||
# - Author set to ProjectContributor | ||
# - Version set to 1. | ||
# - Changes "auto-attached" attachments to hidden | ||
# - Removes autoattach flag | ||
# - Removes "path", "stream" and "tmpFilename" attributes | ||
# | ||
my @files = `git status -uno --porcelain`; | ||
|
||
foreach my $f (@files) { | ||
chomp $f; | ||
$f = substr( $f, 3 ); | ||
next | ||
unless $f =~ | ||
/data\/(?:System|Sandbox|TestCases|Main|_empty|_default|Trash|TWiki)\/.*?\.txt$/; | ||
print "Fixing timestamp on: $f\n"; | ||
my $date = time; | ||
open( F, "<", "$f" ) || die "Could not open $f for read"; | ||
my @lines; | ||
while ( my $l = <F> ) { | ||
chomp($l); | ||
if ( $l =~ /^%META:(TOPICINFO|FILEATTACHMENT)\{(.*)\}%$/ ) { | ||
$l =~ s/date=\"\d+\"/date="$date"/; | ||
$l =~ s/author=\"[^\"]+\"/author="ProjectContributor"/; | ||
$l =~ s/user=\"[^\"]+\"/user="ProjectContributor"/; | ||
$l =~ s/version="\d*"/version="1"/; | ||
$l =~ s/comment=\"reprev\"//; | ||
$l =~ s/reprev=\"[^\"]+\"//; | ||
$l =~ s/[\s]+/ /; | ||
$l =~ s/ attr="" autoattached="1"/ attr="h"/; | ||
$l =~ s/ autoattached="[^"]*"//; | ||
$l =~ s/ path="[^"]*"//; | ||
$l =~ s/ stream="[^"]*"//; | ||
$l =~ s/ tmpFilename="[^"]*"//; | ||
} | ||
if ( $l =~ /^%META:FILEATTACHMENT\{(.*)\}%$/ && $l !~ m/user=/ ) { | ||
$l =~ s/date=/user="ProjectContributor" date=/; | ||
} | ||
push( @lines, $l ); | ||
} | ||
close(F); | ||
open( F, ">", "$f" ) || die "Could not open $f for write"; | ||
print F join( "\n", @lines ) . "\n"; | ||
close(F); | ||
} |