Skip to content

Instantly share code, notes, and snippets.

@rwilcox
Last active August 20, 2019 15:20
Show Gist options
  • Save rwilcox/6064298 to your computer and use it in GitHub Desktop.
Save rwilcox/6064298 to your computer and use it in GitHub Desktop.
View all comments, even outdated ones, for a PR on Github
#!/opt/local/bin/zsh
# NOTE: requires ZSH for vered. If you're using another shell you'll need to set PULL_NUMBER, ORGANIZATION and REPO
# somehow yourself
# also depends on the jgrep gem (jgrep for "json grep"). jgrep respects object structure and lets
# me search for _links.html.href
GITHUB_USERNAME=rwilcox
GITHUB_PASSWORD=hahahahaha
JGREP=/opt/local/bin/jgrep
PULL_NUMBER=42
ORGANIZATION=rwilcox
REPO=school_days
if [[ ($ZSH_NAME = "zsh") && (-z $BBEDIT_CLIENT_INTERACTIVE) ]]; then
# ZSH_NAME is set when a zsh shell is spawned. Better than $SHELL because the
# user might not be running zsh as their current shell
vared -p "Enter pull request number: " PULL_NUMBER
vared -p "Enter the organization/user name: " ORGANIZATION
vared -p "Enter repo name: " REPO
fi
curl --user "$GITHUB_USERNAME:$GITHUB_PASSWORD" \
--request GET \
https://api.github.com/repos/$ORGANIZATION/$REPO/pulls/$PULL_NUMBER/comments | $JGREP -s "body diff_hunk user.login _links.html.href path original_position position" | perl -i -p -e 's/\\n/\n/g' | fold -w 80 -s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment