4 # git log --name-only --date=short | gilog2mkd.pl
9 use constant MAXCOMMIT
=> 10;
10 # Length of the nit hash in characters
11 use constant GITSHALEN
=> 40;
13 my $progn = $0; # Current program name
14 my $hdr = "#Noticias:\n";
15 my $git_cr = undef; # Git commit regex, if a line matches this regex then
16 # it's the start of a commit message
17 my $i = 0; # Commit counter
20 $tmp = sprintf('^commit ([[:digit:]abcdef]{%s})$', GITSHALEN
);
25 $_ = <>; # Reads first line
27 # Iterates over commits
28 for ($i = 0; $i < MAXCOMMIT
&& !eof; $i++) {
30 hash
=> undef, # Commit hash
31 authn
=> undef, # Author name
32 authm
=> undef, # Author mail
33 date
=> undef, # Commit date
34 msg
=> undef, # Commit message
35 file
=> undef # First changed file
38 if (not scalar(($commit->{hash
}) = /$git_cr/)) {
39 die sprintf("This doesn't look like a commit message!, ".
40 "stopped at %s line %s; reading %s line %s.\n",
41 $progn, __LINE__
, $ARGV, $.);
42 } elsif (not scalar(($commit->{authn
}, $commit->{authm
})
43 = <> =~ /^Author:\s+([^<]+)<([^>]*)>$/)) {
44 die sprintf("This doesn't look like an 'Author:' line!, ".
45 "stopped at %s line %s; reading %s line %s.\n",
46 $progn, __LINE__
, $ARGV, $.);
47 } elsif (not scalar(($commit->{date
}) = <> =~ /^Date:\s+(.+)$/)) {
48 die sprintf("This doesn't look like a 'Date:' line!, ".
49 "stopped at %s line %s; reading %s line %s.\n",
50 $progn, __LINE__
, $ARGV, $.);
53 # Iterating over a single commit
58 }elsif(!$commit->{file
} && /^\w/){
64 printf(STDERR
"\$hash: $commit->{hash}\n");
65 printf(STDERR
"\$authn: $commit->{authn}\n");
66 printf(STDERR
"\$authm: $commit->{authm}\n");
67 printf(STDERR
"\$date: $commit->{date}\n");
68 printf(STDERR
"\$msg: $commit->{msg}\n");
70 printf(STDERR
"\$file: $commit->{file}\n");
73 if (not $commit->{msg
}) {
74 die sprintf("Empty commit msg!, ".
75 "stopped at %s line %s; reading %s line %s.\n",
76 $progn, __LINE__
, $ARGV, $.);
84 \t[Ir.]($commit->{file})