Empty properties when cloning an entry
[org-mode/org-jambu.git] / UTILITIES / make_emacs_changelog
blob059428f9117c0240124371878c865478ad2aae40
1 #!/usr/bin/perl
3 $commitrange = shift @ARGV;
4 if (!$commitrange) {
5 print STDERR "Enter commitrange: ";
6 $commitrange = <>;
7 $commitrange =~ s/\s*(.*?)\s+/$1/;
10 $syncdate = shift @ARGV;
11 if (!$syncdate) {
12 print STDERR "Enter syncdate YYYY-MM-DD: ";
13 $syncdate = <>;
14 $syncdate =~ s/\s*(.*?)\s+/$1/;
17 $kind = shift @ARGV;
18 if (!$kind) {
19 print STDERR 'Enter kind ("lisp" or "texi" or "card" or press RET): ';
20 $kind = <>;
21 $kind =~ s/\s*(.*?)\s+/$1/;
22 $kind =~ s/"(.*?)"/$1/;
23 if ($kind ne "lisp" and $kind ne "texi" and $kind ne "card"
24 and $kind ne "") {
25 die "Invalid Changelog kind";
29 # Run git log to get the commits the messages
30 open IN,"git log $commitrange|";
31 undef $/;
32 $log = <IN>;
33 @commits = split(/^(?=commit)/m,$log);
35 for $i (0..$#commits) {
36 $entry = ""; $tiny = "";
37 $commit = $commits[$i];
38 $author = $1 if $commit=~/^Author: ([^\n]+)/m;
39 $date = $1 if $commit=~/^Date: ([^\n]+)/m;
40 $entry = $1 if $commit=~/^([ \t]*\* [^\f]*?)(\n[ \t]*\n([^*]|\Z)|\Z)/m;
41 $tiny = " (tiny change)" if $commit =~ /TINYCHANGE/;
43 # split author into name and address
44 if ($author =~ /(.*?)\s+(<.*?>)/) {
45 $name = $1;
46 $address = $2;
47 } else {
48 warn "No name/address";
49 next;
52 if ($entry) {
54 # Fix the path when directories have been omitted
56 $entry =~ s/^([ \t]*\* )([-a-zA-Z]+\.el)/$1lisp\/$2/mg;
57 $entry =~ s/^([ \t]*\* )(org[a-z]*\.texi?)/$1doc\/$2/mg;
59 # remove stuff which is not for this output
60 if ($kind =~ /\S/) {
61 remove_parts("contrib/","testing/","xemacs/");
62 remove_parts("Makefile","README");
64 if ($kind eq "lisp") { remove_parts("doc/") }
65 if ($kind eq "texi") { remove_parts("lisp/","doc/orgcard","doc/orgguide") }
66 if ($kind eq "card") { remove_parts("lisp/","doc/org\\.","doc/orgguide") }
68 # indent each line by 1 TAB
69 $entry =~ s/^[ \t]*/\t/gm;
71 # Add empty lines if there are several files in there
72 $entry =~ s/(\n[ \t]+\* )/\n$1/g;
74 # remove blocks of more than one empty line
75 while ($entry =~s/\n[ \t]*\n[ \t]*\n/\n/g) {};
77 # remove/replace parts of the path
79 $entry =~ s/^([ \t]+\* )lisp\//$1/mg;
80 $entry =~ s/^([ \t]+\* )doc\/orgcard/$1 refcards\/orgcard/mg;
81 $entry =~ s/^([ \t]+\* )doc\//$1misc\//mg;
83 # remove empty space at beginning and end
84 $entry =~ s/\A\s*/\t/;
85 $entry =~ s/\s*\Z/\n/;
87 # If there is anything left in the entry, print it
88 if ($entry =~ /\S/) {
89 print "$syncdate $name $address$tiny\n\n$entry\n";
94 sub remove_parts {
95 foreach $path (@_) {
96 $re = "^[ \t]*\\*\\s+" . $path . "[^\\000]*?(?=^[ \\t]*\\*|\\Z)";
97 $entry =~ s/$re/\n$1/mg;