Skip to main content
What does Gearset’s repo dependency cleaner do?
Valerio Chang avatar
Written by Valerio Chang
Updated over 6 months ago

Gearset’s repo dependency cleaner deletes Salesforce metadata with missing dependencies from your repo, because anything with a missing dependency cannot be deployed to a Salesforce org. 

Here is an example of what this looks like on the Deployment results page:

The repo dependency cleaner runs only when you deploy to a Git branch. There are two types of cleaning the repo cleaner will perform:

  1. The repo cleaner will always look for items to clean that are related to what you've selected for deployment. For example, if you deploy a Custom Field that is marked as required, the repo cleaner will remove any permissions for this field, as Salesforce does not allow setting field permissions for required fields, so attempting to deploy the contents of this repo would fail.

  2. If your deployment includes any destructive change, the repo cleaner will also check the entire repo for items that might be missing a dependency. This safeguard prevents Gearset from cleaning repos that are being used as a one-way store, for example for storing only permissions, in which no items are ever deleted.

These steps prevent you from leaving an item with a missing dependency, if you deleted the item on which it depends from the repo. You’ll be able to see any deletions in your version control system; they will be part of the same commit as the deployment.

What gets cleaned?

The cleaner doesn’t delete everything with a missing dependency. It looks for the metadata types that most easily end up with missing dependencies, such as a profile’s permissions for an object, where the object is not actually in the repo. In this case, the cleaner would delete the permissions because they are undeployable without the object. 

These are the metadata types the repo dependency cleaner looks at, to make sure there are no missing dependencies:

  • Fields

  • Field sets

  • Flows

  • Layouts

  • Objects

  • Quick actions

  • Record types 

  • Validation rules

  • Web links

These are the metadata types that will be deleted if they have missing dependencies:

  • Profiles (and permission sets for API v40 and older)

  • Apex class permissions

  • Field permissions

  • Object permissions

  • App visibility

  • Tab visibility

  • Object translations

  • Flow translations

  • Record types visibility

Although the repo dependency cleaner is triggered by certain deployments, it does not only look at items related to that deployment package. The cleaner looks at the metadata types listed above, across your entire repo. Metadata deployed to source control with another tool besides Gearset - or that has been directly modified in source - might include items with missing dependencies. If so, this undeployable metadata will be deleted by the cleaner.

Can I turn off the repo dependency cleaner?

You might want to turn off the repo dependency cleaner if you deliberately deploy items with missing dependencies through source control. For example, if you have lots of managed packages in your orgs, you might want to deploy the permissions for managed packages’ objects and classes but not deploy the objects and classes themselves. The repo dependency cleaner would delete these permissions, because the items on which they depend are not in the repo.

By default, Gearset’s repo dependency cleaner is enabled. To disable or enable the cleaner, go to My account > Deployment settings and use the toggle under Repo dependency cleaner. This is a team-wide setting, so it applies to all repos deployed to by everyone in your team.

If you do decide to disable the cleaner, and then re-enable it in the future, note that it will still delete the items you sought to protect originally, as soon as you deploy a destructive change to that repo. Only re-enable the cleaner once you are sure that items with missing dependencies no longer need to be stored in your repo.

Can I keep the repo dependency cleaner turned on and still exclude managed packages?

You might want to maintain the repo dependency cleaner's functionality while excluding items related to managed packages. This can be achieved by deploying the Installed package metadata type for the packages you wish to exclude into your repository.

Items associated with the Installed package(s) present in your repository will automatically be excluded from the repo dependency cleaner. However, this exclusion does not apply to items directly associated with any explicitly named deleted items.

Want more information?

Check out our repo dependency cleaner blog post here.

Did this answer your question?