Introduction
Author: Tony Smith <tony@perforce.com>
Description
Example trigger to enforce a rule "files of suffix .x need
to be added as type Z". (For example, ".jpg" files must
always be "binary" and ".sh" files should always be "text".)
This script is mostly a reimplentation of Jeff Bowles
and Wed Peters' Perl binary.pl using P4Ruby but it uses
a more generalised trigger execution framework to make
it easier to concentrate on the nuts and bolts of what
your trigger does.
Requires
Ruby
P4Ruby
P4Triggers module
Example ‘triggers’ section:
Note: since this is applicable to only filenames with certain suffixes,
you might want to restrict the trigger to run when those files are
submitted. So, if this is looking at .cpp/.h/.txt/.html lines, you might
want to have it run only on those files.)
Triggers:
exampleB //.../*.jpg "ruby whatever/checktype.rb %changelist%"
exampleB //.../*.bmp "ruby whatever/checktype.rb %changelist%"
exampleB //.../*.sh "ruby whatever/checktype.rb %changelist%"
Note
For triggers I recommend you use a P4CONFIG file rather than hard coding
username/password in the script itself. This script assumes you've taken
that advice.