Skip to content

Instantly share code, notes, and snippets.

@exupero
Last active January 13, 2016 16:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exupero/4540806 to your computer and use it in GitHub Desktop.
Save exupero/4540806 to your computer and use it in GitHub Desktop.
Getting the pull request for a branch with Python and Jq.
import json
import sys
for p in json.load(sys.stdin):
if p['head']['ref'] == sys.argv[1]:
print p['html_url']
jq -r ".[] | select(.head.ref == \"$1\") | .html_url"
@ozbillwang
Copy link

Get here from url http://spin.atomicobject.com/2013/01/27/json-command-line-jq/.

It seems useful, but could you please paste sample input file, then I can understand where .head.ref and .html_url come from.

Thanks a lot

@ye
Copy link

ye commented Jan 13, 2016

@SydOps Github API documentation for Pull Request has abundant example JSONs for you to consume and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment