File: gen-bugnote

package info (click to toggle)
wireshark 4.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 351,352 kB
  • sloc: ansic: 3,102,875; cpp: 129,717; xml: 100,972; python: 56,513; perl: 24,575; sh: 5,874; lex: 4,383; pascal: 4,304; makefile: 166; ruby: 113; objc: 91; tcl: 35
file content (51 lines) | stat: -rwxr-xr-x 1,204 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#
# Given a Wireshark issue ID, fetch its title and prepare an entry suitable
# for pasting into the release notes. Requires curl and jq.
#
# Usage: gen-bugnote <issue number>
#
# Copyright 2013 Gerald Combs
#
# SPDX-License-Identifier: GPL-2.0-or-later
#

gitlab_issue_url_pfx="https://gitlab.com/api/v4/projects/wireshark%2Fwireshark/issues"
issue_id="${1#\#}" # Strip leading "#"

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

if [ -z "$issue_id" ] ; then
    echo "Usage: $( basename "$0" ) <issue id>"
    exit 1
fi

issue_title=$(
    curl --silent "${gitlab_issue_url_pfx}/$issue_id" \
    | jq --raw-output '.title'
    )

issue_title="${issue_title//\\/\{backslash\}}"
trailing_period=""
if [[ ! ${issue_title: -1} =~ [[:punct:]] ]] ; then
    trailing_period="."
fi

printf "* %s%s wsbuglink:${issue_id}[].\\n" "$issue_title" "$trailing_period" \
    | $clipboard_cmd

echo "Copied $issue_id: $issue_title"