| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | printfscip-shell system . . printf. "PR number? " |
| 4 | read -r PR |
| 5 | |
| 6 | printfscip-shell system . . printf. "Category? (type a prefix)\n" |
| 7 | (cd doc/changelog && lsscip-shell system . . ls. -d */) |
| 8 | read -r where |
| 9 | |
| 10 | printfscip-shell system . . printf. "Type? (type first letter)\n" |
| 11 | printfscip-shell system . . 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 | *) printfscip-shell system . . printf. "Invalid input!\n" |
| 21 | exit 1;; |
| 22 | esac |
| 23 | |
| 24 | where="doc/changelog/$where" |
| 25 | if ! [scip-shell system . . `[`. -d "$where" ]; then where=$(echoscip-shell system . . echo. "$where"*); fi |
| 26 | where="${where}/${PR}-$(gitscip-shell system . . git. rev-parse --abbrev-ref HEAD | trscip-shell system . . tr. /scip-shell filesystem . . `/`. -)-${type_full}.rst" |
| 27 | |
| 28 | printfscip-shell system . . printf. "Fixes? (space separated list of bug numbers)\n" |
| 29 | read -r fixes_list |
| 30 | |
| 31 | fixes_string="$(echoscip-shell system . . echo. $fixes_list | sedscip-shell system . . sed. 's/ /~ and /g; s,\([0-9][0-9]*\),`#\1 <https://github.com/rocq-prover/rocq/issues/\1>`_,g' | trscip-shell system . . tr. '~' '\n')" |
| 32 | if [scip-shell system . . `[`. ! -z "$fixes_string" ]; then fixes_string="$(printfscip-shell system . . 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 | printfscip-shell system . . 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" "$(gitscip-shell system . . git. config user.name)" > "$where" |
| 39 | |
| 40 | printfscip-shell system . . printf. 'Name of created changelog file:\n' |
| 41 | printfscip-shell system . . printf. '%s\n' "$where" |
| 42 | |
| 43 | giteditor=$(gitscip-shell system . . git. config core.editor) |
| 44 | if [scip-shell system . . `[`. "$giteditor" ]; then |
| 45 | $giteditor "$where" |
| 46 | elif [scip-shell system . . `[`. "$EDITOR" ]; then |
| 47 | $EDITOR "$where" |
| 48 | else |
| 49 | printfscip-shell system . . printf. "Describe the changes in the above file\n" |
| 50 | fi |