| 1 | #!/bin/sh |
| 2 | |
| 3 | printf "PR number? " |
| 4 | read -r PR |
| 5 | |
| 6 | printf "Category? (type a prefix)\n" |
| 7 | (cd doc/changelog && ls -d */) |
| 8 | read -r where |
| 9 | |
| 10 | printf "Type? (type first letter)\n" |
| 11 | printf "[A]dded \t[C]hanged \t[D]eprecated \t[F]ixed \t[R]emoved\n" |
| 12 | read -r type_first_letter |
| 13 | |
| 14 | case "$type_first_letter" in |
| 15 | [Aa]) type_full="Added";; |
| 16 | [Cc]) type_full="Changed";; |
| 17 | [Dd]) type_full="Deprecated";; |
| 18 | [Ff]) type_full="Fixed";; |
| 19 | [Rr]) type_full="Removed";; |
| 20 | *) printf "Invalid input!\n" |
| 21 | exit 1;; |
| 22 | esac |
| 23 | |
| 24 | where="doc/changelog/$where" |
| 25 | if ! [ -d "$where" ]; then where=$(echo "$where"*); fi |
| 26 | where="${where}/${PR}-$(git rev-parse --abbrev-ref HEAD | tr / -)-${type_full}.rst" |
| 27 | |
| 28 | printf "Fixes? (space separated list of bug numbers)\n" |
| 29 | read -r fixes_list |
| 30 | |
| 31 | fixes_string="$(echo $fixes_list | sed 's/ /~ and /g; s,\([0-9][0-9]*\),`#\1 <https://github.com/rocq-prover/rocq/issues/\1>`_,g' | tr '~' '\n')" |
| 32 | if [ ! -z "$fixes_string" ]; then fixes_string="$(printf '\n fixes %s,' "$fixes_string")"; fi |
| 33 | |
| 34 | # shellcheck disable=SC2016 |
| 35 | # the ` are regular strings, this is intended |
| 36 | # use %s for the leading - to avoid looking like an option (not sure |
| 37 | # if necessary but doesn't hurt) |
| 38 | printf '%s **%s:**\n Describe your change here but do not end with a period\n (`#%s <https://github.com/rocq-prover/rocq/pull/%s>`_,%s\n by %s).\n' - "$type_full" "$PR" "$PR" "$fixes_string" "$(git config user.name)" > "$where" |
| 39 | |
| 40 | printf 'Name of created changelog file:\n' |
| 41 | printf '%s\n' "$where" |
| 42 | |
| 43 | giteditor=$(git config core.editor) |
| 44 | if [ "$giteditor" ]; then |
| 45 | $giteditor "$where" |
| 46 | elif [ "$EDITOR" ]; then |
| 47 | $EDITOR "$where" |
| 48 | else |
| 49 | printf "Describe the changes in the above file\n" |
| 50 | fi |