-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist-all-my-open-prs
executable file
·66 lines (59 loc) · 1.88 KB
/
list-all-my-open-prs
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
#!/bin/sh
#
# List all my open prs.
exec rest bitbucket get '/rest/api/latest/dashboard/pull-requests?limit=999&role=author&state=open' 2>/dev/null |
exec jq -r --unbuffered '
.values[] |
[
.fromRef.latestCommit,
(.id | tostring) + "/" + (.version | tostring),
(.updatedDate / 1000 | strftime("%Y-%m-%d_%H:%M:%S")),
(.properties.commentCount // 0 | tostring) + "," + (.properties.openTaskCount | tostring),
.toRef.repository.project.key + "/" + .toRef.repository.slug + ":" + .toRef.displayId,
(
(.title | gsub("\\s"; "_")) as $title |
if (.title | length) <= 51
then $title
else $title[0:49] + "…"
end
)
] |
@sh
' |
exec xargs -n 6 -P 0 -- sh -c '
test -n "$1" ||
exit 0
build=$(
exec rest bitbucket get \
"/rest/build-status/latest/commits/$1" \
2>/dev/null |
exec jq -r "
.values[0].state as \$state |
if \$state == \"SUCCESSFUL\"
then \"B\"
elif \$state == \"FAILED\"
then \"F\"
else \"R\"
end
"
)
repo=${5#*/}
repo=${repo%%:*}
merge=$(
exec rest bitbucket get \
"/rest/api/latest/projects/${5%%/*}/repos/$repo/pull-requests/${2%%/*}/merge" \
2>/dev/null |
exec jq -r "
if .canMerge
then \"M\"
elif .conflicted
then \"C\"
else \"V\\(.vetoes | length)\"
end
"
)
echo "$2" "$3" "$merge,${build:-?}" "$4" "$5" "$6"
' -- |
exec sort -k 2,2 |
exec column -t
# vim: set ft=sh :