Created
November 26, 2025 15:07
-
-
Save uhbif19/ecab7a055d886354bf91fb58a43ad575 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/zsh | |
| # find-pr.sh - Find GitHub PR for a given commit hash | |
| # Check if gh is installed | |
| if ! command -v gh &> /dev/null; then | |
| echo "GitHub CLI 'gh' not found. Please install it from https://cli.github.com/" | |
| exit 1 | |
| fi | |
| # Check for commit sha argument | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 <commit-sha>" | |
| echo "This script expects the commit SHA as the first argument." | |
| exit 1 | |
| fi | |
| COMMIT_SHA=$1 | |
| # Use gh search to find the PR and format the output | |
| PRS=$(gh search prs "$COMMIT_SHA" --json number,title,url --jq '.[] | "#\(.number) \(.title) - \(.url)"') | |
| if [ -z "$PRS" ]; then | |
| echo "No PR found for commit $COMMIT_SHA" | |
| else | |
| echo "Found PR(s) for commit $COMMIT_SHA:" | |
| echo "$PRS" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment