]> code.delx.au - gnu-emacs/blob - build-aux/gitlog-to-emacslog
Avoid unnecessary bumping of Makefile.in's timestamp.
[gnu-emacs] / build-aux / gitlog-to-emacslog
1 #!/bin/sh
2
3 # Convert git log output to ChangeLog format for GNU Emacs.
4
5 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
6
7 # Author: Paul Eggert
8
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 LC_ALL=C
23 export LC_ALL
24
25 # The newest revision that should not appear in the generated ChangeLog.
26 gen_origin=2c1b8604946efbcd8ec5dd6c6dda7541ce4fc3c0
27 test -n "$1" && test "$1" != "." && gen_origin=$1
28
29 output=$2
30 test -n "$output" || output=ChangeLog
31
32 # If this is not a Git repository, just generate an empty ChangeLog.
33 test -d ${srcprefix}.git || {
34 # Remove any old ChangeLog, in case it is a vc-dwim symlink.
35 rm -f "${distprefix}$output" || exit
36 >"${distprefix}$output"
37 exit
38 }
39
40 # Use Gnulib's packaged ChangeLog generator.
41 ${srcprefix}build-aux/gitlog-to-changelog --ignore-matching='^; ' \
42 --format='%B' \
43 "$gen_origin.." >"${distprefix}ChangeLog.tmp" || exit
44
45 if test -s "${distprefix}ChangeLog.tmp"; then
46
47 # Fix up bug references.
48 # This would be better as eg a --transform option to gitlog-to-changelog,
49 # but... effort. FIXME does not handle rare cases like:
50 # Fixes: debbugs:19434 debbugs:19519
51 sed 's/ Fixes: \(debbugs:\|bug#\)\([0-9][0-9]*\)/ (Bug#\2)/' \
52 "${distprefix}ChangeLog.tmp" > "${distprefix}ChangeLog.tmp2"
53 mv "${distprefix}ChangeLog.tmp2" "${distprefix}ChangeLog.tmp"
54
55 # Find the years covered by the generated ChangeLog, so that
56 # a proper copyright notice can be output.
57 years=`
58 sed -n 's/^\([0-9][0-9]*\).*/\1/p' "${distprefix}ChangeLog.tmp" |
59 sort -nu
60 `
61 start_year=
62 end_year=
63 for year in $years; do
64 : ${start_year:=$year}
65 end_year=$year
66 done
67
68 if test "$start_year" = "$end_year"; then
69 year_range=$start_year
70 else
71 year_range=$start_year-$end_year
72 fi
73
74 # Append a proper copyright notice.
75 sed -n '
76 1i\
77
78 /^;; Local Variables:/,${
79 s/\(Copyright[ (C)]*\)[0-9]*-[0-9]*/\1'"$year_range"'/
80 p
81 }
82 ' <ChangeLog.2 >>"${distprefix}ChangeLog.tmp" || exit
83 fi
84
85 # Install the generated ChangeLog.
86 test "$output" = "ChangeLog.tmp" || \
87 mv -i "${distprefix}ChangeLog.tmp" "${distprefix}$output"