|
1 | 1 | #!/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 | +# |
2 | 20 | FROM=v6.0.0 |
| 21 | +TO=. |
| 22 | +PROJ=universal-ctags |
| 23 | +REPO=ctags |
| 24 | + |
| 25 | +args=("$@") |
3 | 26 |
|
4 | 27 | pr_title() |
5 | 28 | { |
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/'/'/g" -e 's/&/\&/g' -e 's/"/"/g' -e 's/>/>/g' -e 's/</</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/'/'/g" -e 's/&/\&/g' -e 's/"/"/g' -e 's/>/>/g' -e 's/</</g' |
10 | 33 | } |
11 | 34 |
|
12 | 35 | issue_title() |
13 | 36 | { |
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/'/'/g" -e 's/&/\&/g' -e 's/"/"/g' -e 's/>/>/g' -e 's/</</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/'/'/g" -e 's/&/\&/g' -e 's/"/"/g' -e 's/>/>/g' -e 's/</</g' |
18 | 41 | } |
19 | 42 |
|
20 | 43 | usage() |
21 | 44 | { |
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" |
26 | 49 | } |
27 | 50 |
|
28 | 51 | if [[ $# == 0 ]]; then |
29 | | - usage 1>&2 |
30 | | - exit 1 |
| 52 | + usage 1>&2 |
| 53 | + exit 1 |
31 | 54 | fi |
32 | 55 |
|
33 | 56 | 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 | + ;; |
68 | 97 | esac |
0 commit comments