You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Ted Byers <r....@gmail.com> on 2012/05/20 23:16:16 UTC

New to subversion, need to find documentation on writing hooks

I have just installed subversion on a Ubuntu VM, and trying to learn how to
administer both.  I have successfully created my first VN repository.  :-)

 

Now, I have read through the documentation a couple times, and know what
hooks are and why they're used, but I am not clear on how to write one as
the examples I have found so far are written in programming languages I
don't know (such as Python).

 

In the first project I am going to put into this repository, I am writing a
test suite based on Boost's Test library (written in C++).  What I want to
do is write a program that assesses code coverage, so that all new code has
at least one unit test, and then require that the codebase, including all
existing and new tests,  compile and execute successfully; and have a
precommit hook that prevents a commit unless this test suite program
indicates that the tests all passed.  I have read arguments that recommend
against this, claiming it can slow down commits, but then I am more
concerned about code quality, and always having a codebase, which to me
includes all tests, that compiles and runs properly than I am in the
convenience of any programmers working on the project.  I also write in Perl
and JavaScript (and not so much anymore in Java or C#), so I will want the
same requirement on all code in all the languages I routinely use.

 

Can anyone either show me how to write such a pre-commit hook, or point me
to examples that would show how to do this?

 

Thanks

 

Cheers

 

Ted

 


Re: New to subversion, need to find documentation on writing hooks

Posted by Ryan Schmidt <su...@ryandesign.com>.
On May 20, 2012, at 16:16, Ted Byers wrote:

> I have just installed subversion on a Ubuntu VM, and trying to learn how to administer both.  I have successfully created my first VN repository.  :-)
>  
> Now, I have read through the documentation a couple times, and know what hooks are and why they're used, but I am not clear on how to write one as the examples I have found so far are written in programming languages I don't know (such as Python).
>  
> In the first project I am going to put into this repository, I am writing a test suite based on Boost's Test library (written in C++).  What I want to do is write a program that assesses code coverage, so that all new code has at least one unit test, and then require that the codebase, including all existing and new tests,  compile and execute successfully; and have a precommit hook that prevents a commit unless this test suite program indicates that the tests all passed.  I have read arguments that recommend against this, claiming it can slow down commits, but then I am more concerned about code quality, and always having a codebase, which to me includes all tests, that compiles and runs properly than I am in the convenience of any programmers working on the project.  I also write in Perl and JavaScript (and not so much anymore in Java or C#), so I will want the same requirement on all code in all the languages I routinely use.
>  
> Can anyone either show me how to write such a pre-commit hook, or point me to examples that would show how to do this?

You should be able to write Subversion hook scripts in whatever language you like. I used PHP before, but now that I've jumped into using node.js for web development, writing one in JavaScript would be fun. I don't have an example handy at this time. But there should be tons of examples using Perl.


Re: New to subversion, need to find documentation on writing hooks

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Ted Byers,
am Montag, 21. Mai 2012 um 12:08 schrieben Sie:

> I have never heard of jenkins.  What more can you tell me about it?

Better first read yourself about Hudson and Jenkins, the latter is a
newly created fork of the former, and CI in general and decide if it
is something for you. If you already have tests you really should
consider to use one of the CI-plattforms and not reinvent the wheel
using hooks. Hudson is pretty easy to setup and configure.

http://en.wikipedia.org/wiki/Continuous_integration
http://en.wikipedia.org/wiki/Hudson_(software)
http://en.wikipedia.org/wiki/Jenkins_(software)

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon.............030-2 1001-310
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hanover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: New to subversion, need to find documentation on writing hooks

Posted by Les Mikesell <le...@gmail.com>.
On Mon, May 21, 2012 at 6:52 PM, Blair Zajac <bl...@orcaware.com> wrote:
>
>>> $ java -jar jenkins.war
>>
>>
>> Since he mentioned ubuntu earlier, it is probably even easier to go
>> with the packaged version:
>> https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
>> after which the system will know how to pick up updates.
>
>
> Do you mean apt-get updates or Jenkin's self-provided update mechanism?  If
> the later, is that recommended when it is installed via apt-get? I've always
> installed Jenkins by hand.

I use Centos with yum and the rpm-packaged version and it updates via
the system yum mechanism like everything else.  I assume the ubuntu
package works the same way with apt-get/synaptic or whatever the
system uses.   It is a lot easier to administer everything in one
place instead of having to update every application separately.

-- 
    Les Mikesell
       lesmikesell@gmail.com

Re: New to subversion, need to find documentation on writing hooks

Posted by Blair Zajac <bl...@orcaware.com>.
On 05/21/2012 03:11 PM, Les Mikesell wrote:
> On Mon, May 21, 2012 at 4:56 PM, David Weintraub<qa...@gmail.com>  wrote:
>>
>> Jenkins is pretty simple on the surface to setup. Simply download the
>> Jenkins "war" file, install a Java JDK if you don't have one
>> installed, and run the following command:
>>
>> $ java -jar jenkins.war
>
> Since he mentioned ubuntu earlier, it is probably even easier to go
> with the packaged version:
> https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
> after which the system will know how to pick up updates.

Do you mean apt-get updates or Jenkin's self-provided update mechanism? 
  If the later, is that recommended when it is installed via apt-get? 
I've always installed Jenkins by hand.

Blair



Re: New to subversion, need to find documentation on writing hooks

Posted by Les Mikesell <le...@gmail.com>.
On Mon, May 21, 2012 at 4:56 PM, David Weintraub <qa...@gmail.com> wrote:
>
> Jenkins is pretty simple on the surface to setup. Simply download the
> Jenkins "war" file, install a Java JDK if you don't have one
> installed, and run the following command:
>
> $ java -jar jenkins.war

Since he mentioned ubuntu earlier, it is probably even easier to go
with the packaged version:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
after which the system will know how to pick up updates.

-- 
   Les Mikesell
     lesmikesell@gmail.com

Re: New to subversion, need to find documentation on writing hooks

Posted by David Weintraub <qa...@gmail.com>.
On Mon, May 21, 2012 at 6:08 AM, Ted Byers <r....@gmail.com> wrote:

> I have never heard of jenkins.  What more can you tell me about it?

Jenkins is a Continuous Integration system. Continuous Integration
means every time sone one changes the code, you automatically build
the changes. This at least proves that the changes "don't break the
build". More sophisticated analysis can be done too. For example,
running unit tests, checking code for possible bugs, running coverage
tests, checking the code syntax.

This is something that's really quite common in the Java environment
where builds take but a few minutes. It's not as common in the C/C++
world where builds can take hours, but it's beginning to get there.

Jenkins is pretty simple on the surface to setup. Simply download the
Jenkins "war" file, install a Java JDK if you don't have one
installed, and run the following command:

$ java -jar jenkins.war

Then, go to http://localhost:8080 in your browser and see what's
there. Jenkins is pretty simple. If you are somewhat technical, you
should be able to set up a job in a matter of minutes. Just go ahead
and give it a try. There are dozens, if not hundreds of plugins that
can run all sorts of third party integrations. Jenkins can integrate
with almost any defect tracking system, and dozens of development
tools.


-- 
David Weintraub
qazwart@gmail.com

Re: AW: New to subversion, need to find documentation on writing hooks

Posted by Michael Diers <md...@elego.de>.
On 2012-05-22 08:21, Markus Schaber wrote:
[...]
> At my current employer, we successfully use Jenkins. 
> 
> But there are other such systems, for example the java-based http://cruisecontrol.sourceforge.net/ and its .NET cousing http://www.cruisecontrolnet.org/ - both of them were used at one of my former employers place. At another former employers place, we used post-commit hooks triggering a self-written python daemon which ran appropriate scons build files. And AFAIR, Microsoft also provides some auto-build solution for VSS or TFS.
> 
> http://en.wikipedia.org/wiki/Continuous_integration#Software contains a list of CI software.
> 
> So even if you don't like Hudson or Jenkins for whatever reason, there are lots of alternatives, and I strongly suggest you evaluate continuous integration in your environment.
[...]

Ted,

Please have a look at the (commmercial) CI tool TeamCity.

It is able to do so-called "pre-checked commits", which might help with
your objective, i.e. keeping bad commits out of the codeline.

http://en.wikipedia.org/wiki/TeamCity
http://www.jetbrains.com/teamcity/features/index.html

-- 
Michael Diers, elego Software Solutions GmbH, http://www.elegosoft.com/

AW: New to subversion, need to find documentation on writing hooks

Posted by Markus Schaber <m....@3s-software.com>.
Hi, Ted,

Just as an addition:

Von: Les Mikesell [mailto:lesmikesell@gmail.com]
> On Mon, May 21, 2012 at 5:50 AM, Ted Byers <r....@gmail.com> wrote:
> > Actually, I had never heard of Hudson either; except in reference to
> > the famous explorer of the Canadian north, and the bay due north of
> > Ontario, in the eastern Canadian arctic, named for him.
> >
> > Thanks for the links, though, as that gives me a starting point for
> > evaluating it.
> >
> 
> Conceptually it is a framework where you write simple jobs that are
> scheduled or run when you commit something new to your version control
> system.  The typical use is to build the trunk version on every change,
> run the tests, and email the group if anything is broken, but a job can do
> anything you want and there are many plugin extensions.
> A master system does the scheduling and collates the results but the work
> can be distributed over many slave machines and across target platforms.

At my current employer, we successfully use Jenkins. 

But there are other such systems, for example the java-based http://cruisecontrol.sourceforge.net/ and its .NET cousing http://www.cruisecontrolnet.org/ - both of them were used at one of my former employers place. At another former employers place, we used post-commit hooks triggering a self-written python daemon which ran appropriate scons build files. And AFAIR, Microsoft also provides some auto-build solution for VSS or TFS.

http://en.wikipedia.org/wiki/Continuous_integration#Software contains a list of CI software.

So even if you don't like Hudson or Jenkins for whatever reason, there are lots of alternatives, and I strongly suggest you evaluate continuous integration in your environment.

Best regards

Markus Schaber
-- 
___________________________
We software Automation.

3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 | Fax +49-831-54031-50

Email: m.schaber@3s-software.com | Web: http://www.3s-software.com 
CoDeSys internet forum: http://forum.3s-software.com
Download CoDeSys sample projects: http://www.3s-software.com/index.shtml?sample_projects

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915 

Re: New to subversion, need to find documentation on writing hooks

Posted by Les Mikesell <le...@gmail.com>.
On Mon, May 21, 2012 at 5:50 AM, Ted Byers <r....@gmail.com> wrote:
>
> Actually, I had never heard of Hudson either; except in reference to the
> famous explorer of the Canadian north, and the bay due north of Ontario, in
> the eastern Canadian arctic, named for him.
>
> Thanks for the links, though, as that gives me a starting point for
> evaluating it.
>

Conceptually it is a framework where you write simple jobs that are
scheduled or run when you commit something new to your version control
system.  The typical use is to build the trunk version on every
change, run the tests, and email the group if anything is broken, but
a job can do anything you want and there are many plugin extensions.
A master system does the scheduling and collates the results but the
work can be distributed over many slave machines and across target
platforms.

-- 
  Les Mikesell
     lesmikesell@gmail.com

RE: New to subversion, need to find documentation on writing hooks

Posted by Ted Byers <r....@gmail.com>.
> -----Original Message-----
> From: Cooke, Mark [mailto:mark.cooke@siemens.com]
> Sent: May-21-12 6:13 AM
> To: Ted Byers; 'Les Mikesell'
> Cc: users@subversion.apache.org
> Subject: RE: New to subversion, need to find documentation on writing
hooks
> 
> > -----Original Message-----
> > From: Ted Byers [mailto:r.ted.byers@gmail.com]
> > Sent: 21 May 2012 11:09
> > To: 'Les Mikesell'
> > Cc: users@subversion.apache.org
> > Subject: RE: New to subversion, need to find documentation on writing
> > hooks
> >
> >
> > > -----Original Message-----
> > > From: Les Mikesell [mailto:lesmikesell@gmail.com]
> > > Sent: May-21-12 12:58 AM
> > > To: Ted Byers
> > > Cc: users@subversion.apache.org
> > > Subject: Re: New to subversion, need to find documentation
> > on writing
> > hooks
> > >
> > > On Sun, May 20, 2012 at 4:16 PM, Ted Byers
> > <r....@gmail.com> wrote:
> > >
> > > >  I have read arguments that recommend against this, claiming it
> > > > can slow down commits, but then
> > I am more
> > > > concerned about code quality, and always having a
> > codebase, which to
> > > > me includes all tests, that compiles and runs properly
> > than I am in
> > > > the convenience of any programmers working on the project.
> > >
> > > I suspect that everyone involved would be happier if you
> > implement that in
> > a
> > > continuous integration tool like jenkins that will still
> > check everything
> > (and can
> > > do a lot more) but does not interfere with
> > > commits.    And use branches/tags to identify the production quality
> > > versions so your programmers can get some work done.
> > >
> > > --
> > >   Les Mikesell
> > >      lesmikesell@gmail.com
> >
> > Hi Les
> >
> > Thanks
> >
> > I have never heard of jenkins.  What more can you tell me about it?
> >
> > Cheers
> >
> > Ted
> >
> ...it used to be called `Hudson` if you have heard of that.
> 
> Homepage  : http://jenkins-ci.org/
> Wikipedia : http://en.wikipedia.org/wiki/Jenkins_(software)
> 

Thanks Marc

Actually, I had never heard of Hudson either; except in reference to the
famous explorer of the Canadian north, and the bay due north of Ontario, in
the eastern Canadian arctic, named for him.

Thanks for the links, though, as that gives me a starting point for
evaluating it.

Cheers

Ted


RE: New to subversion, need to find documentation on writing hooks

Posted by "Cooke, Mark" <ma...@siemens.com>.
> -----Original Message-----
> From: Ted Byers [mailto:r.ted.byers@gmail.com] 
> Sent: 21 May 2012 11:09
> To: 'Les Mikesell'
> Cc: users@subversion.apache.org
> Subject: RE: New to subversion, need to find documentation on 
> writing hooks
> 
> 
> > -----Original Message-----
> > From: Les Mikesell [mailto:lesmikesell@gmail.com]
> > Sent: May-21-12 12:58 AM
> > To: Ted Byers
> > Cc: users@subversion.apache.org
> > Subject: Re: New to subversion, need to find documentation 
> on writing
> hooks
> > 
> > On Sun, May 20, 2012 at 4:16 PM, Ted Byers 
> <r....@gmail.com> wrote:
> > 
> > >  I have read arguments that recommend
> > > against this, claiming it can slow down commits, but then 
> I am more
> > > concerned about code quality, and always having a 
> codebase, which to
> > > me includes all tests, that compiles and runs properly 
> than I am in
> > > the convenience of any programmers working on the project.
> > 
> > I suspect that everyone involved would be happier if you 
> implement that in
> a
> > continuous integration tool like jenkins that will still 
> check everything
> (and can
> > do a lot more) but does not interfere with
> > commits.    And use branches/tags to identify the production quality
> > versions so your programmers can get some work done.
> > 
> > --
> >   Les Mikesell
> >      lesmikesell@gmail.com
> 
> Hi Les	
> 
> Thanks
> 
> I have never heard of jenkins.  What more can you tell me about it?
> 
> Cheers
> 
> Ted
> 
...it used to be called `Hudson` if you have heard of that.

Homepage  : http://jenkins-ci.org/
Wikipedia : http://en.wikipedia.org/wiki/Jenkins_(software)

~ mark c

RE: New to subversion, need to find documentation on writing hooks

Posted by Ted Byers <r....@gmail.com>.
> -----Original Message-----
> From: Les Mikesell [mailto:lesmikesell@gmail.com]
> Sent: May-21-12 12:58 AM
> To: Ted Byers
> Cc: users@subversion.apache.org
> Subject: Re: New to subversion, need to find documentation on writing
hooks
> 
> On Sun, May 20, 2012 at 4:16 PM, Ted Byers <r....@gmail.com> wrote:
> 
> >  I have read arguments that recommend
> > against this, claiming it can slow down commits, but then I am more
> > concerned about code quality, and always having a codebase, which to
> > me includes all tests, that compiles and runs properly than I am in
> > the convenience of any programmers working on the project.
> 
> I suspect that everyone involved would be happier if you implement that in
a
> continuous integration tool like jenkins that will still check everything
(and can
> do a lot more) but does not interfere with
> commits.    And use branches/tags to identify the production quality
> versions so your programmers can get some work done.
> 
> --
>   Les Mikesell
>      lesmikesell@gmail.com

Hi Les	

Thanks

I have never heard of jenkins.  What more can you tell me about it?

Cheers

Ted


Re: New to subversion, need to find documentation on writing hooks

Posted by Les Mikesell <le...@gmail.com>.
On Sun, May 20, 2012 at 4:16 PM, Ted Byers <r....@gmail.com> wrote:

>  I have read arguments that recommend
> against this, claiming it can slow down commits, but then I am more
> concerned about code quality, and always having a codebase, which to me
> includes all tests, that compiles and runs properly than I am in the
> convenience of any programmers working on the project.

I suspect that everyone involved would be happier if you implement
that in a continuous integration tool like jenkins that will still
check everything (and can do a lot more) but does not interfere with
commits.    And use branches/tags to identify the production quality
versions so your programmers can get some work done.

-- 
  Les Mikesell
     lesmikesell@gmail.com

Re: New to subversion, need to find documentation on writing hooks

Posted by David Chapman <dc...@acm.org>.
On 5/20/2012 2:16 PM, Ted Byers wrote:
>
> I have just installed subversion on a Ubuntu VM, and trying to learn 
> how to administer both.  I have successfully created my first VN 
> repository.  :-)
>
> Now, I have read through the documentation a couple times, and know 
> what hooks are and why they're used, but I am not clear on how to 
> write one as the examples I have found so far are written in 
> programming languages I don't know (such as Python).
>
> In the first project I am going to put into this repository, I am 
> writing a test suite based on Boost's Test library (written in C++).  
> What I want to do is write a program that assesses code coverage, so 
> that all new code has at least one unit test, and then require that 
> the codebase, including all existing and new tests,  compile and 
> execute successfully; and have a precommit hook that prevents a commit 
> unless this test suite program indicates that the tests all passed.  I 
> have read arguments that recommend against this, claiming it can slow 
> down commits, but then I am more concerned about code quality, and 
> always having a codebase, which to me includes all tests, that 
> compiles and runs properly than I am in the convenience of any 
> programmers working on the project.  I also write in Perl and 
> JavaScript (and not so much anymore in Java or C#), so I will want the 
> same requirement on all code in all the languages I routinely use.
>
>
The usual convention is to put the checks in the post-commit hook, then 
back out offending changes if any.  Otherwise commits can grind to a halt.

I once worked at a company where the pre-commit test suite (not part of 
a hook) ran for an hour.  We were supposed to ensure that no other 
changes had been made to the affected modules before the commit.  
However, this would sometimes require several iterations (a dozen 
developers and a couple dozen modules under active, though unrelated, 
enhancement efforts meant lots of "file has been changed" conflicts at 
commit time).  Occasionally we simply had to merge, compile, commit, and 
then rerun the test suite.  (Yes, I would have liked to reduce that 
suite to 30 seconds or less, but that was a much larger problem than 
what I could change at that company.)

-- 
     David Chapman      dcchapman@acm.org
     Chapman Consulting -- San Jose, CA
     Software Development Done Right.
     www.chapman-consulting-sj.com