Skip to content

Instantly share code, notes, and snippets.

@hughrawlinson
Created July 30, 2016 18:54
Show Gist options
  • Save hughrawlinson/51a696c3cfc75236232ef29992b0fb7e to your computer and use it in GitHub Desktop.
Save hughrawlinson/51a696c3cfc75236232ef29992b0fb7e to your computer and use it in GitHub Desktop.
Get a list of important issues from a GitHub repo
#!/bin/bash
# A program to parse GitHub issues as a list sorted by engagement
HELP="Get a list of important issues from a GitHub repo
Usage: importantIssues.sh repo user [count sort]
repo: GitHub repo containing the issues
user: GitHub user/org containing the repo
count: Number of issues to return
sort: If defined will reverse sort by comment count + reactions count"
REPO=${1}
USER=${2}
MAX_ISSUES=${3-10000}
if [ -n ${4} ]; then
REVERSE="-r"
fi;
if [ -z $REPO ] || [ $REPO == "--help" ] || [ $REPO == "-h" ]; then
echo "$HELP"
exit 0
fi
URL="https://api.github.com/repos/$USER/$REPO/issues?per_page=$MAX_ISSUES&sort=comments&state=open"
# GitHub doesn't let you sort by reactions yet, so in the event that you're
# querying for fewer than the total number of open issues
curl -s -H "Accept: application/vnd.github.squirrel-girl-preview" $URL | jq --raw-output '.[] | [.comments+.reactions.total_count, (.title|@json), "#"+(.number|tostring)] | @csv' | sort -t, -n -k1 $REVERSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment