This same question is treated in the Stack Overflow post
Is there a way to see what pending pull requests affect a particular file?
I reproduce below the
answer by larsks
for this question.
ElpieKay's answer is basically what I was suggesting in my comment; this answer has an example shell script that would largely automated the process.
It turns out that it is fairly easy to get a list of open pull requests; you can just the following curl command line to get a JSON list of open requests:
curl https://api.github.com/repos/<user>/<repo>/pulls
For example:
curl https://api.github.com/repos/centos-opstools/opstools-ansible/pulls
You can then extract the pull request numbers from that using something like jq (the -s argument to curl just suppresses some status output that you get when piping curl output to another command):
curl -s https://api.github.com/repos/centos-opstools/opstools-ansible/pulls |
jq '.[]|.number'
You could then take the output of that command and pipe it into a loop to fetch just those pull requests and inspect them for a file of interest:
curl -s https://api.github.com/repos/centos-opstools/opstools-ansible/pulls |
jq '.[]|.number' |
while read pr; do
git fetch --quiet origin refs/pull/$pr/head
if git show --pretty=format:'' --name-only FETCH_HEAD | grep -q $file_i_care_about; then
echo "PR $pr"
fi
done
Which would yield output like:
PR 82
PR 71
PR 69
The above assumes that the variable file_i_care_about is a variable containing the file in which you are interested.
git initfollowed bygit remote? – pgr Aug 11 '22 at 14:09per_pageoption I can increase that to 100, but I'd still have to deal with several API requests, and look at them one by one. Very inefficient for such a large repo with thousands of PRs like the one I work with most of the time. I opened a feature request for Github-cli regarding this: https://github.com/cli/cli/issues/6642 – pgr Nov 19 '22 at 16:26