Last active
January 13, 2016 16:25
-
-
Save exupero/4540806 to your computer and use it in GitHub Desktop.
Getting the pull request for a branch with Python and Jq.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
for p in json.load(sys.stdin): | |
if p['head']['ref'] == sys.argv[1]: | |
print p['html_url'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jq -r ".[] | select(.head.ref == \"$1\") | .html_url" |
@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
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