Add excluded-files field to create-pull-request and push-to-pull-request-branch#20935
Add excluded-files field to create-pull-request and push-to-pull-request-branch#20935
excluded-files field to create-pull-request and push-to-pull-request-branch#20935Conversation
…st-branch Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
ignored-files field to create-pull-request and push-to-pull-request-branch
|
@copilot add |
There was a problem hiding this comment.
Pull request overview
Adds an ignored-files config option to the create-pull-request and push-to-pull-request-branch safe outputs so certain file globs can be excluded from file-protection evaluation.
Changes:
- Introduces
ignored-filesin Go safe-output configs and passes it into the JS handler config asignored_files. - Adds JS support (
checkIgnoredFiles) and updatescheckFileProtectionto apply ignores before allowlist/protected-file checks. - Extends JSON schema and adds/updates unit + handler-level tests for ignore behavior.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/push_to_pull_request_branch.go | Adds IgnoredFiles to config and parses ignored-files. |
| pkg/workflow/create_pull_request.go | Adds IgnoredFiles to config struct. |
| pkg/workflow/compiler_safe_outputs_config.go | Plumbs ignored_files into handler config for both actions. |
| pkg/parser/schemas/main_workflow_schema.json | Documents and schemas the new ignored-files property. |
| actions/setup/js/types/handler-factory.d.ts | Adds ignored_files?: string[] to handler config typing/docs. |
| actions/setup/js/manifest_file_helpers.cjs | Implements checkIgnoredFiles and applies ignore filtering in checkFileProtection. |
| actions/setup/js/manifest_file_helpers.test.cjs | Adds unit coverage for ignored-files logic + ordering. |
| actions/setup/js/create_pull_request.test.cjs | Adds integration-style tests for ignored-files behavior. |
| actions/setup/js/push_to_pull_request_branch.test.cjs | Adds integration-style tests for ignored-files behavior. |
Comments suppressed due to low confidence (1)
pkg/parser/schemas/main_workflow_schema.json:6425
- Same as above:
ignored-filesis documented as being excluded "from the effective patch", but the handlers still apply the full patch file. Please either implement actual patch filtering or adjust this description to reflect that only protection checks are affected.
"ignored-files": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of glob patterns for files to ignore when creating the patch. Applied before allowed-files and protected-files checks — matching files are excluded from all protection checks and from the effective patch. Supports * (any characters except /) and ** (any characters including /)."
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -161,7 +202,9 @@ function checkFileProtection(patchContent, config) { | |||
| const prefixes = Array.isArray(config.protected_path_prefixes) ? config.protected_path_prefixes : []; | |||
| const { manifestFilesFound } = checkForManifestFiles(patchContent, manifestFiles); | |||
| const { protectedPathsFound } = checkForProtectedPaths(patchContent, prefixes); | |||
| const allFound = [...manifestFilesFound, ...protectedPathsFound]; | |||
| const effectiveManifest = manifestFilesFound.filter(f => !ignoredBasenames.has(f)); | |||
| const effectivePaths = protectedPathsFound.filter(f => !ignoredPaths.has(f)); | |||
| const allFound = [...effectiveManifest, ...effectivePaths]; | |||
| "ignored-files": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| }, | ||
| "description": "List of glob patterns for files to ignore when creating the patch. Applied before allowed-files and protected-files checks — matching files are excluded from all protection checks and from the effective patch. Supports * (any characters except /) and ** (any characters including /)." |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot the ignored-files should NOT be included in the patch. The behavior is similar to |
…ch generation Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ration time Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 3118bc5. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
…terminology Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 61b3746. Renamed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
ignored-files field to create-pull-request and push-to-pull-request-branchexcluded-files field to create-pull-request and push-to-pull-request-branch
…HOST support Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in c1210f8. The CI failures were caused by two new commits that landed on main after the last merge:
Merged main and updated both the golden files and the test expectations. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
… function Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in f333f70. The TypeScript error was a variable shadowing bug: in the strategy-3 patch generation block, a local |
Adds an
excluded-filesglob array to bothcreate-pull-requestandpush-to-pull-request-branchsafe-output configs. Files matching these patterns are excluded from the patch entirely at generation time using git's native:(exclude)<pattern>magic pathspec — they will not appear in the resulting commit and are not subject toallowed-filesorprotected-fileschecks.Example:
With this config, changes to
dist/bundle.jsare excluded from the patch at generation time — they won't appear in the commit, won't trigger anallowed-filesviolation, and won't hit aprotected-filesblock.Changes
generate_git_patch.cjs: NewexcludedFilesoption; each pattern becomes a:(exclude)<pattern>magic pathspec appended to everygit format-patch --stdoutcall across all three patch-generation strategies. Files are excluded by git before the patch is written.safe_outputs_handlers.cjs: Forwardsexcluded_filesfrom handler config togenerateGitPatch()aspatchOptions.excludedFilesfor bothcreate_pull_requestandpush_to_pull_request_branch.manifest_file_helpers.cjs:checkFileProtection()simplified — noexcluded_fileshandling needed since excluded files never reach protection checks;checkExcludedFiles()retained as a utility.types/handler-factory.d.ts: Addedexcluded_files?: string[]toHandlerConfigwith description referencing:(exclude)pathspec behavior.create_pull_request.go/push_to_pull_request_branch.go: AddedExcludedFiles []string(yaml:"excluded-files,omitempty");push-to-pull-request-branchparser extended to read the field.compiler_safe_outputs_config.go: Passesexcluded_filesinto the JS handler config for both actions.main_workflow_schema.json:excluded-filesarray property added to both action schemas; description explains the:(exclude)<pattern>git pathspec mechanism.cloclo.md: Addedexcluded-files: [".github/workflows/*.lock.yml"]to thecreate-pull-requestconfig so lock files are excluded from PRs created by the cloclo workflow.generate_git_patch.test.cjsusing a real git repo verify that:(exclude)pathspecs correctly exclude files at generation time; handler tests andmanifest_file_helpers.test.cjsupdated to reflect the generation-time filtering model.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.