Remarque
La fonctionnalité de directives de codage personnalisées est uniquement disponible avec le plan Copilot Enterprise et est actuellement réservée à certains clients. See Adding repository custom instructions for GitHub Copilot.
About coding guidelines
You can provide Copilot with a set of coding guidelines, written in natural language, that will help it review your code in a way that aligns with your organization's coding style and best practices. For more information—including examples of coding guidelines—see About coding guidelines for GitHub Copilot code review.
Creating a coding guideline
-
Sur GitHub, accédez à la page principale du référentiel.
-
Sous le nom de votre dépôt, cliquez sur Paramètres. Si vous ne voyez pas l’onglet « Paramètres », sélectionnez le menu déroulant , puis cliquez sur Paramètres.
-
In the "Code & automation" section of the sidebar, click Copilot, then Code review.
-
Click Create guideline.
-
Under "Name," give the coding guideline a name.
-
Under "Description," provide a description of the coding guideline up to 600 characters long. This will be used by Copilot to understand your coding style and to decide when to leave a comment.
How you write your description has a big impact on the quality of comments that Copilot will generate. For help with writing effective coding guidelines, see About coding guidelines for GitHub Copilot code review.
-
Optionally, limit the coding guideline to specific file types or paths by clicking Add file path and adding path patterns.
You can use
fnmatch
syntax to define paths to target, with*
as a wildcard to match any string of characters.Étant donné que GitHub utilise l’indicateur
File::FNM_PATHNAME
pour la syntaxeFile.fnmatch
, le caractère générique*
ne correspond pas aux séparateurs de répertoires (/
). Par exemple,qa/*
correspond à toutes les branches commençant parqa/
et contenant une barre oblique unique, mais ne correspond pas àqa/foo/bar
. Vous pouvez inclure n’importe quel nombre de barres obliques aprèsqa
avecqa/**/*
, qui correspondrait, par exemple, àqa/foo/bar/foobar/hello-world
. Vous pouvez également étendre la chaîneqa
avecqa**/**/*
pour rendre la règle plus inclusive.Pour plus d’informations sur les options de syntaxe, consultez la documentation fnmatch.
-
Test your coding guideline to make sure it works as expected.
- Click Add sample.
- Add your own sample, or press Generate code sample to automatically generate a code sample based on your title and description.
- Click Save to save the code sample.
- Test the coding guideline against your sample by pressing Run.
-
Save your coding guideline, and turn it on, by clicking Save guideline.