{{Project|P4Ruby Library| curator=Tony Smith| path=//guest/tony_smith/perforce/P4Rubylib/...| language=Ruby| license=PPL| brief=Library of P4Ruby scripts and triggers}} [[Category:Perforce administrative tools]] [[Category:Perforce APIs]] [[Category:Ruby]] == Introduction== I've started to put together some commonly used/requested scripts both to provide examples of good scripting using P4Ruby and also to solve some common problems in what I hope is an efficient way. I hope that over time, this will grow into a fairly broad range of resources for Perforce users. All of these scripts require you to install [http://www.ruby-lang.org Ruby] and [ftp://ftp.perforce.com/perforce P4Ruby] == Support == If you have any problems or questions with these scripts you can contact me at [mailto:tony@perforce.com tony@perforce.com] or [mailto:tony@smee.org tony@smee.org]. These scripts are not supported by Perforce Software, but by me personally. I'll answer questions as quickly as I can. == Triggers == These are some example trigger scripts. The documentation for all of these scripts is available [http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/doc/index.html here]. {| class="TablePager" ! colspan="2"|Common Files |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/P4Triggers.rb P4Triggers.rb] |A generalised framework for implementing Perforce triggers used by all of the other scripts. If you're going to use these scripts at all, you'll need this file to be installed in the same directory as the scripts themselves. |- ! colspan="2"|Pre-Submit Triggers |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/checkjob.rb checkjob.rb] |Ensures that all changelists are associated with a job before they can be submitted. This is the simplest example of using the P4Triggers.rb framework. |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/checktype.rb checktype.rb] |Ensures that new files being added/branched have the correct Perforce filetypes. Whilst "p4 typemap" goes a long way towards ensuring filetype consistency, it's easily overridden. Since a user cannot override a trigger, sysadmins who want more enforcement may want to use this trigger. |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/checkcase.rb checkcase.rb] |Script to ensure that new files being added/branched respect the case of existing directories in the path. For example, if //depot/test/fileA already exists, then this script will reject an attempt to add //depot/TEST/fileB or //Depot/test/fileB for that matter. This is very useful if you have Windows clients or if your Perforce server runs on Windows. In an all Unix environment it's not so much of a problem. |- ! colspan="2"|Post-Submit (Commit) Triggers (2004.2 and later) |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/autointeg.rb autointeg.rb] |A script for keeping a slave branch in sync with its master. Whenever a change is submitted to the master branch, it's automatically propagated to the slave via this commit trigger. The files that are integrated can be limited both by the trigger spec, and by the branch spec used. |- ! colspan="2"|Spec Triggers |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/triggers/defaultclient.rb defaultclient.rb] |A small script to ensure that the default client view for all new clients that are created are based on the view of an existing template client. This allows system administrators to define a default client mapping only a small section of the depot, and by default that's all new users will see when they create their clients. |} == General Purpose Scripts == These are some useful non-trigger scripts {| class="TablePager" |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/scripts/integrename.rb integrename.rb] |A script to integrate changes using a branch view and attempt to follow renames in both the source and target branches. |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/scripts/oldclients.rb oldclients.rb] |A script to find the oldest clients - useful to locate candidates for deletion. |- |[http://public.perforce.com/guest/tony_smith/perforce/P4Rubylib/scripts/reversechange.rb reversechange.rb] |A script to back out a specified change. Handles many cases, but may be defeated by older changes. See the notes in the script for more information. |} == Additional Information == {{RecentChanges|//guest/tony_smith/perforce/P4Rubylib/...}} {{License|PPL|1997-2007|Perforce Software, Inc}}