2013-04-23 19:21:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2020-09-09 00:54:41 +00:00
|
|
|
# Given a Wireshark issue ID, fetch its title and prepare an entry suitable
|
|
|
|
# for pasting into the release notes. Requires curl and jq.
|
2013-04-23 19:21:18 +00:00
|
|
|
#
|
2020-09-09 00:54:41 +00:00
|
|
|
# Usage: gen-bugnote <issue number>
|
2013-04-23 19:21:18 +00:00
|
|
|
#
|
|
|
|
# Copyright 2013 Gerald Combs
|
|
|
|
#
|
2018-03-07 14:28:51 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2013-04-23 19:21:18 +00:00
|
|
|
#
|
|
|
|
|
2020-09-09 00:54:41 +00:00
|
|
|
gitlab_issue_url_pfx="https://gitlab.com/api/v4/projects/wireshark%2Fwireshark/issues"
|
2020-09-23 19:34:28 +00:00
|
|
|
issue_id="${1#\#}" # Strip leading "#"
|
2013-09-07 00:18:10 +00:00
|
|
|
|
2013-04-23 19:21:18 +00:00
|
|
|
case "$OSTYPE" in
|
|
|
|
darwin*)
|
|
|
|
clipboard_cmd="pbcopy -Pascii"
|
|
|
|
;;
|
|
|
|
cygwin*)
|
|
|
|
clipboard_cmd="cat > /dev/clipboard"
|
|
|
|
;;
|
|
|
|
linux*)
|
|
|
|
clipboard_cmd="xsel --clipboard"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unable to copy to clipboard"
|
|
|
|
clipboard_cmd="cat > /dev/null"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-09-09 00:54:41 +00:00
|
|
|
if [ -z "$issue_id" ] ; then
|
|
|
|
echo "Usage: $( basename "$0" ) <issue id>"
|
2013-04-23 19:21:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-09-09 00:54:41 +00:00
|
|
|
issue_title=$(
|
|
|
|
curl -s -o - "${gitlab_issue_url_pfx}/$issue_id" \
|
2021-11-11 02:30:23 +00:00
|
|
|
| jq '.title'
|
2016-12-19 19:04:09 +00:00
|
|
|
)
|
2013-04-23 19:21:18 +00:00
|
|
|
|
2021-11-11 02:30:23 +00:00
|
|
|
# We can escape backslashes in jq's --raw-output or we can trim quotes off
|
|
|
|
# its plain output.
|
|
|
|
issue_title="${issue_title%\"}"
|
|
|
|
issue_title="${issue_title#\"}"
|
2022-05-04 17:38:02 +00:00
|
|
|
trailing_period=""
|
|
|
|
if [[ ! ${issue_title: -1} =~ [[:punct:]] ]] ; then
|
|
|
|
trailing_period="."
|
|
|
|
fi
|
2021-11-11 02:30:23 +00:00
|
|
|
|
2022-05-04 17:38:02 +00:00
|
|
|
printf "* %s%s wsbuglink:${issue_id}[].\\n" "$issue_title" "$trailing_period" \
|
2020-09-09 00:54:41 +00:00
|
|
|
| $clipboard_cmd
|
2013-04-23 19:21:18 +00:00
|
|
|
|
2020-09-09 00:54:41 +00:00
|
|
|
echo "Copied $issue_id: $issue_title"
|