Another improvement in gencl
* mu-aux/gencl: New option --email. * Makefile.am: Simplify the ChangeLog command. Use the --email option.
Showing
2 changed files
with
47 additions
and
15 deletions
... | @@ -133,18 +133,11 @@ amend_file=ChangeLog.amend | ... | @@ -133,18 +133,11 @@ amend_file=ChangeLog.amend |
133 | .PHONY: ChangeLog | 133 | .PHONY: ChangeLog |
134 | ChangeLog: | 134 | ChangeLog: |
135 | $(AM_V_at)if test -d .git; then \ | 135 | $(AM_V_at)if test -d .git; then \ |
136 | cmd="$(top_srcdir)/mu-aux/gencl --verbose --append-dot"; \ | 136 | $(top_srcdir)/mu-aux/gencl --verbose --append-dot \ |
137 | if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \ | 137 | --email=$(PACKAGE_BUGREPORT) \ |
138 | then \ | 138 | --append=$(prev_change_log) \ |
139 | cmd="$$cmd --append=$(prev_change_log)"; \ | 139 | --amend=$(amend_file) \ |
140 | fi; \ | 140 | --since=$(gen_start_date); \ |
141 | if test -n "$(amend_file)"; then \ | ||
142 | cmd="$$cmd --amend=$(amend_file)"; \ | ||
143 | fi; \ | ||
144 | if test -n "$(gen_start_date)"; then \ | ||
145 | cmd="$$cmd --since=$(gen_start_date)"; \ | ||
146 | fi; \ | ||
147 | $$cmd; \ | ||
148 | fi | 141 | fi |
149 | 142 | ||
150 | dist-hook: ChangeLog | 143 | dist-hook: ChangeLog | ... | ... |
... | @@ -25,6 +25,7 @@ my $amend_file; | ... | @@ -25,6 +25,7 @@ my $amend_file; |
25 | my %amendment; | 25 | my %amendment; |
26 | my $append_dot; | 26 | my $append_dot; |
27 | my $ignore_errors; | 27 | my $ignore_errors; |
28 | my $email; | ||
28 | 29 | ||
29 | my $exit_status = 0; | 30 | my $exit_status = 0; |
30 | 31 | ||
... | @@ -37,10 +38,12 @@ gencl - generate ChangeLog from git log output | ... | @@ -37,10 +38,12 @@ gencl - generate ChangeLog from git log output |
37 | B<gencl> | 38 | B<gencl> |
38 | [B<-fiv>] | 39 | [B<-fiv>] |
39 | [B<-a> I<FILE>] | 40 | [B<-a> I<FILE>] |
41 | [B<-m> I<EMAIL>] | ||
40 | [B<-F> I<FILE>] | 42 | [B<-F> I<FILE>] |
41 | [B<--amend=>I<FILE>] | 43 | [B<--amend=>I<FILE>] |
42 | [B<--append-dot>] | 44 | [B<--append-dot>] |
43 | [B<--append=>I<FILE>] | 45 | [B<--append=>I<FILE>] |
46 | [B<--email=>I<EMAIL>] | ||
44 | [B<--file=>I<FILE>] | 47 | [B<--file=>I<FILE>] |
45 | [B<--force>] | 48 | [B<--force>] |
46 | [B<--ignore-errors>] | 49 | [B<--ignore-errors>] |
... | @@ -86,7 +89,13 @@ Append I<FILE> to the end of the generated file. Multiple B<--append> | ... | @@ -86,7 +89,13 @@ Append I<FILE> to the end of the generated file. Multiple B<--append> |
86 | are processed in the order of their occurrence on the command line. | 89 | are processed in the order of their occurrence on the command line. |
87 | The content of I<FILE> is appended verbatim, except that the line beginning | 90 | The content of I<FILE> is appended verbatim, except that the line beginning |
88 | with the text B<Local Variables:> is taken to mark the end of file. | 91 | with the text B<Local Variables:> is taken to mark the end of file. |
89 | 92 | ||
93 | =item B<-m>, B<--email=>I<EMAIL> | ||
94 | |||
95 | Sets email address to use in the topmost automatically generated entry. | ||
96 | In the absense of this option, B<gencl> constructs the email from the | ||
97 | current user name and the domain (or host) name. | ||
98 | |||
90 | =item B<-F>, B<--file=>I<FILE> | 99 | =item B<-F>, B<--file=>I<FILE> |
91 | 100 | ||
92 | Create I<FILE> instead of the B<ChangeLog>. | 101 | Create I<FILE> instead of the B<ChangeLog>. |
... | @@ -225,13 +234,40 @@ GetOptions( | ... | @@ -225,13 +234,40 @@ GetOptions( |
225 | 'strip-cherry-pick' => \$strip_cherry_pick, | 234 | 'strip-cherry-pick' => \$strip_cherry_pick, |
226 | 'amend=s' => \$amend_file, | 235 | 'amend=s' => \$amend_file, |
227 | 'append-dot' => \$append_dot, | 236 | 'append-dot' => \$append_dot, |
228 | 'ignore-errors|i' => \$ignore_errors | 237 | 'ignore-errors|i' => \$ignore_errors, |
238 | 'email|m=s' => \$email | ||
229 | ) or exit(1); | 239 | ) or exit(1); |
230 | 240 | ||
231 | if (! -d '.git') { | 241 | if (! -d '.git') { |
232 | exit 0; | 242 | exit 0; |
233 | } | 243 | } |
234 | 244 | ||
245 | unless (defined($email)) { | ||
246 | if (exists($ENV{EMAIL})) { | ||
247 | $email = $ENV{EMAIL}; | ||
248 | } else { | ||
249 | my ($user, $domain); | ||
250 | if (exists($ENV{USER})) { | ||
251 | $user = $ENV{USER}; | ||
252 | } elsif (my ($name) = getpwuid(getuid())) { | ||
253 | $user = $name; | ||
254 | } else { | ||
255 | die "can't get user name"; | ||
256 | } | ||
257 | |||
258 | if (chomp($domain = `domainname`) && $domain ne "(none)") { | ||
259 | ; | ||
260 | } elsif (exists($ENV{HOSTNAME})) { | ||
261 | $domain = $ENV{HOSTNAME}; | ||
262 | } elsif ($domain = `hostname`) { | ||
263 | chomp $domain; | ||
264 | } else { | ||
265 | $domain = 'localhost'; | ||
266 | } | ||
267 | $email = $user . '@' . $domain; | ||
268 | } | ||
269 | } | ||
270 | |||
235 | read_amend_file($amend_file) if $amend_file; | 271 | read_amend_file($amend_file) if $amend_file; |
236 | 272 | ||
237 | $Text::Wrap::columns = 72; | 273 | $Text::Wrap::columns = 72; |
... | @@ -258,7 +294,7 @@ sub toplevel_entry { | ... | @@ -258,7 +294,7 @@ sub toplevel_entry { |
258 | 294 | ||
259 | my @header; | 295 | my @header; |
260 | 296 | ||
261 | push @header, "$date Automatically generated <bug-mailutils\@gnu.org>"; | 297 | push @header, "$date Automatically generated <$email>"; |
262 | push @header, ''; | 298 | push @header, ''; |
263 | push @header, "\tHEAD $hash."; | 299 | push @header, "\tHEAD $hash."; |
264 | push @header, ''; | 300 | push @header, ''; |
... | @@ -289,6 +325,9 @@ sub toplevel_entry { | ... | @@ -289,6 +325,9 @@ sub toplevel_entry { |
289 | sub headcmp { | 325 | sub headcmp { |
290 | my $file = shift; | 326 | my $file = shift; |
291 | if (open(my $fd, '<', $changelog_file)) { | 327 | if (open(my $fd, '<', $changelog_file)) { |
328 | # Skip first line | ||
329 | $_ = <$fd>; | ||
330 | shift; | ||
292 | while (<$fd>) { | 331 | while (<$fd>) { |
293 | my $line = shift; | 332 | my $line = shift; |
294 | last unless defined($line); | 333 | last unless defined($line); | ... | ... |
-
Please register or sign in to post a comment