組織として GitHub Copilot を提供するところもだいぶ増えてきましたね。
組織利用の場合、使える機能を制限するポリシー設定なども重要ですが、その他に設定項目として「Content Exclusion」というものがあるのをご存知でしょうか。
その名の通り、リポジトリ・組織ごとに設定したパスルールに従って、該当したファイルではコード入力補完などをさせないようにすることができる というもの。
(2024年7月23日時点では Beta 機能となっていますが、問題なく動作します。機能的な留意点については後述します。)
ローカル検証用の .env など、 Copilot には食わせたくないファイルを除外しておくと、幾分か心の平穏が得られます。リポジトリ管理者や組織オーナーは利用を検討しましょう。
以下、設定のための基本的な情報をメモします。
リポジトリの Settings でのコンテンツ除外
リポジトリの [Settings] -> Code and automation 内 [Copilot] から設定可能。
以下、Example of paths specified in the repository settings | Github より引用したサンプル。
# Ignore the `/src/some-dir/kernel.rs` file in this repository.
- "/src/some-dir/kernel.rs"
# Ignore files called `secrets.json` anywhere in this repository.
- "secrets.json"
# Ignore all files whose names begin with `secret` anywhere in this repository.
- "secret*"
# Ignore files whose names end with `.cfg` anywhere in this repository.
- "*.cfg"
# Ignore all files in or below the `/scripts` directory of this repository.
- "/scripts/**"
パターンマッチングは、パターンマッチングは Ruby の fnmatch 形式とのこと。
組織の Settings でのコンテンツ除外
組織の [Settings] -> Code, planning, and automation 内 [Copilot] から設定可能。
組織の設定では、全リポジトリ共通の定義の他、特定リポジトリにのみ適用するルールも設定することができる。
以下、Example of repositories and paths in organization settings | Github より引用したサンプル。
# Ignore all `.env` files at any path, in any repository.
# This setting applies to all repositories, not just to those on GitHub.com.
# This could also have been written on a single line as:
#
# "*": ["**/.env"]
"*":
- "**/.env"
# In the `octo-repo` repository in this organization:
octo-repo:
# Ignore the `/src/some-dir/kernel.rs` file.
- "/src/some-dir/kernel.rs"
# In the `primer/react` repository on GitHub:
https://github.com/primer/react.git:
# Ignore files called `secrets.json` anywhere in this repository.
- "secrets.json"
# Ignore files called `temp.rb` in or below the `/src` directory.
- "/src/**/temp.rb"
# In the `copilot` repository of any GitHub organization:
git@github.com:*/copilot:
# Ignore any files in or below the `/__tests__` directory.
- "/__tests__/**"
# Ignore any files in the `/scripts` directory.
- "/scripts/*"
# In the `gitlab-org/gitlab-runner` repository on GitLab:
git@gitlab.com:gitlab-org/gitlab-runner.git:
# Ignore the `/main_test.go` file.
- "/main_test.go"
# Ignore any files with names beginning with `server` or `session` anywhere in this repository.
- "{server,session}*"
# Ignore any files with names ending with `.md` or `.mk` anywhere in this repository.
- "*.m[dk]"
# Ignore files directly within directories such as `packages` or `packaged` anywhere in this repository.
- "**/package?/*"
# Ignore files in or below any `security` directories, anywhere in this repository.
- "**/security/**"
補足
- IDE側に反映するには、設定から30分待つかIDEを再起動する必要あり
you can wait up to 30 minutes to see the effect of a settings change, or you can manually reload the content exclusion settings by closing and reopening the application.
Testing changes to content exclusions in your IDE | Github より
- IDEによってはコンテンツ除外がサポートされていないものがあるため注意
- コンテンツ除外が適用されるのは、「GitHub Copilot Business または GitHub Copilot Enterprise サブスクリプションの一部としてシートが付与されている」か「コンテンツの除外が設定されている同じ組織のメンバーである」ユーザーのみ
公式ドキュメント