You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by martinay <ma...@videotron.ca> on 2003/05/21 04:39:39 UTC

external argument pass to "pre-commit" trigger...

hi folks !

I've followed and play around with SVN and I'm trying to make it The Source
Control Manager in the company I work for.
Part of the tedious evaluations of the Pros&Cons (I've pushed a lot of Pros
on the list :-), I need now to get deeper in the "Trigger Scripts"
functionalities ...

The goal I wish to achieve :

- using the simple "svn" command line, I want to provide some "external
arguments" to hook to our BugTracker, so that each time someone checkin
something, some infos will be added to BugTracker's DB using the the
"pre-commit" and "post-commit" script ...

What I've discovered :

- It seems that an "svn commit" command didn't provide any "external
arguments" accessible by the trigger scripts.
I've seen there is an "--extensions" (or "-t") option for "diff" command,
unfortunately, it is not available to other commands. But, it seems to be a
good and cheap alternative to have the same capabilites for any SVN commands
(assuming svnlook or envvar can let me access to it) ...

Is there any poeple having other ideas about the way I should implement such
triggers ?

Thanks in advance,

Tourlou !


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: external argument pass to "pre-commit" trigger...

Posted by cm...@collab.net.
martinay <ma...@videotron.ca> writes:

> Hi Ben !
> 
> Thanks for your hint ! I will try to make it work, but you probably know
> that developpers are sometime lazy ... :-)
> 
> How can I make sure that devs are issuing an "svn ps bugid NNN [PATH]" with
> the same path as choosen while issuing the "svn commit [PATH]" ? probably it
> won't be as problem most of the time, but just to enforce it ...
> 
> I thought it would me nice to have something in-between with unversioned
> props, but I can figured out how to apply it to "future commits", it would
> be nice to have something without path related, but only assigned to
> revision (but "future" revision) so command will look like :
> 
> svn ps bugid --revprop -r PENDING NNN
> 
> (currently, --revprop can only be assigned to revision from the past (not to
> PENDING revision), which is my bottleneck. Devs can assigned versionned
> props during their works, but than they are force to modify files outside
> the previous scope, and when they try to commit, the trigger will need to
> make that all files are included in the new scope)
> 
> That why I was trying to get the "bugid" attached with the commit itself.
> Maybe there is a good compromise ? Any idea to get it even smooter ?

Were I you, I would write a pre-commit hook in Python that uses the
Subversion Python bindings to do this:

  1.  Read the 'svn:log' property on the transaction that's about to
      be committed, looking for some regular expression like "issue
      1300" -- whatever format you want your bugid's referenced as.

  2.  If that bugid is found, set a 'bugid' property on the
      transaction -- this will be automatically promoted to a revision
      property when the commit succeeds.  If, however, no bugid is
      found in the committer's log message, return non-zero and cause
      the commit to fail (you could even have the script send email to
      the developer saying that he forgot to put the bugid in his
      commit log message).

Unlike setting versioned path properties, setting revision properties
is safe to do from within the pre-commit hook because the working copy
doesn't have to stay in sync with that value.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

RE: external argument pass to "pre-commit" trigger...

Posted by martinay <ma...@videotron.ca>.
Hi Ben !

Thanks for your hint ! I will try to make it work, but you probably know
that developpers are sometime lazy ... :-)

How can I make sure that devs are issuing an "svn ps bugid NNN [PATH]" with
the same path as choosen while issuing the "svn commit [PATH]" ? probably it
won't be as problem most of the time, but just to enforce it ...

I thought it would me nice to have something in-between with unversioned
props, but I can figured out how to apply it to "future commits", it would
be nice to have something without path related, but only assigned to
revision (but "future" revision) so command will look like :

svn ps bugid --revprop -r PENDING NNN

(currently, --revprop can only be assigned to revision from the past (not to
PENDING revision), which is my bottleneck. Devs can assigned versionned
props during their works, but than they are force to modify files outside
the previous scope, and when they try to commit, the trigger will need to
make that all files are included in the new scope)

That why I was trying to get the "bugid" attached with the commit itself.
Maybe there is a good compromise ? Any idea to get it even smooter ?

(BTW, such exercise remind me something interesting about "commit" features
: I've seen some products offering not only "PENDING" ChangeSet, but also
user-defined changesets for which Devs can assigned files been modfied to
specific changeset (which corresponding to specific bugid), so I don't known
how we can expand capabilites on that side, but it would be nice to have
such "changeset" pendings with associated props)

Tourlou !

>
> martinay <ma...@videotron.ca> writes:
>
> > The goal I wish to achieve :
> >
> > - using the simple "svn" command line, I want to provide
> some "external
> > arguments" to hook to our BugTracker, so that each time
> someone checkin
> > something, some infos will be added to BugTracker's DB using the the
> > "pre-commit" and "post-commit" script ...
> >
> > What I've discovered :
> >
> > - It seems that an "svn commit" command didn't provide any "external
> > arguments" accessible by the trigger scripts.
>
> No, the pre-commit and post-commit hook scripts receive only fixed
> arguments.  It's assumed that you can use 'svnlook' or other tools to
> examine the stuff that is committed.
>
> What kind of "external arguments" do the hook scripts need to pass to
> your bug tracker?  If it's metadata about the commit, perhaps it could
> come out of a file or directory property?
>
> For example, require that users set a specific 'bug-number' property
> when they commit (enforced by the pre-commit hook script).  Then the
> post-commit hook script can look for the property.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: external argument pass to "pre-commit" trigger...

Posted by Ben Collins-Sussman <su...@collab.net>.
martinay <ma...@videotron.ca> writes:

> The goal I wish to achieve :
> 
> - using the simple "svn" command line, I want to provide some "external
> arguments" to hook to our BugTracker, so that each time someone checkin
> something, some infos will be added to BugTracker's DB using the the
> "pre-commit" and "post-commit" script ...
> 
> What I've discovered :
> 
> - It seems that an "svn commit" command didn't provide any "external
> arguments" accessible by the trigger scripts.

No, the pre-commit and post-commit hook scripts receive only fixed
arguments.  It's assumed that you can use 'svnlook' or other tools to
examine the stuff that is committed.

What kind of "external arguments" do the hook scripts need to pass to
your bug tracker?  If it's metadata about the commit, perhaps it could
come out of a file or directory property?  

For example, require that users set a specific 'bug-number' property
when they commit (enforced by the pre-commit hook script).  Then the
post-commit hook script can look for the property.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: external argument pass to "pre-commit" trigger...

Posted by Michael Fletcher <mi...@theplanet.ca>.
Could you use a revision property?

ie
% svn commit
Committed revision 555.
% svn propset bugid --revprop -r 555 "Bug456" http://myrepo/

On Tuesday, May 20, 2003, at 10:39  PM, martinay wrote:

> hi folks !
>
> I've followed and play around with SVN and I'm trying to make it The 
> Source
> Control Manager in the company I work for.
> Part of the tedious evaluations of the Pros&Cons (I've pushed a lot of 
> Pros
> on the list :-), I need now to get deeper in the "Trigger Scripts"
> functionalities ...
>
> The goal I wish to achieve :
>
> - using the simple "svn" command line, I want to provide some "external
> arguments" to hook to our BugTracker, so that each time someone checkin
> something, some infos will be added to BugTracker's DB using the the
> "pre-commit" and "post-commit" script ...
>
> What I've discovered :
>
> - It seems that an "svn commit" command didn't provide any "external
> arguments" accessible by the trigger scripts.
> I've seen there is an "--extensions" (or "-t") option for "diff" 
> command,
> unfortunately, it is not available to other commands. But, it seems to 
> be a
> good and cheap alternative to have the same capabilites for any SVN 
> commands
> (assuming svnlook or envvar can let me access to it) ...
>
> Is there any poeple having other ideas about the way I should 
> implement such
> triggers ?
>
> Thanks in advance,
>
> Tourlou !
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>
Michael Fletcher


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org