Mercurial > hg > octave-lojdl > gnulib-hg
annotate build-aux/gitlog-to-changelog @ 12217:e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Rather than putting #!/usr/bin/perl on the first line,
start with a variant of what's recommended by "man perlrun" that
invokes the first "perl" program from your shell's search path.
* build-aux/gitlog-to-changelog: Replace #!... as above.
Add a "Local Variables" perl mode setting.
Prompted by a patch from Ludovic Courtès.
Improved by Eric Blake.
* build-aux/useless-if-before-free: Likewise.
* build-aux/announce-gen: Likewise.
* build-aux/update-copyright: Likewise.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Fri, 30 Oct 2009 15:02:02 +0100 |
parents | 9db809f9b38f |
children | b5e42ef33b49 |
rev | line source |
---|---|
12217
e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Jim Meyering <meyering@redhat.com>
parents:
11812
diff
changeset
|
1 eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' |
e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Jim Meyering <meyering@redhat.com>
parents:
11812
diff
changeset
|
2 & eval 'exec perl -wS "$0" $argv:q' |
e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Jim Meyering <meyering@redhat.com>
parents:
11812
diff
changeset
|
3 if 0; |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
4 # Convert git log output to ChangeLog format. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
5 |
12217
e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Jim Meyering <meyering@redhat.com>
parents:
11812
diff
changeset
|
6 my $VERSION = '2009-10-30 13:46'; # UTC |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
7 # The definition above must lie within the first 8 lines in order |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
8 # for the Emacs time-stamp write hook (at end) to update it. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
9 # If you change this file with Emacs, please let the write hook |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
10 # do its job. Otherwise, update this string manually. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
11 |
11604
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
12 # Copyright (C) 2008, 2009 Free Software Foundation, Inc. |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
13 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
14 # This program is free software: you can redistribute it and/or modify |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
15 # it under the terms of the GNU General Public License as published by |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
16 # the Free Software Foundation, either version 3 of the License, or |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
17 # (at your option) any later version. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
18 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
19 # This program is distributed in the hope that it will be useful, |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
22 # GNU General Public License for more details. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
23 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
24 # You should have received a copy of the GNU General Public License |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
25 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
26 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
27 # Written by Jim Meyering |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
28 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
29 use strict; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
30 use warnings; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
31 use Getopt::Long; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
32 use POSIX qw(strftime); |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
33 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
34 (my $ME = $0) =~ s|.*/||; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
35 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
36 # use File::Coda; # http://meyering.net/code/Coda/ |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
37 END { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
38 defined fileno STDOUT or return; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
39 close STDOUT and return; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
40 warn "$ME: failed to close standard output: $!\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
41 $? ||= 1; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
42 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
43 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
44 sub usage ($) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
45 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
46 my ($exit_code) = @_; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
47 my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
48 if ($exit_code != 0) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
49 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
50 print $STREAM "Try `$ME --help' for more information.\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
51 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
52 else |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
53 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
54 print $STREAM <<EOF; |
10934
6c0822db154b
gitlog-to-changelog: pass all command-line arguments to git-log
William Pursell <bill.pursell@gmail.com>
parents:
10341
diff
changeset
|
55 Usage: $ME [OPTIONS] [ARGS] |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
56 |
10934
6c0822db154b
gitlog-to-changelog: pass all command-line arguments to git-log
William Pursell <bill.pursell@gmail.com>
parents:
10341
diff
changeset
|
57 Convert git log output to ChangeLog format. If present, any ARGS |
6c0822db154b
gitlog-to-changelog: pass all command-line arguments to git-log
William Pursell <bill.pursell@gmail.com>
parents:
10341
diff
changeset
|
58 are passed to "git log". To avoid ARGS being parsed as options to |
6c0822db154b
gitlog-to-changelog: pass all command-line arguments to git-log
William Pursell <bill.pursell@gmail.com>
parents:
10341
diff
changeset
|
59 $ME, they may be preceded by '--'. |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
60 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
61 OPTIONS: |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
62 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
63 --since=DATE convert only the logs since DATE; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
64 the default is to convert all log entries. |
11812
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
65 --format=FMT set format string for commit subject and body; |
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
66 see 'man git-log' for the list of format metacharacters; |
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
67 the default is '%s%n%b%n' |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
68 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
69 --help display this help and exit |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
70 --version output version information and exit |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
71 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
72 EXAMPLE: |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
73 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
74 $ME --since=2008-01-01 > ChangeLog |
10934
6c0822db154b
gitlog-to-changelog: pass all command-line arguments to git-log
William Pursell <bill.pursell@gmail.com>
parents:
10341
diff
changeset
|
75 $ME -- -n 5 foo > last-5-commits-to-branch-foo |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
76 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
77 EOF |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
78 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
79 exit $exit_code; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
80 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
81 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
82 # If the string $S is a well-behaved file name, simply return it. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
83 # If it contains white space, quotes, etc., quote it, and return the new string. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
84 sub shell_quote($) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
85 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
86 my ($s) = @_; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
87 if ($s =~ m![^\w+/.,-]!) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
88 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
89 # Convert each single quote to '\'' |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
90 $s =~ s/\'/\'\\\'\'/g; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
91 # Then single quote the string. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
92 $s = "'$s'"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
93 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
94 return $s; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
95 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
96 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
97 sub quoted_cmd(@) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
98 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
99 return join (' ', map {shell_quote $_} @_); |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
100 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
101 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
102 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
103 my $since_date = '1970-01-01 UTC'; |
11812
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
104 my $format_string = '%s%n%b%n'; |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
105 GetOptions |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
106 ( |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
107 help => sub { usage 0 }, |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
108 version => sub { print "$ME version $VERSION\n"; exit }, |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
109 'since=s' => \$since_date, |
11812
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
110 'format=s' => \$format_string, |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
111 ) or usage 1; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
112 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
113 my @cmd = (qw (git log --log-size), "--since=$since_date", |
11812
9db809f9b38f
Minor improvement in gitlog-to-changelog
Sergey Poznyakoff <gray@gnu.org.ua>
parents:
11604
diff
changeset
|
114 '--pretty=format:%ct %an <%ae>%n%n'.$format_string, @ARGV); |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
115 open PIPE, '-|', @cmd |
10341
973c3d3ff40f
gitlog-to-changelog: give better diagnostic for failed pipe-open
Ben Pfaff <blp@gnu.org>
parents:
9682
diff
changeset
|
116 or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n" |
973c3d3ff40f
gitlog-to-changelog: give better diagnostic for failed pipe-open
Ben Pfaff <blp@gnu.org>
parents:
9682
diff
changeset
|
117 . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
118 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
119 my $prev_date_line = ''; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
120 while (1) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
121 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
122 defined (my $in = <PIPE>) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
123 or last; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
124 $in =~ /^log size (\d+)$/ |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
125 or die "$ME:$.: Invalid line (expected log size):\n$in"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
126 my $log_nbytes = $1; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
127 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
128 my $log; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
129 my $n_read = read PIPE, $log, $log_nbytes; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
130 $n_read == $log_nbytes |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
131 or die "$ME:$.: unexpected EOF\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
132 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
133 my @line = split "\n", $log; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
134 my $author_line = shift @line; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
135 defined $author_line |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
136 or die "$ME:$.: unexpected EOF\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
137 $author_line =~ /^(\d+) (.*>)$/ |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
138 or die "$ME:$.: Invalid line " |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
139 . "(expected date/author/email):\n$author_line\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
140 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
141 my $date_line = sprintf "%s $2\n", strftime ("%F", localtime ($1)); |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
142 # If this line would be the same as the previous date/name/email |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
143 # line, then arrange not to print it. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
144 if ($date_line ne $prev_date_line) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
145 { |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
146 $prev_date_line eq '' |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
147 or print "\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
148 print $date_line; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
149 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
150 $prev_date_line = $date_line; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
151 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
152 # Omit "Signed-off-by..." lines. |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
153 @line = grep !/^Signed-off-by: .*>$/, @line; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
154 |
11604
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
155 # If there were any lines |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
156 if (@line == 0) |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
157 { |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
158 warn "$ME: warning: empty commit message:\n $date_line\n"; |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
159 } |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
160 else |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
161 { |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
162 # Remove leading and trailing blank lines. |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
163 while ($line[0] =~ /^\s*$/) { shift @line; } |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
164 while ($line[$#line] =~ /^\s*$/) { pop @line; } |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
165 |
11604
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
166 # Prefix each non-empty line with a TAB. |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
167 @line = map { length $_ ? "\t$_" : '' } @line; |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
168 |
11604
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
169 print "\n", join ("\n", @line), "\n"; |
6855551f304d
gitlog-to-changelog: don't infloop on an empty commit log
Jim Meyering <meyering@redhat.com>
parents:
10934
diff
changeset
|
170 } |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
171 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
172 defined ($in = <PIPE>) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
173 or last; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
174 $in ne "\n" |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
175 and die "$ME:$.: unexpected line:\n$in"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
176 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
177 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
178 close PIPE |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
179 or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
180 # FIXME-someday: include $PROCESS_STATUS in the diagnostic |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
181 } |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
182 |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
183 # Local Variables: |
12217
e9550a750583
perl scripts: remove #!/usr/bin/perl in favor of more portable...
Jim Meyering <meyering@redhat.com>
parents:
11812
diff
changeset
|
184 # mode: perl |
9680
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
185 # indent-tabs-mode: nil |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
186 # eval: (add-hook 'write-file-hooks 'time-stamp) |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
187 # time-stamp-start: "my $VERSION = '" |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
188 # time-stamp-format: "%:y-%02m-%02d %02H:%02M" |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
189 # time-stamp-time-zone: "UTC" |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
190 # time-stamp-end: "'; # UTC" |
8df33869766a
New script and module: gitlog-to-changelog
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
191 # End: |