9

Is it possible to get a list of pull requests that have touched any file under a given directory?

The other day, I had to wade through dozens of pull requests from the past several months and collect all the ones that had touched any file in under a particular path of interest.

I tried to search PRs using the file path on GitHub, but it didn't seem like file paths were indexed. Poking around a bit further, I couldn't really find a solution for file searching in pull requests, which was sort of surprising. I eventually had to go through the commit history of various directories and collect the related PRs, but it was fairly tedious.

Is there any support for summarizing PRs by affected files in GitHub? Perhaps this is something the API is capable of?

TheMadDeveloper
  • 1,587
  • 15
  • 28

2 Answers2

2
git log --merges --first-parent -- <file>

will show you commits that merged in changes to specific files. Since you use PR's to merge files chances are that this will be sufficient.

If this is not the case, however, and you have additional merge commits on the mainline that aren't PR's, you may need to use a combination of the --author=<pattern>, --committer=<pattern>, and --grep=<pattern> flags to further filter the output:

   --author=<pattern>, --committer=<pattern>
       Limit the commits output to ones with author/committer header lines that match
       the specified pattern (regular expression). With more than one
       --author=<pattern>, commits whose author matches any of the given patterns are
       chosen (similarly for multiple --committer=<pattern>).

   --grep=<pattern>
       Limit the commits output to ones with log message that matches the specified
       pattern (regular expression). With more than one --grep=<pattern>, commits whose
       message matches any of the given patterns are chosen (but see --all-match).

       When --show-notes is in effect, the message from the notes is matched as if it
       were part of the log message.
Pockets
  • 1,186
  • 7
  • 12
  • That's command-line `git`, not an ideal answer to a question that is (I believe) specific to the web interface to GitHub. Still, thank you. – Graham Perrin Oct 23 '22 at 19:01
0

I just had the same question, you can just search for the path in the PR filter:

Github PR

dArignac
  • 1,205
  • 4
  • 11
  • 25