您可以通过在代码库根目录的 .gemini/ 文件夹中添加 config.yaml 文件来修改 GitHub 中的 Gemini Code Assist 行为。config.yaml 文件包含各种可配置的功能,您可以启用或停用这些功能,包括使用 glob 模式指定要忽略的文件。
Gemini Code Assist 还支持向 .gemini/ 文件夹添加 styleguide.md 文件,该文件会指示 Gemini Code Assist 在执行代码审核时遵循一些特定规则。如需详细了解 Gemini Code Assist 的样式指南,请参阅代码审核样式指南。
config.yaml 示例
以下代码段是 config.yaml 文件的一个示例。在此示例中,每个属性都设置为 Gemini Code Assist 使用的默认值。您可以使用以下代码段作为模板来创建自己的 config.yaml 文件:
have_fun: false
memory_config:
disabled: false
code_review:
disable: false
comment_severity_threshold: MEDIUM
max_review_comments: -1
pull_request_opened:
help: false
summary: true
code_review: true
include_drafts: true
ignore_patterns: []
config.yaml 个架构
以下代码段是 config.yaml 文件的架构。它定义了所有可能的配置选项及其接受的值:
$schema: "http://json-schema.org/draft-07/schema#" title: RepoConfig description: Configuration for Gemini Code Assist on a repository. All fields are optional and have default values. type: object properties: have_fun: type: boolean description: Enables fun features such as a poem in the initial pull request summary. Default: false. ignore_patterns: type: array items: type: string description: A list of glob patterns for files and directories that Gemini Code Assist should ignore. Files matching any pattern in this list will be skipped during interactions. Default: []. memory_config: type: object description: Configuration for persistent memory, which is used to improve responses. properties: disabled: type: boolean description: Whether to disable persistent memory for this specific repository, if Improve response quality has been enabled for multiple repositories. Default: false. code_review: type: object description: Configuration for code reviews. All fields are optional and have default values. properties: disable: type: boolean description: Disables Gemini from acting on pull requests. Default: false. comment_severity_threshold: type: string enum: - LOW - MEDIUM - HIGH - CRITICAL description: The minimum severity of review comments to consider. Default: MEDIUM. max_review_comments: type: integer format: int64 description: The maximum number of review comments to consider. Use -1 for unlimited. Default: -1. pull_request_opened: type: object description: Configuration for pull request opened events. All fields are optional and have default values. properties: help: type: boolean description: Posts a help message on pull request open. Default: false. summary: type: boolean description: Posts a pull request summary on the pull request open. Default: true. code_review: type: boolean description: Posts a code review on pull request open. Default: true. include_drafts: type: boolean description: Enables agent functionality on draft pull requests. Default: true.
管理多个代码库中的配置
Gemini Code Assist on GitHub 的某些方面可以在多个代码库中进行管理:
如果您使用的是消费者版,则可以为与账号关联的所有代码库切换某些设置。
如果您使用的是企业版,则可以针对通过 Developer Connect 连接分组的多个代码库切换某些设置。在这种情况下,您可以通过 Google Cloud 控制台管理这些账号的集体设置。
如果某个代码库作为群组的一部分进行管理,但也有自己的 config.yaml,则该代码库的 config.yaml 设置会覆盖群组设置。
如需了解具体的设置行为和例外情况,请查看 config.yaml 架构。
以下步骤展示了如何跨多个代码库控制一组配置。以下步骤假定您之前已在 GitHub 上设置 Gemini Code Assist。
使用方
在 Gemini Code Assist 中,前往设置页面。
如果系统提示,请点击 Log in with GitHub,然后按照提示在 Gemini Code Assist 中登录 GitHub。
在 Gemini 页面中,选择要使用的账号,查看服务条款,然后点击继续。
在自由代理页面中,根据需要更新设置。
点击保存。
企业
在 Google Cloud 控制台中,前往 Gemini Code Assist 代理和工具页面。
在代理部分中,找到 Code Assist 源代码管理卡片,然后点击高级。
系统会打开 Edit Code Assist Source Code Management 窗格。
在连接表格中,点击要应用配置的连接的名称。
系统会打开相应连接的详情页面。
在设置标签页中,更新您要更改的设置。
点击保存。