-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-prs
executable file
·33 lines (21 loc) · 906 Bytes
/
list-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
#!/bin/bash
USAGE="Lists open pull requests for all repositories.\n"
USAGE+="Usage: albert list-prs"
([[ "$1" == "help" ]] || [[ "$2" == "help" ]] ) && { echo -e "$USAGE"; exit 0; }
MY_DIR="$(dirname "$0")"
source "$MY_DIR/util"
check_access_token
REPO_NAMES=$(get_repos)
for REPO in $REPO_NAMES; do
PULL_REQUESTS=$(http GET "https://api.github.com/repos/AutoScout24/$REPO/pulls?status=open&access_token=$ACCESS_TOKEN" | jq "map(select(.title))")
PR_COUNT=$(echo "$PULL_REQUESTS" | jq "length")
if [[ $PR_COUNT -gt 0 ]]; then
echo "$(tput bold)$(tput setaf 3)PRs in $REPO$(tput sgr0)"
echo -en "$(tput bold)"
echo "$PULL_REQUESTS" |
jq -r ".[0:$PR_COUNT] | .[] | (.title + \"\t\" + .html_url + \"\t\" + .user.login + \"\t\" + .created_at)" |
column -t -s $'\t' | gsed 's/^/ /'
echo -en "$(tput sgr0)"
echo
fi
done;