如要修改 GitHub 上的 Gemini Code Assist 行為,請在存放區根目錄的 .gemini/ 資料夾中新增 config.yaml 檔案。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.
管理多個存放區的設定
您可以在多個存放區中管理 GitHub 上的 Gemini Code Assist 某些功能:
如果您使用個人版,可以為與帳戶相關聯的所有存放區切換特定設定。
如果您使用企業版,可以為透過 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」頁面中,選取要使用的帳戶,然後查看服務條款,並點選「繼續」。
在「Free agent」頁面中,視需要更新設定。
按一下 [儲存]。
Enterprise
在 Google Cloud 控制台中,前往 Gemini Code Assist 的「Agents & Tools」頁面。
在「代理程式」部分中,找到「Code Assist 原始碼管理」資訊卡,然後按一下「進階」。
「Edit Code Assist Source Code Management」(編輯 Code Assist 原始碼管理) 窗格隨即開啟。
在「連線」表格中,按一下要套用設定的連線名稱。
系統會開啟連線的詳細資料頁面。
在「設定」分頁中,更新要變更的設定。
按一下 [儲存]。