github - Github 中的 CODEOWNERS 没有按预期工作

标签 github

问题:CODEOWNERS 需要完全限定的路径来对目录/子目录进行规则。

我正在编写下面的代码示例来说明问题。

* @global-owner
foo/bar/ @octocat

我期望每当对目录 foo/bar 中的任何文件(甚至递归地)提出 PR 时,都应该为用户分配评论。但是,这始终默认为 * 规则。

但是,当我将文件更改为如下内容时:

* @global-owner
/app/src/main/java/com/cueo/foo/bar/ @octocat

这就像一个魅力。但问题是我需要将每个目录重复两次,如下所示:

/app/src/main/java/com/cueo/foo/bar/ @octocat
/app/src/test/java/com/cueo/foo/bar/ @octocat

根据文档:

# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
apps/ @octocat

我相信这也适用于嵌套目录结构,例如:

foo/bar/apps/ @octocat

最佳答案

我们还需要在路径前加上**。这在文档中并不清楚。

所以如果我们添加如下规则:

* @global-owner
**/foo/bar/ @octocat

@octocat 将分配给项目中的所有 foo/bar 目录。

关于github - Github 中的 CODEOWNERS 没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60107744/

相关文章:

java - Git Hub Actions 使用 Maven 对其他存储库的私有(private)包注册表进行身份验证

git - 即使我将工作分支 merge 到 master,master 也 merge 到工作分支

git - JGit HTTPS 克隆不起作用

git push错误 "error: src refspec xxx does not match any."使用git flow

python - 在 Google Colab 中编辑 README.md 文件

github - 如何将 GitHub 问题和 PRs 包含在 API 触发的 repo 导入到 GitLab 中?

git - 如何将分支从一个存储库移动到不同存储库的另一个分支

github - 获取我们所有私有(private)仓库的列表

python - 如何仅使用 python-requests 在 Github 中获取最新版本?

python - 使用 GitHub 上的 pip install -e 时出现格式错误。使用#egg 的值(value)?