GitHub API(此拉取请求中项目所在的目录)

huangapple go评论65阅读模式
英文:

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

问题

我有一个问题。我正在使用GitHub API遍历一个拉取请求。每个拉取请求是一个单独的分支,对应一个独立的项目。每个项目都有一个唯一的目录。

我能通过GitHub API找出这个拉取请求中项目所在的目录吗?

英文:

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?

答案1

得分: 0

你需要列出拉取请求的提交记录(参见列出拉取请求上的提交记录)。

然后,你需要获取每个提交(参见获取提交)并查看files属性,以查看进行了哪些修改。

一旦你得到了在提交中被修改的文件列表,你应该能够解析出目录,从而确定与拉取请求相关联的项目。

听起来你正在处理一个多项目的单一代码库(即,一个包含多个项目的仓库)。值得注意的是,在Git或GitHub中并没有阻止人们在单个拉取请求中修改多个项目的机制。

英文:

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.

huangapple
  • 本文由 发表于 2023年3月9日 17:08:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75682451.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定