-
Notifications
You must be signed in to change notification settings - Fork 135
Pre‐commit checks for Unity
In Unity projects, pre-commit checks ensure a cleaner, more stable repository by preventing common issues before they enter version control. This page outlines the two main pre-commit checks: detecting unsaved changes in Unity and identifying empty folders with .meta files.
When committing, Rider communicates with Unity to verify if there are any unsaved changes. If changes are detected, Rider prompts the user with a dialog.
This check prevents unintended issues caused by unsaved changes in Unity that could affect team members pulling from the repository. Unsaved changes may include modified scenes and scriptable objects.
When a commit attempt is made, Rider queries Unity for any unsaved modifications. If Unity reports unsaved changes, Rider displays a dialog, encouraging users to save their work before proceeding.
Description Unity automatically generates a .meta file for each new folder, even if the folder is empty. This check detects any .meta files for empty folders when committing and prompts the user with an alert.
Git does not track empty folders, but it does track .meta files. If a .meta file is committed without the corresponding folder, Unity will delete it on other machines that do not have the folder, leading to an unnecessary cycle of adding and removing the file in version control. This creates a "commit ping-pong," where .meta files for empty folders are continuously added and removed across commits, cluttering the commit history.
Before completing the commit, Rider scans for any .meta files corresponding to empty folders. If it finds any, Rider alerts the user, who can then choose to either commit anyway or cancel and fix the issues manually.