0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Github Copilot] リポジトリ・組織ごとにコンテンツ除外を設定する(Content Exclusion)

Posted at

組織として GitHub Copilot を提供するところもだいぶ増えてきましたね。

組織利用の場合、使える機能を制限するポリシー設定なども重要ですが、その他に設定項目として「Content Exclusion」というものがあるのをご存知でしょうか。

その名の通り、リポジトリ・組織ごとに設定したパスルールに従って、該当したファイルではコード入力補完などをさせないようにすることができる というもの。
(2024年7月23日時点では Beta 機能となっていますが、問題なく動作します。機能的な留意点については後述します。)

ローカル検証用の .env など、 Copilot には食わせたくないファイルを除外しておくと、幾分か心の平穏が得られます。リポジトリ管理者や組織オーナーは利用を検討しましょう。

以下、設定のための基本的な情報をメモします。

リポジトリの Settings でのコンテンツ除外

リポジトリの [Settings] -> Code and automation 内 [Copilot] から設定可能。
copilot_repo_exclusion.png

以下、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] から設定可能。
copilot_org_exclusion.png

組織の設定では、全リポジトリ共通の定義の他、特定リポジトリにのみ適用するルールも設定することができる。
以下、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によってはコンテンツ除外がサポートされていないものがあるため注意

Availability of content exclusions

  • コンテンツ除外が適用されるのは、「GitHub Copilot Business または GitHub Copilot Enterprise サブスクリプションの一部としてシートが付与されている」か「コンテンツの除外が設定されている同じ組織のメンバーである」ユーザーのみ

Who is affected by a content exclusion setting?

公式ドキュメント

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?