11

Let's assume I found a typo in some project's file. The project has a lot of open pull requests¹, so it's not practical to manually search through the pull requests to see if any of them contain a fix for this typo.

Is there a way to see all pull requests that change the regarding file, or better yet the regarding line?

¹ E.g., take Docker, which has 98 open pull requests at the time of this writing.

2 Answers 2

7

Hopefully by now you've found an answer to your question, but if not (or if anyone else has the same question) you can search a repo's open pull requests for a word or phrase -- the file name, for example, or the typo corrected, or the line that it appears on.

To search open pull requests, use the following search query:

is:pr is:open "phrase to search for"

Searching the Docker pull requests for "fix typo" right now returns 1 result.

2
  • 2
    Unfortunately, this approach is not entirely reliable where specification of the name of a file is exact. Please see <github.com/orgs/community/discussions/…> under find PRs that update a file · Discussion #36946 · community. Commented Oct 23, 2022 at 19:16
  • 1
    This doesn't seem to work for me for finding PRs touching a specific file, in my case file path: client/src-shared/TgSequenceEditor
    – tnrich
    Commented Sep 15, 2023 at 18:15
1

Here's a little script I cobbled together to solve a similar issue:

#grab all the PRs and sort them so the newest ones are first in the list:
git ls-remote origin 'pull/*/head' | awk '{print $2}' | grep -oE '[0-9]+' | sort -n | tail -r |
#read each PR and filter for any that have changed file in question 
while read pr; do
  echo "Searching $pr"
  if gh pr view $pr --json files --jq '.files.[].path' | grep -q "yourFileNameHere"; then
    echo "Found in PR $pr - $(gh pr view $pr --json state --jq '.state')" 
  fi
done

(btw you'll need the github cli tool gh - https://cli.github.com/)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.