Code reviews are an excellent way to guarantee good code quality; you can enforce the integration policies by only allowing the merge operation for those branches that have an approved code review.
Find attached a small tool that checks if the branch you are trying to merge has an approved code review; if it does the merge operation can continue, if it doesn't the merge operation stops. This tool can works in both Windows and Linux (with mono), so it fits perfect like a Plastic SCM Trigger.
As the main purpose is allowing the merge operation for the branches with approved code reviews, the trigger has to be a "before-merge" one. Check the trigger creation command:
cm trigger create before-merge merge_gate "C:\Program Files\PlasticSCM5\server\triggers\MergeWithCodeReviewTrigger.exe"
Below is what the tool does inside:
- Read the source changeset merge contributor.
- Retrieve the branch containing the source changeset.
- Check if the branch has a code review and it's approved.
- If the branch has an approved code review the merge operation is allowed, if it doesn't, the merge operation can't continue.
Of course, you can extend the capabilities of the trigger as much as you want. For example, you can add a restriction to only check for an approved code review if the merge destination branch is "/main". It's straightforward, just read the "PLASTIC_MERGE_DESTINATION" environment variable and if it's main do all the checks; if it doesn't just allow the merge.