-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetopenPRs.10m.sh
81 lines (65 loc) · 14.1 KB
/
getopenPRs.10m.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# shellcheck disable=SC2034
# shellcheck disable=SC2154
# shellcheck source=/dev/null
# <bitbar.title>Bitbucket Pull Requests</bitbar.title>
# <bitbar.version>1.0</bitbar.version>
# <bitbar.author>Mikey Beck</bitbar.author>
# <bitbar.author.github>mikeybeck</bitbar.author.github>
# <bitbar.desc>Shows Bitbucket open pull request information</bitbar.desc>
# <bitbar.image>https://raw.githubusercontent.com/mikeybeck/bitbar-bitbucketPRs/master/screenshot.png</bitbar.image>
# <bitbar.dependencies>jq</bitbar.dependencies>
# <bitbar.abouturl>https://github.com/mikeybeck/bitbar-bitbucketPRs</bitbar.abouturl>
# Relevant documentation for BitBucket: http://web.archive.org/web/20150530151816/https://confluence.atlassian.com/display/BITBUCKET/pullrequests+Resource#pullrequests
USERNAME=
PASSWORD=
REPO_OWNER=
REPO_SLUG=
NUM_APPROVALS_REQ=2 # Number of approvals required for pull request
# Export PATH
export PATH="/usr/local/bin:/usr/bin:$PATH"
# Base64 icon to use in system bar
icon="iVBORw0KGgoAAAANSUhEUgAAAQcAAAEmCAYAAABvW1U0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xO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z+eTWIDb8xmcGev4Sp45/t/AVL9dQ7qDO64AAAAAElFTkSuQmCC"
response=$(curl -s -X GET --user $USERNAME:$PASSWORD "https://bitbucket.org/api/2.0/repositories/$REPO_OWNER/$REPO_SLUG/pullrequests/")
json=$(echo $response | jq -r -c '[.values[] | {title: .title, author: .author.display_name, num_comments: .comment_count, link_html: .links.html.href, link_status: .links.statuses.href, link_self: .links.self.href}]')
prs=$(echo $response | jq -r -c '(.size|tostring)')
num_approved_by_me=0
declare -a lines
for pr in $(echo "${json}" | jq -r '.[] | @base64'); do
_jq() {
echo ${pr} | base64 --decode | jq -r ${1}
}
build_state=$(curl -s -X GET --user $USERNAME:$PASSWORD $(_jq '.link_status') | jq -r '.values[].state')
self=$(curl -s -X GET --user $USERNAME:$PASSWORD $(_jq '.link_self'))
num_approvals=$(echo $self | jq -r '[select(.participants[].approved)] | length')
colour="red"
if [[ $build_state == "SUCCESSFUL" ]]; then
colour="green" # Colour to show if PR is good to go (approved & build passed)
if [ "$num_approvals" -lt "$NUM_APPROVALS_REQ" ]; then
colour="black" # Colour to show if PR build passed but not approved
fi
fi
approved_by_me=$(echo $self | jq -r --arg USERNAME "$USERNAME" '.participants[] | select(.user.username == $USERNAME) | .approved')
if [[ $approved_by_me == "true" ]]; then
approved_by_me=":heavy_check_mark:"
((num_approved_by_me++))
else
approved_by_me="-"
fi
line=$(echo "$approved_by_me " $(_jq '.author') '-' $(_jq '.title') " ┃ :heavy_check_mark: $num_approvals ┃ :speech_balloon: $(_jq '.num_comments')" "| href=$(_jq '.link_html') color=$colour")
lines+=("$line")
done
# Print everything out
num_unapproved_by_me=$((prs - num_approved_by_me))
echo $prs "/" $num_unapproved_by_me " | templateImage=$icon dropdown=false" # Display number of PRs in menu bar
# if [[ $num_unapproved_by_me != 0 ]]; then
# echo "($num_unapproved_by_me unapproved) | dropdown=false" # Cycle number of PRs not approved by me in menu bar, if > 0
# fi
echo "---"
echo "View all open pull requests | href=https://bitbucket.org/$REPO_OWNER/$REPO_SLUG/pull-requests/"
echo "---"
for line in "${lines[@]}"
do
echo "$line" # Display open PRs in dropdown
done