[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Best practice question - undo or prevent commit?

From: Andy Levy <andy.levy_at_gmail.com>
Date: Wed, 6 Feb 2008 08:28:48 -0500

On Feb 6, 2008 7:45 AM, Bill Walton <bill.walton_at_charter.net> wrote:
>
>
> We've set up an integration environment in which we're running our automated
> test suite. We're currently kicking off the tests after the code is
> committed. The problem that presents is that if someone commits code that
> fails the tests (the team is new to automated tests and still getting into
> the habit), all the commits that follow will also fail until the problem is
> fixed.
>
> My goal is to prevent 'bad' code from being committed to the repository. Is
> it possible to use a pre-commit hook to move the code being committed into
> the test environment and run the tests? Or do I need to 'undo' the commit
> to back out the offending code?

I would do neither. If you put the committed code into an environment
where you run the tests, you will hold up all other commits while
those tests run. Unless your automated tests run in under 10 seconds,
you're setting up for a big roadblock.

I'm not even sure that you can get a complete picture of the code
(with changes included) when pre-commit fires.

I also would not recommend having something that's completely
automated "backing out" a commit that's already happened because it
failed a test.

If you're trying to get people into the habit of testing before the
commit, gentle "embarrassment" can work wonders. Let everyone commit
at will. Use a continuous integration system to do a build/test after
each commit. If the tests fail, have the system send out an email to
announce who last committed that latest batch of broken changes (and
is therefore responsible for fixing it). People will learn the habit
pretty quickly. I've read of a number of teams who do this; sometimes
the "build breaker" has to keep a duncecap on his/her desk (or on top
of their monitor, or their PC, or the cube wall - someplace visible)
until the next build break happens, sometimes the breaker has to buy
the team donuts, etc. It's not meant to be mean-spirited, just a way
to encourage people to do the right thing.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-02-06 14:29:08 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.