forked from OSInside/kiwi-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.filter
executable file
·88 lines (76 loc) · 2.1 KB
/
.filter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl -w
#
# Convert a SUSE changelog file into descending chronological order
#
use Date::Parse;
use Time::Zone;
use strict;
my @wday = qw{Sun Mon Tue Wed Thu Fri Sat};
my @mon = qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec};
my $zone;
my $lastt;
my %logs;
my $logmsg;
while (<>) {
next if (/^--------------/);
if (/^(?:\* )?([A-Za-z]+\s+[A-Za-z]+\s+[0-9].*[0-9][0-9][0-9][0-9])(.*\@.*)$/) {
my $dt = $1;
my $who = $2;
$dt = lc($dt);
$who =~ s/^\s+//;
$who =~ s/^-\s*//;
$dt =~ /([0-9][0-9][0-9][0-9])/;
my $year = $1;
if (!defined($zone) && $dt =~ /\s([a-z]{3,4})(dst)?\s[0-9]{4}/) {
my $dst = $2;
$zone = tz_offset($1);
$zone += 3600 if defined($zone) && $dst;
}
my $tdt = str2time($dt);
$dt =~ /([0-9]+)/;
my $day = $1;
if (!$tdt) {
if ($dt =~ /([a-z]{3})\s+([a-z]{3})/) {
$tdt = str2time("$1 $2 $day $year");
}
}
if (!$tdt) {
if ($dt =~ /([a-z]{3})/) {
$tdt = str2time("$1 $day $year");
}
}
if (!$tdt) {
$tdt = str2time("$year-1-1");
}
# 12:00 if not specified
$tdt += 12 * 3600 unless $dt =~ /\d:\d/;
$tdt += ($zone || 0);
if (defined($lastt) && $logmsg) {
if (defined($logs{$lastt})) {
#warn "Double commit detected:\n" . $logs{$lastt} ."\n";
my @message = split /\n/,$logmsg;
shift @message;
shift @message;
$logmsg = join ("\n",@message);
$logs{$lastt} .= $logmsg ."\n";
#$logs{$lastt} .= "-------------------------------------------------------------------\n" . $logmsg;
} else {
$logs{$lastt} = $logmsg;
}
}
$lastt = $tdt;
$logmsg = $_;
next;
}
$logmsg .= $_;
}
if (defined($lastt) && $logmsg) {
$logs{$lastt} = $logmsg;
}
sub hashValueDescendingNum {
$b <=> $a;
}
foreach my $key (sort hashValueDescendingNum (keys(%logs))) {
print "-------------------------------------------------------------------\n";
print "$logs{$key}";
}