-
Notifications
You must be signed in to change notification settings - Fork 1
/
get-removed-labels
executable file
·67 lines (62 loc) · 1.39 KB
/
get-removed-labels
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
#!/bin/bash
# Function to display usage
usage() {
echo "Usage: $0 -o owner -n name -p pr_number"
exit
}
# Parse command-line arguments
while getopts ":o:n:p:" opt; do
case $opt in
o)
owner="$OPTARG"
;;
n)
name="$OPTARG"
;;
p)
pr_number="$OPTARG"
;;
\?)
echo "Invalid option -$OPTARG" >&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
# Check if all required arguments are provided
if [ -z "$owner" ] || [ -z "$name" ] || [ -z "$pr_number" ]; then
usage
fi
response=$(
gh api graphql \
--paginate \
-F number=$pr_number -F owner=$owner -F name=$name \
-f query='
query($endCursor: String, $owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
timelineItems(first: 5, after: $endCursor) {
nodes {
__typename
... on UnlabeledEvent {
label {
name
}
}
}
pageInfo {
endCursor
hasNextPage
}
}
}
}
}
' --jq '.data.repository.pullRequest.timelineItems.nodes
| map(select(.__typename == "UnlabeledEvent") | .label.name)
'
)
echo $response | jq -s 'add | unique'