Created
November 29, 2019 03:44
-
-
Save itkrt2y/066ee4de3e00cb28e960a9e6a9334869 to your computer and use it in GitHub Desktop.
Open Pull Request associated with a commit id
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
#!/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