Skip to content

Commit f58f61e

Browse files
committed
Allow disabling patch automerge for selected dependencies
We introduce a new cookiecutter argument which allows users to specify zero or more regex patterns for dependencies whose patch level updates shouldn't be automerged. The template expects that the contents of the new argument is a string which contains zero or more regex patterns separated by semicolons. The template will use these patterns as the values for the package rule field `excludePackagePatterns`.
1 parent c07c837 commit f58f61e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cookiecutter.json

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"automerge_patch": "y",
1515
"automerge_patch_v0": "n",
1616

17+
"automerge_patch_regexp_blocklist": "",
18+
1719
"copyright_holder": "VSHN AG <info@vshn.ch>",
1820
"copyright_year": "1950",
1921

hooks/post_gen_project.py

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
automerge_patch = "{{ cookiecutter.automerge_patch }}" == "y"
1313
automerge_patch_v0 = "{{ cookiecutter.automerge_patch_v0 }}" == "y"
1414

15+
automerge_patch_regexp_blocklist = "{{ cookiecutter.automerge_patch_regexp_blocklist }}"
16+
1517
if not create_lib:
1618
shutil.rmtree("lib")
1719

@@ -88,6 +90,13 @@
8890
# remove match current version if we want v0.x patch automerge
8991
del patch_rule["matchCurrentVersion"]
9092

93+
# Set excludePackagePatterns to the provided list of package patterns for which patch PRs
94+
# shouldn't be automerged. Only set the field if the provided list isn't empty.
95+
if len(automerge_patch_regexp_blocklist) > 0:
96+
# NOTE: We expect that the provided pattern list is a string with patterns separated by ;
97+
patterns = automerge_patch_regexp_blocklist.split(";")
98+
patch_rule["excludePackagePatterns"] = patterns
99+
91100
renovatejson["packageRules"].append(patch_rule)
92101

93102
# NOTE: Later rules in `packageRules` take precedence

0 commit comments

Comments
 (0)