Jump to content

How to setup trigger (client or server) checking file properties?


Charles L.

Recommended Posts

Dear Plastic team,

How would it be possible to setup a trigger based on file properties?
The need is to make sure some metadata are properly defined otherwise check-in is refused.
I can image smthg is possible using externalized control script or exe, but inside cm, is there such mechanism available?

svn proplist lists key/values of given file.

Kind regards,
Charles

Link to comment
Share on other sites

Hi Charles, we already have ticket dealing with this topic but anyway, let me share the information here as well:

We have a triggers guide where we show all the environment variables available depending on the trigger type:
https://www.plasticscm.com/documentation/triggers/plastic-scm-version-control-triggers-guide

For instance, for the "before.checkin" trigger, the item path is available in the standard input of the trigger:
 

The standard input receives revision identifiers for all the items involved in the checkin operation, one per line. Each of them is a specially formatted string containing the server's path of the item (independent of any workspace) and the revision specification, so its contents are easily retrieved using the cm cat command.

This is the format of the revision specifications, one per line:

status item_path item_type#br:branch;changeset:cset_id@rep:rep_name@repserver:server

The meaning of the members in italic is detailed in the following table:

status The status of the item to be checked in: added (AD), changed (CH), moved (MV), deleted (DE)...
item_path The revision's path in server format, which is independent of the client workspace and operating system.
item_type The type of the item: DIR or FILE.
branch The branch of the revision.
cset_id Only available in the after-checkin trigger.
The changeset unique identifier. Can be used to ease parsing when accessing revisions with cm cat or cm shelveset in the trigger script, as string after the first semicolon uniquely identifies the revision inside the server.
rep_name The repository name where the revision belongs.
server The repository server and port where the repository belongs.

This example shows standard input supplied to a checkin trigger when making a checkin to the search.h changed file:

CH "/" DIR#br:/main/scm001;changeset:61@rep:doom3src@repserver:HERMES:8087
CH "/search" DIR#br:/main/scm001;changeset:61@rep:doom3src@repserver:HERMES:8087
CH "/search/search.h" FILE#br:/main/scm001;changeset:61@rep:doom3src@repserver:HERMES:8087


Plastic also has the "cm fileinfo --help" command, that allows getting metadata information of the files:

cm fileinfo --help
Retrieves detailed information about the items in the workspace.

Usage:

    cm fileinfo <item_path>[ ...] [--fields=<field_value>[,...]]
                [[--xml | -x [=<output_file>]] | [--format=<str_format>]]
                [--symlink] [--encoding=<name>]

    item_path           Items to display. Use a whitespace to separate the
                        items.
                        Use double quotes (" ") to specify paths containing
                        spaces.


Regards,
Carlos.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...