Skip to content

Commit 74058f9

Browse files
authored
Merge pull request #3877 from masatake/misc-news--generalize
misc/news.bash: generalize the script
2 parents 6a6f927 + ed36fd1 commit 74058f9

File tree

1 file changed

+77
-48
lines changed

1 file changed

+77
-48
lines changed

misc/news.bash

Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,97 @@
11
#!/bin/bash
2+
#
3+
# news.bash - enumerate the titles of issues and pull-requests closed between FROM..TO
4+
#
5+
# Copyright (C) 2023 Masatake YAMATO
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
#
220
FROM=v6.0.0
21+
TO=.
22+
PROJ=universal-ctags
23+
REPO=ctags
24+
25+
args=("$@")
326

427
pr_title()
528
{
6-
local N=$1
7-
curl https://github.com/universal-ctags/ctags/pull/"$N" | grep '^ <title>' | \
8-
sed -e 's!^[[:space:]]*<title>\(.\+Pull Request #[0-9]*\).*</title>$!* \1!' | \
9-
sed -e "s/&#39;/'/g" -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e 's/&gt;/>/g' -e 's/&lt;/</g'
29+
local N=$1
30+
curl --no-progress-meter https://github.com/${PROJ}/${REPO}/pull/"$N" | grep '^ <title>' | \
31+
sed -e 's!^[[:space:]]*<title>\(.\+Pull Request #[0-9]*\).*</title>$!* \1!' | \
32+
sed -e "s/&#39;/'/g" -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e 's/&gt;/>/g' -e 's/&lt;/</g'
1033
}
1134

1235
issue_title()
1336
{
14-
local N=$1
15-
curl https://github.com/universal-ctags/ctags/issues/"$N" | grep '^ <title>' | \
16-
sed -e 's!^[[:space:]]*<title>\(.\+Issue #[0-9]*\).*</title>$!* \1!' | \
17-
sed -e "s/&#39;/'/g" -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e 's/&gt;/>/g' -e 's/&lt;/</g'
37+
local N=$1
38+
curl --no-progress-meter https://github.com/${PROJ}/${REPO}/issues/"$N" | grep '^ <title>' | \
39+
sed -e 's!^[[:space:]]*<title>\(.\+Issue #[0-9]*\).*</title>$!* \1!' | \
40+
sed -e "s/&#39;/'/g" -e 's/&amp;/\&/g' -e 's/&quot;/"/g' -e 's/&gt;/>/g' -e 's/&lt;/</g'
1841
}
1942

2043
usage()
2144
{
22-
printf " %s help|--help|-h\n" "$0"
23-
printf " %s pr [#]\n" "$0"
24-
printf " %s issue [#]\n" "$0"
25-
printf " %s man\n" "$0"
45+
printf " %s help|--help|-h\n" "$0"
46+
printf " %s pr [#]\n" "$0"
47+
printf " %s issue [#]\n" "$0"
48+
printf " %s man\n" "$0"
2649
}
2750

2851
if [[ $# == 0 ]]; then
29-
usage 1>&2
30-
exit 1
52+
usage 1>&2
53+
exit 1
3154
fi
3255

3356
case $1 in
34-
(help|--help|-h)
35-
usage 1>&2
36-
exit 0
37-
;;
38-
(pr)
39-
shift
40-
if [[ $1 =~ [0-9]+ ]]; then
41-
pr_title "$1"
42-
exit 0
43-
else
44-
git log --oneline ${FROM}.. \
45-
| grep '[0-9a-f]\+ Merge pull request #[0-9]\+.*' \
46-
| sed -ne 's/.*#\([0-9]\+\) from.*/\1/p' | while read N; do
47-
pr_title "$N"
48-
done
49-
exit 0
50-
fi
51-
;;
52-
(issue)
53-
shift
54-
if [[ $1 =~ [0-9]+ ]]; then
55-
issue_title "$1"
56-
exit 0
57-
else
58-
git log ${FROM}.. \
59-
| grep 'Close #' \
60-
| sed -ne 's/[[:space:]]Close #\([0-9]\+\).*/\1/p' | while read N; do
61-
issue_title $N
62-
done
63-
fi
64-
;;
65-
(man)
66-
git diff ${FROM}... man/*.in
67-
;;
57+
(help|--help|-h)
58+
usage 1>&2
59+
exit 0
60+
;;
61+
(pr)
62+
shift
63+
if [[ $1 =~ [0-9]+ ]]; then
64+
pr_title "$1"
65+
exit 0
66+
else
67+
echo
68+
echo ".. generated by $0 ${args[@]}" "[$FROM..$TO]"
69+
echo
70+
git log --oneline ${FROM}..${TO} \
71+
| grep '[0-9a-f]\+ Merge pull request #[0-9]\+.*' \
72+
| sed -ne 's/.*#\([0-9]\+\) from.*/\1/p' | while read N; do
73+
pr_title "$N"
74+
done
75+
exit 0
76+
fi
77+
;;
78+
(issue)
79+
shift
80+
if [[ $1 =~ [0-9]+ ]]; then
81+
issue_title "$1"
82+
exit 0
83+
else
84+
echo
85+
echo ".. generated by $0 ${args[@]}" "[$FROM..$TO]"
86+
echo
87+
git log ${FROM}..${TO} \
88+
| grep '^[ \t]*[Cc]losed\? *#' \
89+
| sed -ne 's/[[:space:]][Cc]losed\? *#\([0-9]\+\).*/\1/p' | while read N; do
90+
issue_title $N
91+
done
92+
fi
93+
;;
94+
(man)
95+
git diff ${FROM}..${TO} man/*.in
96+
;;
6897
esac

0 commit comments

Comments
 (0)