2010-07-07 02:44:48 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
$commitrange = shift @ARGV;
|
|
|
|
if (!$commitrange) {
|
|
|
|
print STDERR "Enter commitrange: ";
|
|
|
|
$commitrange = <>;
|
|
|
|
$commitrange =~ s/\s*(.*?)\s+/$1/;
|
|
|
|
}
|
|
|
|
|
|
|
|
$syncdate = shift @ARGV;
|
|
|
|
if (!$syncdate) {
|
|
|
|
print STDERR "Enter syncdate YYYY-MM-DD: ";
|
|
|
|
$syncdate = <>;
|
|
|
|
$syncdate =~ s/\s*(.*?)\s+/$1/;
|
|
|
|
}
|
|
|
|
|
2010-10-23 02:18:06 -04:00
|
|
|
$kind = shift @ARGV;
|
|
|
|
if (!$kind) {
|
|
|
|
print STDERR 'Enter kind ("lisp" or "texi" or "card" or press RET): ';
|
|
|
|
$kind = <>;
|
|
|
|
$kind =~ s/\s*(.*?)\s+/$1/;
|
|
|
|
$kind =~ s/"(.*?)"/$1/;
|
2010-12-11 11:56:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($kind ne "lisp" and $kind ne "texi" and $kind ne "card"
|
|
|
|
and $kind ne "") {
|
|
|
|
die "Invalid Changelog kind";
|
2010-10-23 02:18:06 -04:00
|
|
|
}
|
|
|
|
|
2012-05-27 11:47:04 -04:00
|
|
|
# commit must touch these paths or files to be considered
|
|
|
|
$fpath = "lisp/ doc/";
|
|
|
|
|
2010-07-07 02:44:48 -04:00
|
|
|
# Run git log to get the commits the messages
|
2012-05-27 11:47:04 -04:00
|
|
|
open IN,"git log --no-merges --format='%aN%n<%aE>%n%b%x0c' $commitrange -- $fpath|";
|
2010-07-07 02:44:48 -04:00
|
|
|
undef $/;
|
|
|
|
$log = <IN>;
|
2012-05-27 06:53:37 -04:00
|
|
|
@commits = split(/\f/,$log);
|
2010-07-07 02:44:48 -04:00
|
|
|
|
2012-05-27 11:47:04 -04:00
|
|
|
my %entries;
|
|
|
|
|
2012-05-27 06:53:37 -04:00
|
|
|
foreach my $commit (@commits) {
|
|
|
|
$name = ( $commit=~ s/([^\n]+)\n//m ) ? $1 : "N/A";
|
|
|
|
$address = ( $commit=~ s/([^\n]+)\n//m ) ? $1 : "N/A";
|
|
|
|
$tiny = $commit =~ s/TINYCHANGE//mg ? " (tiny change)" : "";
|
|
|
|
$entry = $commit;
|
2010-07-07 02:44:48 -04:00
|
|
|
|
|
|
|
if ($entry) {
|
2010-10-23 02:18:06 -04:00
|
|
|
|
2012-05-27 11:47:04 -04:00
|
|
|
# remove whitespace at beginning of line
|
|
|
|
$entry =~ s/^[ \t]*//mg;
|
|
|
|
|
2012-05-27 06:53:37 -04:00
|
|
|
# add linebreaks before each starred line except the very first
|
2012-05-27 11:47:04 -04:00
|
|
|
$entry =~ s/\A[\n\t]*/@/mg;
|
|
|
|
$entry =~ s/^\*/\n\n*/mg;
|
2012-05-27 06:53:37 -04:00
|
|
|
$entry =~ s/\A@//mg;
|
|
|
|
|
|
|
|
# normalize starred lines
|
|
|
|
$entry =~ s/^(\*[^(]*\S)\(/\1 (/mg;
|
2010-10-23 02:18:06 -04:00
|
|
|
|
2012-05-27 06:53:37 -04:00
|
|
|
# remove blocks of more than one empty line
|
2012-05-27 11:47:04 -04:00
|
|
|
$entry =~s/\n{3,}/\n\n/mg;
|
2012-05-27 06:53:37 -04:00
|
|
|
|
|
|
|
# Fix the path when directories have been omitted
|
|
|
|
$entry =~ s/^\* ([-a-zA-Z]+\.el)/* lisp\/$1/mg;
|
|
|
|
$entry =~ s/^\* (org[a-z]*\.texi?)/* doc\/$1/mg;
|
2010-10-23 02:18:06 -04:00
|
|
|
|
|
|
|
# remove stuff which is not for this output
|
|
|
|
if ($kind =~ /\S/) {
|
2012-08-26 08:03:20 -04:00
|
|
|
# do not delete or rename directories from the list as long as
|
|
|
|
# Changelog entries referring to them exist!
|
2012-09-03 06:47:02 -04:00
|
|
|
remove_parts(qw( contrib/ testing/ xemacs/ mk/ etc/ ));
|
2012-08-26 08:03:20 -04:00
|
|
|
remove_parts(qw( .*Makefile README .+\.mk ));
|
2010-10-23 02:18:06 -04:00
|
|
|
}
|
|
|
|
if ($kind eq "lisp") { remove_parts("doc/") }
|
|
|
|
if ($kind eq "texi") { remove_parts("lisp/","doc/orgcard","doc/orgguide") }
|
|
|
|
if ($kind eq "card") { remove_parts("lisp/","doc/org\\.","doc/orgguide") }
|
|
|
|
|
|
|
|
# remove/replace parts of the path
|
2012-05-27 06:53:37 -04:00
|
|
|
$entry =~ s:^\* lisp/:* :mg;
|
|
|
|
$entry =~ s:^\* doc/orgcard:* refcards/orgcard:mg;
|
|
|
|
$entry =~ s:^\* doc/:* misc/:mg;
|
2010-10-23 02:18:06 -04:00
|
|
|
|
|
|
|
# remove empty space at beginning and end
|
2012-05-27 06:53:37 -04:00
|
|
|
$entry =~ s/\A\s*//;
|
|
|
|
$entry =~ s/\s*\Z//;
|
|
|
|
|
|
|
|
# remove everything that is not a starred entry
|
2012-05-27 11:47:04 -04:00
|
|
|
my @entries = grep( /^\*/, split( /\n\n/, $entry ));
|
2010-10-23 02:18:06 -04:00
|
|
|
|
|
|
|
# If there is anything left in the entry, print it
|
2012-05-27 11:47:04 -04:00
|
|
|
if (scalar @entries) {
|
|
|
|
push @{ $entries{"$syncdate $name $address$tiny"} }, @entries;
|
2010-10-23 02:18:06 -04:00
|
|
|
}
|
2010-07-07 02:44:48 -04:00
|
|
|
}
|
|
|
|
}
|
2012-05-27 11:47:04 -04:00
|
|
|
foreach my $key ( sort keys %entries ) {
|
|
|
|
next if (! exists $entries{"$key"} );
|
|
|
|
print "$key\n";
|
|
|
|
if ( exists $entries{"$key (tiny change)"} ) {
|
|
|
|
push @{ $entries{"$key"} }, @{ $entries{"$key (tiny change)"} };
|
|
|
|
delete $entries{"$key (tiny change)"};
|
|
|
|
}
|
|
|
|
my @entries = @{ $entries{"$key"} };
|
|
|
|
foreach my $entry ( @entries ) {
|
|
|
|
# indent each line by exactly one TAB
|
|
|
|
$entry =~ s/^/\t/mg;
|
|
|
|
print "\n$entry\n";
|
|
|
|
}
|
|
|
|
print "\n\n";
|
|
|
|
}
|
2010-07-07 02:44:48 -04:00
|
|
|
|
2010-10-23 02:18:06 -04:00
|
|
|
sub remove_parts {
|
|
|
|
foreach $path (@_) {
|
|
|
|
$re = "^[ \t]*\\*\\s+" . $path . "[^\\000]*?(?=^[ \\t]*\\*|\\Z)";
|
|
|
|
$entry =~ s/$re/\n$1/mg;
|
|
|
|
}
|
|
|
|
}
|