What is Gated Commit?
Let’s start with what gated commit is. Gated commit is an integration pattern that allows users to integrate extra steps before committing changes into the main branch of version control systems (VCS).
So before your commit changes are available to everyone else in the branch, gated commit will check factors such as unit test result, code coverage and code issues. Hence, depending on the result, it will decide that commit should proceed or not.
Gated Commit in Embold
Embold gated commit is also following the same pattern, where we are scanning the committed files before changes go to the remote server.
We ensure that the quality of source code meets the industry standards. Also, you can customize those standards at the organization level.
How Embold Gated Commit works?
Well, as mentioned earlier, when you enable Embold gated commit, Embold scanner becomes a solid gate between your local commit and the code in VCS server. This will only allow entry for your code if it matches the particular standards. As shown in Figure 1.1 below, you can see how it works internally.
From the above scenario, we can see that:
- User will commit the code in VCS (Git/SVN).
- A hook for VCS will trigger the Embold scan internally.
- After scanning all modified or added files, Embold will check the result with the configurable gated commit profile. And if the result is not satisfied with the gated commit profile, the commit will be rejected.
- Else, The commit will be Accepted.
Further, Git hook/svn hook is one of the important functionality provided by VCS, where hook script will execute before commit happens. The script will perform an Embold scan in the background.
Note: In case of Git hook, it will run on local machine where as, for SVN we have the same hook script that will be execute on SVN server only.
What if you still want to Commit?
Sometimes, you are solving some critical issues and your code is not matching your organization’s quality gate standards but you still want to commit. Then you have one option, as “Force commit”. In that case, you would need to add “embold –skip” in your commit message. That’s it! Your commit will be accepted, however embold –skip message will be added in your commit message for future tracking.
Let’s see, one example of a commit message,
Added new connection with force commit is your original message and
embold --skip is a flag for skipping Embold scan.
How to configure quality gate for Gated Commit?
There is a standard quality gate configuration already set by default. But, if you need a customize quality gate configuration then you can set it easily. Moreover, you can also disable some rules in the configuration as well as skip Embold scanning of files or directories.
Overall, if you want to ensure that the quality of your code should improve before it commits to VCS server, then Embold gated commit would be a great option.