Search code examples
githubgithub-api

GitHub API (directory where the project is located in this pull request)


I have a question. I'm iterating over a pull request via the GitHub API. Each pull request is a separate branch with a separate project. Each has a unique directory.

Can I somehow find out the directory where the project is located in this pull request with GitHub API?


Solution

  • You will have to list the commits of the pull request (see List commits on a pull request).

    You will then need to fetch each commit (see Get a commit) and look at the files property to see what has been modified.

    Once you have a list of files being modified in the commit, you should be able to parse out the directory to determine the project(s) associated with the pull request.

    It sounds like you are working out of a monorepo (i.e., a repository with multiple projects in it). It is worth noting that there is nothing in Git or GitHub that will prevent people from modifying multiple projects in a single pull request.