Review enforcement
Swarm can optionally enforce that a change to be submitted is tied to an approved code review. Additionally, Swarm can require that the content of a change to be submitted matches the content of its associated approved code review.
Important
These capabilities are currently not available for a Perforce service running on a Windows host.
These capabilities are provided via the trigger script included with Swarm, but are not enabled by default nor covered in the standard installation steps.
To enable these capabilities, edit the Perforce trigger table by running the p4 triggers command as a user with super-level privileges and add the following lines:
swarm.enforce.1 change-submit //DEPOT_PATH1/... "%quote%/path/to/swarm-trigger.sh%quote% -t enforce -v %change% -p %serverport%" swarm.enforce.2 change-submit //DEPOT_PATH2/... "%quote%/path/to/swarm-trigger.sh%quote% -t enforce -v %change% -p %serverport%" swarm.strict.1 change-content //DEPOT_PATH1/... "%quote%/path/to/swarm-trigger.sh%quote% -t strict -v %change% -p %serverport%" swarm.strict.2 change-content //DEPOT_PATH2/... "%quote%/path/to/swarm-trigger.sh%quote% -t strict -v %change% -p %serverport%"
Customize each line with the appropriate depot path to
enforce review approvals or to apply a
strict comparison of review contents. Ensure that the
/path/to/swarm-trigger.sh
is updated to match the
previously installed Swarm trigger lines.
The above lines include two examples of each of the two new trigger behaviors. Remove unnecessary lines, or add additional lines for specific depot paths as required.
For reference:
-
-t enforce
-
rejects changes to be committed that are not associated with an approved code review.
-
-t strict
-
rejects changes to be committed when the change's content does not match the content of its associated approved code review.
Note
-t strict
implies -t enforce
; you
should not apply both arguments to a single trigger.
Group exclusion
You may want to exclude specific users from the enforcement provided by these new trigger lines:
-
Create a group in the Perforce service whose members should be excluded from enforce or strict review restrictions.
-
Add users who should be excluded to the group.
Note
The owner of a group is not counted as a member of the group, unless the owner's userid is listed as a user in the group.
-
Edit the trigger table and add
-g
to each enforce or strict trigger line as desired.group_name
If the group name is
review_exclusions
, the trigger lines would be similar to:swarm.enforce.1 change-submit //DEPOT_PATH1/... "%quote%
/path/to/
swarm-trigger.sh%quote% -t enforce -v %change% -p %serverport% -g review_exclusions" swarm.enforce.2 change-submit //DEPOT_PATH2/... "%quote%/path/to/
swarm-trigger.sh%quote% -t enforce -v %change% -p %serverport% -g review_exclusions" swarm.strict.1 change-content //DEPOT_PATH1/... "%quote%/path/to/
swarm-trigger.sh%quote% -t strict -v %change% -p %serverport% -g review_exclusions" swarm.strict.2 change-content //DEPOT_PATH2/... "%quote%/path/to/
swarm-trigger.sh%quote% -t strict -v %change% -p %serverport% -g review_exclusions"