ccollab admin trigger update-changelist

Top  Previous  Next

Usage: ccollab [global-options] admin trigger update-changelist [--description-prefix <value> --description-template <value>] <changelist-spec>

 

update-changelist - Automatically update Perforce changelist with information about the review of that changelist

 

Command Options

Option

Required?

Description

--description-prefix <value>

Y

Prefix text for review line in changelist description

--description-template <value>

Y

Template text for review line in changelist description

<changelist-spec>

Y

%changelist% for 'commit' trigger, or %formfile% for 'form-in change' trigger

 

If you are reviewing changelists prior to submit, you might want some text in your changelist description saying the changelist was reviewed, which review ID, participants, and so on.

 

Running this command on the 'submit' trigger causes a description of the review to be added or updated in the changelist text when a pending changelist is submitted. If you also run this trigger on 'form-in change' then users can see the data update whenever they edit the changelist.

 

To install this trigger edit your Perforce Triggers list (see Perforce manual for details) and add a line like the following (except supply your installation directory for the ccollab application, replace <values> as appropriate, and put everything on one line even though the following text is word-wrapping):

 

ccollabupdatechangelist commit //depot/... "/usr/bin/ccollab --url <collabUrl> --user <collabUser> --password <collabPasswd> --scm perforce --p4port <p4port> --p4user <p4user> --p4passwd <p4passwd> --p4client <p4client> admin trigger update-changelist --description-prefix 'Review: ' --description-template 'ID ${review.id} by ${review.participants.rolename}' %changelist%

 

Optionally you can also add on the next line:

ccollabupdatechangelist form-in change "/usr/bin/ccollab --url <collabUrl> --user <collabUser> --password <collabPasswd> --scm perforce --p4port <p4port> --p4user <p4user> --p4passwd <p4passwd> admin trigger update-changelist --description-prefix 'Review: ' --description-template 'ID ${review.id} by ${review.participants.rolename}' %formfile%

 

Note - This example works under Windows, but under Unix the Perforce trigger system parses this line incorrectly, splitting up arguments by whitespace even though they are quoted using single-quotes.

 

The solution is to use a separate shell script file to call our code and to call that script from the Perforce trigger.

 

The --description-prefix prefix option is the prefix text that means: This is a line that should be updated with review information. The trigger is allowed to replace everything after that prefix with review information. If a changelist doesn't have a line with this prefix, a new line is appended to the end of the changelist description; otherwise the information is updated in-place.

 

The --description-template option is a template that will be inserted after the prefix. The template gives you a chance to decide which information about the review you want to include, in what order, and with any type of textual separators.

 

The template uses the ${...} variable substitution subsystem to let you insert dynamic data. In the example given above, the review ID and a list of participants is inserted between some English text.

 

If there is a review in the system that matches this changelist, the text is always updated either in-place or appended as described. On the other hand, if there is not already a review, the description is updated only if the prefix is already present; if there's no current review and no prefix than nothing is appended to the description.