Peter Lyons

Check for Pull Requests in All Your Repos

June 09, 2016

My current work involves many microservice (ish) node.js projects. Each has its own git repository hosted on github. My team follows a pull request workflow requiring all code to hit our main branch via pull request. We have slack chat integration so we can see when a new pull request is created, but even with that I found myself confused about whether or not there were any pending pull requests that I needed to review.

Scripting to the rescue! Here's what I did to quickly see a list of each repository and the title of each pending pull request. I hacked this together with cURL, an npm command line module named json, and a few lines of shell scripts. Here's the breakdown:

Now you're ready to add this shell script to your shell profile:

check_pull_requests() {
  local organization="YourGithubOrg" # Edit this
  for repo in repo-1 repo-2 repo-3 repo-4; do # Edit this repo list
    echo "* ${repo}"
    curl \
      --silent \
      --header "Authorization: token $(cat ~/.github-pr-status-token.txt)" \
      "${organization}/${repo}/pulls" \
      | json -a title html_url

The output will look something like this:

* repo-1
Update config for Heroku
* repo-2
* repo-3
Fix Bug #42
* repo-4

I hope you find this useful. Get those PRs reviewed quickly!