Created
September 16, 2021 15:38
-
-
Save larsks/e58439f472fb10dfcbfb0ca224703a6b to your computer and use it in GitHub Desktop.
A tool for showing your issues and review requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
: ${GH_ORG:=CCI-MOC} | |
if ! type -p gh > /dev/null; then | |
echo "ERROR: missing gh cli (https://github.com/cli/cli)" >&2 | |
exit 1 | |
fi | |
if ! type -p jq > /dev/null; then | |
echo "ERROR: missing jq command (https://stedolan.github.io/jq/)" >&2 | |
exit 1 | |
fi | |
tmpfile=$(mktemp /tmp/ghXXXXXX) | |
trap "rm -f $tmpfile" EXIT | |
gh api -X GET /search/issues -f q="is:open ${GH_ORG:+org:$GH_ORG} assignee:@me" > $tmpfile | |
if [[ $(jq -r '.total_count' < $tmpfile) -gt 0 ]]; then | |
echo "$(tput setaf 1)Issues$(tput sgr0)" | |
echo | |
jq -r '.items[]|[.repository_url,.number,.html_url,.title] | @tsv' < $tmpfile | | |
sort -t $'\t' -k1,1 -k 2n,2 | | |
awk -F $'\t' 'BEGIN {OFS="\t"} {print $3, $4}' | | |
column -t -s $'\t' | |
else | |
echo "$(tput setaf 2)No issues.$(tput sgr0)" | |
fi | |
gh api -X GET /search/issues -f q='is:open org:CCI-MOC review-requested:@me' > $tmpfile | |
if [[ $(jq -r '.total_count' < $tmpfile) -gt 0 ]]; then | |
echo | |
echo "$(tput setaf 1)Review requests$(tput sgr0)" | |
echo | |
jq -r '.items[]|[.repository_url,.number,.html_url,.title] | @tsv' < $tmpfile | | |
sort -t $'\t' -k1,1 -k 2n,2 | | |
awk -F $'\t' 'BEGIN {OFS="\t"} {print $3, $4}' | | |
column -t -s $'\t' | |
else | |
echo | |
echo "$(tput setaf 2)No review requests.$(tput sgr0)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment