Jump to content


Detecting 'populate' in change-submit trigger

populate trigger

  • Please log in to reply
3 replies to this topic

#1 Jeff Varga

Jeff Varga

    Member

  • Members
  • PipPip
  • 13 posts

Posted 25 June 2018 - 09:44 PM

We have a change-submit trigger that fires on any change to streams that we consider "release branches" like so:

rel-escrow change-submit //stream/foo_*_rel_*/... "%//depot/path/to/EscrowLock.sh% %user% %change%"

and it is great at making sure that users wanting to check in to our release branches have included the appropriate magic in their change description.

However, when I attempt to branch and populate a new release stream like so:
p4 populate -S //stream/foo_22_rel_b8 -r

I get booted because my escrow lock wants me to provide a bunch of magic in the description.  I can provide "-d 'blah blah blah'" but one of our escrow rules is that particular strings exist on their own line.  On linux I can kinda hack this with my shell, but on Windows there's no good way to add line breaks within a command line.

Is there a way in a change-submit trigger to detect that the originating command was a populate so I can easy-out?  Is there a trick for getting -d to read change descriptions from a file?

#2 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 637 posts

Posted 25 June 2018 - 11:02 PM

Does the %args% variable include the name of the command (i.e. "populate" vs "submit")?  If so that's probably the easiest way.  TBH I'd probably do that check/filter as standard practice when writing change-submit triggers since most triggers designed to run during submit are going to have problems if invoked during a populate.

The "-d" flag is meant for quick one-line descriptions and I don't think there's a good way to have it read a multi-line string from somewhere else.

#3 Mailman Sync

Mailman Sync

    Advanced Member

  • Maillist Aggregator
  • 2495 posts

Posted 25 June 2018 - 11:40 PM

Originally posted to the perforce-user mailing list by: Michael Mirman


I don't think %args% contain the command, but %command% would.
The documentation says that %command% is supported for all triggers except archive.
One could pass %command% to the trigger through the command line arguments, so the trigger could "excuse" this kind of a submission.

--
Michael Mirman
MathWorks, Inc.
508-647-7555

-----Original Message-----
From: perforce-user [mailto:perforce-user-bounces@perforce.com] On Behalf Of Sambwise
Sent: Monday, June 25, 2018 7:05 PM
To: perforce-user@perforce.com
Subject: Re: [p4] Detecting 'populate' in change-submit trigger

Posted on behalf of forum user 'Sambwise'.

Does the %args% variable include the name of the command (i.e.
"populate" vs "submit")?  If so that's
probably the easiest way.  TBH I'd probably do that check/filter
as standard practice when writing change-submit triggers since most triggers
designed to run during submit are going to have problems if invoked during a
populate.

The "-d" flag is meant for quick one-line descriptions and I don't
think there's a good way to have it read a multi-line string from somewhere
else.



--
Please click here to see the post in its original format:
  http://forums.perfor...-submit-trigger
_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user

_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user


#4 Robert Cowham

Robert Cowham

    Advanced Member

  • PCP
  • 269 posts
  • LocationLondon, UK

Posted 29 June 2018 - 10:15 AM

View PostJeff Varga, on 25 June 2018 - 09:44 PM, said:

but on Windows there's no good way to add line breaks within a command line.
Powershell? E.g. "line 1`nLine2"

It's a little wierd but capable...
Co-Author of "Learning Perforce SCM", PACKT Publishing, 25 September 2013, ISBN 9781849687645

"It's wonderful to see a new book about Perforce, especially one written by Robert Cowham and Neal Firth. No one can teach Perforce better than these seasoned subject matter experts"
  • Laura Wingerd, author of Practical Perforce, former VP of Product Technology at Perforce





Also tagged with one or more of these keywords: populate, trigger

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users