Skip to content

Instantly share code, notes, and snippets.

@larsks
Created September 16, 2021 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsks/e58439f472fb10dfcbfb0ca224703a6b to your computer and use it in GitHub Desktop.
Save larsks/e58439f472fb10dfcbfb0ca224703a6b to your computer and use it in GitHub Desktop.
A tool for showing your issues and review requests
#!/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