4 # git log --name-only --date=short | gilog2mkd.pl
9 use constant DEBUG
=> 1;
10 use constant MAXCOMMIT
=> 10;
11 # Length of the nit hash in characters
12 use constant GITSHALEN
=> 40;
14 my $progn = $0; # Current program name
15 my $hdr = "#Noticias:\n";
16 my $git_cr = undef; # Git commit regex, if a line matches this regex then
17 # it's the start of a commit message
18 my $i = 0; # Commit counter
21 $tmp = sprintf('^commit ([[:digit:]abcdef]{%s})$', GITSHALEN
);
26 $_ = <>; # Reads first line
28 # Iterates over commits
29 for ($i = 0; $i < MAXCOMMIT
&& !eof; $i++) {
31 hash
=> undef, # Commit hash
32 authn
=> undef, # Author name
33 authm
=> undef, # Author mail
34 date
=> undef, # Commit date
35 msg
=> undef, # Commit message
36 file
=> undef # First changed file
39 if (not scalar(($commit->{hash
}) = /$git_cr/)) {
40 die sprintf("This doesn't look like a commit message!, ".
41 "stopped at %s line %s; reading %s line %s.\n",
42 $progn, __LINE__
, $ARGV, $.);
43 } elsif (not scalar(($commit->{authn
}, $commit->{authm
})
44 = <> =~ /^Author:\s+([^<]+)<([^>]*)>$/)) {
45 die sprintf("This doesn't look like an 'Author:' line!, ".
46 "stopped at %s line %s; reading %s line %s.\n",
47 $progn, __LINE__
, $ARGV, $.);
48 } elsif (not scalar(($commit->{date
}) = <> =~ /^Date:\s+(.+)$/)) {
49 die sprintf("This doesn't look like a 'Date:' line!, ".
50 "stopped at %s line %s; reading %s line %s.\n",
51 $progn, __LINE__
, $ARGV, $.);
54 # Iterating over a single commit
59 }elsif(!$commit->{file
} && /^\w/){
65 if (not $commit->{msg
}) {
66 die sprintf("Empty commit msg!, ".
67 "stopped at %s line %s; reading %s line %s.\n",
68 $progn, __LINE__
, $ARGV, $.);
71 # Prunes empty lines at the start and end of $msg
72 $commit->{msg
} =~ s/^\n+//s;
73 $commit->{msg
} =~ s/\n+$//s;
75 printf(STDERR
"\$commit = {\n") if DEBUG
;
82 printf(STDERR
"\t%s: '%s'\n",
83 $_, ($commit->{$_} ?
$commit->{$_} : "")) if DEBUG
;
85 printf(STDERR
"};\n") if DEBUG
;
93 print <<MARKDOWN if $commit->{file};
94 [Ir.]($commit->{file})