如要修改個別存放區的 GitHub 專用 Gemini Code Assist 行為,請在存放區根目錄的 .gemini/ 資料夾中新增 config.yaml 檔案。config.yaml 檔案包含各種可設定的功能,您可以啟用或停用這些功能。您可以跨多個存放區執行群組設定,為 GitHub 專用 Gemini Code Assist 的部分行為設定群組。
Gemini Code Assist 也支援在 .gemini/ 資料夾中新增 styleguide.md 檔案,指示 Gemini Code Assist 在執行程式碼審查時遵循特定規則。如要進一步瞭解 Gemini Code Assist 的風格指南,請參閱程式碼審查風格指南。
設定欄位
本節說明 GitHub 專用 Gemini Code Assist 中特定可自訂欄位的注意事項。如需完整欄位清單,請參閱 config.yaml 結構定義。
code_review: comment_severity_threshold:這個欄位會設定 Gemini Code Assist 發布註解的最低嚴重程度。舉例來說,如果已設定code_review: comment_severity_threshold: HIGH,Gemini Code Assist 就不會針對它認為屬於LOW或MEDIUM嚴重程度的問題提供提取要求註解,例如次要重構。Gemini Code Assist 會根據考量的問題類型和重要性,判斷註解的嚴重程度,通常違反自訂風格指南的註解會達到或超過嚴重程度門檻。ignore_patterns:這個欄位使用 glob 模式。與存放區互動時,Gemini Code Assist 會忽略符合這份清單中任何模式的檔案。memory_config:如果您先前已為多個存放區啟用提升回覆品質功能,則適用此欄位。為多個存放區啟用提升回覆品質功能後,您可以為群組中的特定存放區設定memory_config: disabled: true,停用該存放區的功能。
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. 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. 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.
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: []
管理多個存放區的設定
您可以在多個存放區中管理 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 原始碼管理) 窗格隨即開啟。
在「連線」表格中,按一下要套用設定的連線名稱。
系統會開啟連線的詳細資料頁面。
在「設定」分頁中,更新要變更的設定。
按一下 [儲存]。