Github mono repo 成员访问

Github mono repo member access

我们有一个使用 NX 工作区的 UI 单声道存储库,我们正在与多个 teams.Is 共享代码

  1. 只允许团队成员访问他们拥有的模块?
  2. 要创建模块所有者可以查看和批准的 PR(仅限团队)?
  1. 不,读取权限 = 整个存储库。如果您使用的是单声道存储库,则读取访问权限为全部或无访问权限。参见:Information about Managing Teams

  2. PR 的读取权限与上面相同,但是您可以要求某些组的 PR 批准者在合并到特定分支时包含某些路径。参见 Information about Code Owners and Protected Branches

不,没有办法限制对存储库的一部分的访问。 Git 文档非常清楚,任何可以读取或写入存储库的人都可以访问该存储库的所有内容。来自 gitnamespaces(7) 手册页:

The fetch and push protocols are not designed to prevent one side from stealing data from the other repository that was not intended to be shared. If you have private data that you need to protect from a malicious peer, your best option is to store it in another repository. This applies to both clients and servers.

如果您需要精细权限,则需要多个存储库。我通常建议不要使用 monorepos,因为它们通常最终会变得非常大,然后性能很差(在修复为时已晚之后),但这也是它们不是一个好主意的另一个原因。

至于模块所有者可以批准的PR,这取决于平台。 GitHub 有 CODEOWNERS 文件,可用于强制某些团队拥有的文件需要该团队的审查。