| 1 |
#!/usr/bin/perl -w |
| 2 |
####################################################################################### |
| 3 |
# A tool for updating .dtx files with a given package date. # |
| 4 |
# Copyright (c) 2010, Deyan Ginev, released under the Gnu General Public License (GPL)# |
| 5 |
# see http://www.gnu.org/copyleft/gpl.html # |
| 6 |
# $URL: https://svn.kwarc.info/repos/stex/trunk/bin/filedate$ # |
| 7 |
####################################################################################### |
| 8 |
|
| 9 |
use strict; |
| 10 |
|
| 11 |
use Getopt::Long; |
| 12 |
use Modparse; |
| 13 |
use Pod::Usage; |
| 14 |
use Cwd qw(abs_path); |
| 15 |
|
| 16 |
my ($file) = @ARGV; |
| 17 |
my $date = `git log --format='%ai' $file`; |
| 18 |
$date = substr($date, 0, index($date, ' ')); |
| 19 |
$date =~ s/-/\//g; |
| 20 |
$file = abs_path($file); |
| 21 |
open(IN,"<$file"); |
| 22 |
my @lines = (); |
| 23 |
while (<IN>) { |
| 24 |
if ($_ =~ /\\Provides(Package|Class)/) { |
| 25 |
$_ =~ s/\[(.*?)\s/\[$date /; |
| 26 |
} |
| 27 |
push @lines, $_; |
| 28 |
} |
| 29 |
close(IN); |
| 30 |
open(OUT,">$file"); |
| 31 |
print OUT join("",@lines); |
| 32 |
close(OUT); |
| 33 |
|
| 34 |
__END__ |
| 35 |
|
| 36 |
|
| 37 |
=head1 SYNOPSIS |
| 38 |
|
| 39 |
filedate <input filename> <newdate> |
| 40 |
|
| 41 |
Purpose: |
| 42 |
Update the dates for a \ProvidePackage invocation in a given .dtx source |
| 43 |
|
| 44 |
Example: |
| 45 |
filedate omdoc.dtx |