Gearset's customizable filters let you control the types of metadata that are displayed in your comparison results. To add an additional layer of granularity, you can use regex filtering to include or exclude specific named items. For more information on how to create or edit a custom metadata filter, see this article.
You can use regex filtering to either include or exclude items from your comparison results. In this article we'll demonstrate how to use this powerful feature to tune your custom filters.
Switching to named items
First, find the metadata type you're after from the left-hand list, and switch the toggle to
You should note that when you switch to
Named items, no items are included by default. You can select specific items to include in your filter and subsequent comparison either by using the checkboxes or by adding regex.
Including items based on regex
Imagine you want to include all items that begin with
Site. Rather than selecting every item manually, you can add a regex rule to include all matching items. Select
Regular expression from the left-hand dropdown and type the regex pattern
^Site.* into the text field. Click
Add to save the rule.
Excluding items based on regex
Sets of items can be excluded by a regex pattern in much the same way as they are included above, by selecting the
Exclude option on the right-hand dropdown when
Regular expression is selected on the left.
The key difference with exclude regex is that items that match the pattern are excluded no matter what, regardless of whether they were included individually or via regex pattern. Exclude regex takes priority over any other filters.
Consider the below example:
The include regex will find
TopicAssignment, in addition to the explicitly included
User. However, the exclude regex will match
As a result, the final set of objects to be included in the comparison will be
Building a complex filter with includes and excludes
Include and exclude filters can be layered to create complex metadata filters.
Take the first example in this doc, including
Site items. Imagine you want to exclude
SitePoweredBy from the comparison, but include all other Apex components.
Object name from the left dropdown, type the name of the item you want to exclude, and switch the right dropdown to
Add to save the rule.
If you left things there,
SitePoweredBy would be excluded, but so would every other Apex component! Now you would need to add the include regex term
.* which includes all other items of this metadata type.
In this way, you can build up complex metadata filters to fine-tune your comparisons and control exactly which items you want to compare and deploy.
Notes of caution
Please ensure you select
Regular expressionfrom the dropdown when you use regex, rather than leaving it on the default
Object name. For example, if you want to add an include regex rule of
.*, if this was set up as an
Include itemrule (from having
Object namein the dropdown) rather than
Include regex, Gearset would look for an item called
.*, and the regex rule wouldn't work.
You can only use the
Named itemsand regex rules to specify top-level items, not subcomponents. For instance, you can set regex to exclude a specific
Custom object, but not to exclude a specific
Want to know more about regex?