-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlinux-issue-update
More file actions
executable file
·68 lines (57 loc) · 1.9 KB
/
Copy pathlinux-issue-update
File metadata and controls
executable file
·68 lines (57 loc) · 1.9 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Update existing issue after a patchset update
#
# Usage (specify message id and subject manually):
#
# linux-issue-update issue messageid subject
#
# or (piped from a mail or a file, using Message-id: and Subject:):
#
# ... | linux-issue-new
#
# possible issues will be listed but need to be typed manually to verify
#
# eg. from your mail client
#
# Requires: gh (authenticated), formail
type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; }
type -p formail > /dev/null || { echo "ERROR: formail tool not found"; exit 1; }
if [ $# = 0 ]; then
echo "ISSUES: update issue from mail on stdin"
tmp=`mktemp`
cat > "$tmp"
subject="`cat "$tmp" | formail -c -z -x Subject`"
msgid="`cat "$tmp" | formail -c -z -x Message-id | tr -d '<>'`"
else
echo "ERROR: Usage: ... | $0"
exit 1
fi
_json_escape() {
printf '%s' "$1" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
}
echo "MSGID: $msgid"
echo "SUBJECT: $subject"
match="$(linux-issue-match < $tmp)"
echo "ISSUES: possible related issues:"
echo "$match"
read -p "ISSUES: enter issue you want to update: " issue < /dev/tty
echo "ISSUE: [$issue]"
if ! [[ $issue =~ ^[0-9]+$ ]]; then
echo "ERROR: not an issue number"
exit 1
fi
echo "ISSUES: update issue with subject $subject"
lore="https://lore.kernel.org/linux-btrfs/${msgid}/
b4 am ${msgid}"
lore=$(_json_escape "$lore")
subject=$(_json_escape "$subject")
echo "{\"body\": ${lore}}" |
gh api "repos/btrfs/linux/issues/${issue}/comments" --input=-
echo "{\"title\": ${subject}}" | \
gh api "repos/btrfs/linux/issues/${issue}" --input=-
repo=btrfs/linux
gh api -X DELETE "repos/$repo/issues/$issue/labels/update"
gh api -X DELETE "repos/$repo/issues/$issue/labels/kdave ACK"
gh api -X DELETE "repos/$repo/issues/$issue/labels/josef ACK"
gh api -X DELETE "repos/$repo/issues/$issue/labels/kdave COMMENTS"
gh api -X DELETE "repos/$repo/issues/$issue/labels/josef COMMENTS"