Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Open Pull Request associated with a commit id
#!/bin/sh
# Required: hub, jq
commit=$1
pr=$(hub api graphql -F query="
{
repository(name: \"{repo}\", owner: \"{owner}\") {
commit: object(expression: \"$commit\") {
... on Commit {
associatedPullRequests(first: 1) {
edges {
node {
number
}
}
}
}
}
}
}" | jq '.data.repository.commit.associatedPullRequests.edges[].node.number')
if [ ! -z "$pr" ]; then
hub browse -- pull/$pr
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.