GitHub and GitLab support CODEOWNERS files. This file specifies the users responsible for developing and maintaining software and documentation. This definition can apply to the entire repository, specific directories, or to individual files. To learn more:
GitHub 和 GitLab 支持 CODEOWNERS 文件。此文件指定负责开发和维护软件和文档的用户。此定义可应用于整个存储库、特定目录或单个文件。要了解更多信息
Use the CodeOwners
method on a Page
object to determine the code owners for the given page.
使用对象CodeOwners上的方法Page来确定给定页面的代码所有者。
To use the CodeOwners
method you must enable access to your local Git repository:
enableGitInfo: true
enableGitInfo = true
{
"enableGitInfo": true
}
Consider this project structure:
my-project/
├── content/
│ ├── books/
│ │ └── les-miserables.md
│ └── films/
│ └── the-hunchback-of-notre-dame.md
└── CODEOWNERS
And this CODEOWNERS file:
* @jdoe
/content/books/ @tjones
/content/films/ @mrichards @rsmith
The table below shows the slice of code owners returned for each file:
Path | Code owners |
---|---|
books/les-miserables.md |
[@tjones] |
films/the-hunchback-of-notre-dame.md |
[@mrichards @rsmith] |
Render the code owners for each content page:
{{ range .CodeOwners }}
{{ . }}
{{ end }}
Combine this method with resources.GetRemote
to retrieve names and avatars from your Git provider by querying their API.
结合此方法,resources.GetRemote通过查询 Git 提供商的 API 来检索名称和头像。