P4Ruby Library: Scripts/Modules for use with P4Ruby

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.

Library Contents

  1. Triggers
  2. General Purpose Scripts

Support

If you have any problems or questions with these scripts you can contact me at tony@perforce.com or 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 here.

Script Description
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.
checkjob.rb Ensures that all changelists are associated with a job before they can be submitted. This is the simplest example of using my trigger framework.
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.
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.

General Purpose Scripts

These are some useful non-trigger scripts

Script Description
integrename.rb A script to integrate changes using a branch view and attempt to follow renames in both the source and target branches. Early alpha state at the moment.
oldclients.rb A script to find the oldest <n> clients - useful to locate candidates for deletion.
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.