Is there a way to github search 'generated' code? #181939
-
Select Topic AreaQuestion BodyWe have 600+ repos for our organisation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Short answer: No — GitHub does not currently allow searching code that it classifies as “generated”, and this behavior cannot be overridden at the organization or repository level. Why this happensGitHub automatically detects generated files using well-known comment patterns such as: // Code generated by mygenerator 0.0.2-b DO NOT EDITOnce a file is classified as generated, GitHub:
This is intentional and there is no opt-in flag to force indexing of generated files. Is there a way to flag generated files to still be indexed?❌ No.
to re-include generated files in search. Practical Workarounds1. Add a secondary non-standard markerKeep the standard generated comment, but add an extra searchable comment: // Code generated by mygenerator 0.0.2-b DO NOT EDIT
// generator-version: [email protected]You can later search for: 2. Emit a machine-readable manifestHave each repo generate a file like: or generator:
name: mygenerator
version: 0.0.2-bThese files are not generated code, so they remain searchable. 3. Use GitHub APIs instead of searchUse:
to iterate repositories and inspect files directly. 4. Local or CI-based scanning (your fallback plan)Your fallback is actually the most reliable approach:
This is how many large orgs handle this exact problem. RecommendationFor long-term maintainability across 600+ repos:
|
Beta Was this translation helpful? Give feedback.
Short answer: No — GitHub does not currently allow searching code that it classifies as “generated”, and this behavior cannot be overridden at the organization or repository level.
Why this happens
GitHub automatically detects generated files using well-known comment patterns such as:
// Code generated by mygenerator 0.0.2-b DO NOT EDITOnce a file is classified as generated, GitHub:
This is intentional and there is no opt-in flag to force indexing of generated files.
Is there a way to flag generated files to still be indexed?
❌ No.
GitHub does not provide: