Hilko Bengen
2014-Feb-14 08:10 UTC
[Libguestfs] [PATCH] podwrapper: Recognize git-style dates in ChangeLog
---
podwrapper.pl.in | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/podwrapper.pl.in b/podwrapper.pl.in
index 9bceec3..61d5e12 100755
--- a/podwrapper.pl.in
+++ b/podwrapper.pl.in
@@ -235,9 +235,17 @@ my $date;
my $filename = "$abs_top_srcdir/ChangeLog";
if (-r $filename) {
open FILE, $filename or die "$progname: $filename: $!";
- $_ = <FILE>;
+ while (<FILE>) {
+ if (/^Date:\s+...\s+(...)\s+(\d+)\s+..:..:..\s+(\d{4})\s+.*$/) {
+ my $i = 0;
+ my %month + map { $_ => ++$i }
+ (qw< Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >);
+ $date = sprintf '%04d-%02d-%02d', $3, $month{$1}, $2;
+ last;
+ }
+ }
close FILE;
- $date = $1 if /^(\d+-\d+-\d+)\s/;
}
$filename = "$abs_top_srcdir/.git";
if (!$date && -d $filename) {
--
1.9.0.rc3
Richard W.M. Jones
2014-Feb-14 12:29 UTC
Re: [Libguestfs] [PATCH] podwrapper: Recognize git-style dates in ChangeLog
On Fri, Feb 14, 2014 at 09:10:17AM +0100, Hilko Bengen wrote:> --- > podwrapper.pl.in | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/podwrapper.pl.in b/podwrapper.pl.in > index 9bceec3..61d5e12 100755 > --- a/podwrapper.pl.in > +++ b/podwrapper.pl.in > @@ -235,9 +235,17 @@ my $date; > my $filename = "$abs_top_srcdir/ChangeLog"; > if (-r $filename) { > open FILE, $filename or die "$progname: $filename: $!"; > - $_ = <FILE>; > + while (<FILE>) { > + if (/^Date:\s+...\s+(...)\s+(\d+)\s+..:..:..\s+(\d{4})\s+.*$/) { > + my $i = 0; > + my %month > + map { $_ => ++$i } > + (qw< Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec >); > + $date = sprintf '%04d-%02d-%02d', $3, $month{$1}, $2; > + last; > + } > + } > close FILE; > - $date = $1 if /^(\d+-\d+-\d+)\s/; > } > $filename = "$abs_top_srcdir/.git"; > if (!$date && -d $filename) { > -- > 1.9.0.rc3Funnily enough I just fixed that. However your fix is more complete, so please push this one. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/