Skip to content

Commit 78c347a

Browse files
pararohanCopilotCopilotlecoursenCopilot
authored
Document allowed exceptions for push rules (#62873)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Laura Coursen <lecoursen@github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pararohan <452580+pararohan@users.noreply.github.com> Copilot-Session: 268c80e7-020f-43b5-a13f-d6010afd5f0c
1 parent b48b25b commit 78c347a

6 files changed

Lines changed: 44 additions & 1 deletion

File tree

content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ Prevent commits that include changes in specified file paths from being pushed t
319319

320320
{% data reusables.repositories.rulesets-push-rules-path-example %}
321321

322+
{% ifversion push-rule-allowed-exceptions %}
323+
324+
You can also add allowed exceptions to this rule. A file matching an allowed exception can be pushed even when it also matches a restricted path.
325+
326+
{% data reusables.repositories.rulesets-push-rules-allowed-exceptions %}
327+
328+
{% endif %}
329+
322330
## Restrict file path length
323331

324332
Prevent commits that include file paths that exceed a specified character limit from being pushed to the repository.
@@ -327,6 +335,20 @@ Prevent commits that include file paths that exceed a specified character limit
327335

328336
Prevent commits that include files with specified file extensions from being pushed to the repository. {% ifversion available-rules-limit %}Limit is 200 entries and up to 200 characters in each entry.{% endif %}
329337

338+
{% ifversion push-rule-allowed-exceptions %}
339+
340+
If you need to allow an exception for a single file of an otherwise blocked file type, use "Restrict file paths" with a pattern such as `**/*.jar`. Only the "Restrict file paths" and "Restrict file size" rules support allowed exceptions.
341+
342+
{% endif %}
343+
330344
## Restrict file size
331345

332346
Prevent commits that exceed a specified file size limit from being pushed to the repository.
347+
348+
{% ifversion push-rule-allowed-exceptions %}
349+
350+
You can also add allowed exceptions to this rule. A file matching an allowed exception can exceed the file size limit.
351+
352+
{% data reusables.repositories.rulesets-push-rules-allowed-exceptions %}
353+
354+
{% endif %}

content/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/troubleshooting-rules.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ If a branch or tag is targeted by rules restricting the metadata of commits, you
2121

2222
When utilizing push rulesets, a maximum of 1000 reference updates are allowed per push. If your push exceeds this limit, it will be rejected. For more information see [AUTOTITLE](/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/creating-rulesets-for-a-repository#creating-a-push-ruleset).
2323

24+
{% ifversion push-rule-allowed-exceptions %}
25+
26+
If your push is blocked by a rule restricting file paths or file size, check whether the ruleset defines allowed exceptions. A repository, organization, or enterprise administrator can add an allowed exception for a file that must remain pushable. See [Restrict file paths](/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#restrict-file-paths) and [Restrict file size](/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#restrict-file-size).
27+
28+
{% endif %}
29+
2430
Additionally, push rulesets apply to the "Create a blob", "Create a tree", and "Create or update file contents" endpoints in the REST API. See [AUTOTITLE](/rest/git/blobs?apiVersion=2022-11-28#create-a-blob), [AUTOTITLE](/rest/git/trees?apiVersion=2022-11-28#create-a-tree), and [AUTOTITLE](/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents).
2531

2632
## Troubleshooting required status checks
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: github/releases#9966
2+
# "Allowed exceptions" (ignored_file_paths) for the Restrict file paths
3+
# and Restrict file size push rules.
4+
# GHES availability TBC — add a ghes key once confirmed.
5+
versions:
6+
fpt: '*'
7+
ghec: '*'

data/reusables/repositories/push-rulesets-overview.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ Push rulesets allow you to:
77
* **Restrict file paths:** Prevent commits that include changes in specified file paths from being pushed.
88

99
{% data reusables.repositories.rulesets-push-rules-path-example %}
10+
11+
{% ifversion push-rule-allowed-exceptions %}You can add allowed exceptions for paths that should remain pushable.{% endif %}
1012
* **Restrict file path length:** Prevent commits that include file paths that exceed a specified character limit from being pushed.
1113
* **Restrict file extensions:** Prevent commits that include files with specified file extensions from being pushed.
12-
* **Restrict file size:** Prevent commits that exceed a specified file size limit from being pushed.
14+
* **Restrict file size:** Prevent commits that exceed a specified file size limit from being pushed.{% ifversion push-rule-allowed-exceptions %} You can add allowed exceptions for files that may exceed the limit.{% endif %}
1315

1416
### About push rulesets for forked repositories
1517

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allowed exceptions use `fnmatch` syntax and are validated when you save the ruleset. For example, `**/gradle/wrapper/*.jar` allows the Gradle wrapper JAR file in any directory.

data/reusables/repositories/rulesets-push-rules-step.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ Any push protections you configure will block pushes in this repository and thro
55
1. Under "Push protections," click the restrictions you want to apply. Then fill in the details for the restrictions you select.
66

77
For file path restrictions, you can use partial or full paths. {% data reusables.repositories.rulesets-push-rules-path-example %}
8+
{%- ifversion push-rule-allowed-exceptions %}
9+
1. Optionally, for the "Restrict file paths" and "Restrict file size" restrictions, under "Allowed exceptions," add the file paths you want to exempt from the restriction.
10+
11+
{% data reusables.repositories.rulesets-push-rules-allowed-exceptions %}
12+
{%- endif %}

0 commit comments

Comments
 (0)