You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Young, Jason (GE Indust, GE Fanuc)" <Ja...@ge.com> on 2006/08/24 21:16:31 UTC

Post commit script for losers who steal even revisions

We have a user here that watches the revision numbers, and when it's
1000, 2000, 3000, etc, he'll just change one character in the file, and
then check it in.  Does anyone have a post-commit script for Windows
that can check if the revision is divisible by 1000 and checked in by a
certain person?  I want those commits to fail, so that he can no longer
steal the glory.

Thanks,
Jason

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


Re: Post commit script for losers who steal even revisions

Posted by Karl Fogel <kf...@google.com>.
"Young, Jason \(GE Indust, GE Fanuc\)" <Ja...@ge.com> writes:
> We have a user here that watches the revision numbers, and when it's
> 1000, 2000, 3000, etc, he'll just change one character in the file, and
> then check it in.  Does anyone have a post-commit script for Windows
> that can check if the revision is divisible by 1000 and checked in by a
> certain person?  I want those commits to fail, so that he can no longer
> steal the glory.

In a post-commit hook, the commit has already happened, so it's too
late.  You need a pre-commit hook.  A pre-commit hooks doesn't know
the upcoming revision number, but it does know the *current* head
revision number.  So if that number is N-1, where N % 10 == 0, and the
user is this loser, then you can block the commit.  Once the youngest
rev advances to N or beyond, he'll be able to commit again.

Of course, this is the wrong solution.  Instead, bring up this
person's behavior, privately or publicly depending on the situation,
and get him to stop being ridiculous.  Don't implement a technical
solution for social problem.

-Karl

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

Re: Post commit script for losers who steal even revisions

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Aug 25, 2006, at 01:15, Ryan Schmidt wrote:

> On Aug 24, 2006, at 23:16, Young, Jason (GE Indust, GE Fanuc) wrote:
>
>> We have a user here that watches the revision numbers, and when it's
>> 1000, 2000, 3000, etc, he'll just change one character in the  
>> file, and
>> then check it in.  Does anyone have a post-commit script for Windows
>> that can check if the revision is divisible by 1000 and checked in  
>> by a
>> certain person?  I want those commits to fail, so that he can no  
>> longer
>> steal the glory.
>
> Ha! Brilliant. :-)
>
> Here's a pre-commit hook for Unix/Linux/Mac OS X. (Sorry; I'm not  
> up on Windows programming, but it should be easy enough to convert  
> this to Perl or a batch file.)
>
> Note that the revision number isn't assigned until after the pre- 
> commit hook ends. So it's possible that a banned author could still  
> commit the banned revision if someone else is committing something  
> else at the same time and that other revision gets handled first.

Let's try again without the debugging code and in a probably faster  
order:



#!/bin/sh

##### begin configuration section #####

BANNED_AUTHORS="larry curly moe"
BANNED_DIVISOR=1000

SVNLOOK=/opt/local/bin/svnlook

##### end configuration section #####

REPO="$1"
TXN="$2"

HEAD_REV=`$SVNLOOK youngest "$REPO"`
NEXT_REV=$(($HEAD_REV+1))
IS_OK_REV=$(($NEXT_REV%$BANNED_DIVISOR))
if [ $IS_OK_REV -ne 0 ]
then
	exit 0
fi

AUTHOR=`$SVNLOOK author -t "$TXN" "$REPO"`
IS_OK_AUTHOR=1
for BANNED_AUTHOR in $BANNED_AUTHORS
do
	if [ "$AUTHOR" = "$BANNED_AUTHOR" ]
	then
		IS_OK_AUTHOR=0
	fi
done
if [ $IS_OK_AUTHOR -ne 0 ]
then
	exit 0
fi

echo "$AUTHOR may not commit revision $NEXT_REV" 1>&2
exit 1


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

Re: Post commit script for losers who steal even revisions

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Aug 24, 2006, at 23:16, Young, Jason (GE Indust, GE Fanuc) wrote:

> We have a user here that watches the revision numbers, and when it's
> 1000, 2000, 3000, etc, he'll just change one character in the file,  
> and
> then check it in.  Does anyone have a post-commit script for Windows
> that can check if the revision is divisible by 1000 and checked in  
> by a
> certain person?  I want those commits to fail, so that he can no  
> longer
> steal the glory.

Ha! Brilliant. :-)

Here's a pre-commit hook for Unix/Linux/Mac OS X. (Sorry; I'm not up  
on Windows programming, but it should be easy enough to convert this  
to Perl or a batch file.)

Note that the revision number isn't assigned until after the pre- 
commit hook ends. So it's possible that a banned author could still  
commit the banned revision if someone else is committing something  
else at the same time and that other revision gets handled first.


#!/bin/sh

BANNED_AUTHORS="larry curly moe"
BANNED_DIVISOR=1000

SVNLOOK=/opt/local/bin/svnlook

REPO="$1"
TXN="$2"

AUTHOR=`$SVNLOOK author -t "$TXN" "$REPO"`
IS_OK_AUTHOR=1
for BANNED_AUTHOR in $BANNED_AUTHORS
do
	echo checking author $BANNED_AUTHOR against $AUTHOR 2>&1
	if [ "$AUTHOR" = "$BANNED_AUTHOR" ]
	then
		IS_OK_AUTHOR=0
	fi
done
if [ $IS_OK_AUTHOR -ne 0 ]
then
	exit 0
fi

HEAD_REV=`$SVNLOOK youngest "$REPO"`
NEXT_REV=$(($HEAD_REV+1))
IS_OK_REV=$(($NEXT_REV%$BANNED_DIVISOR))
if [ $IS_OK_REV -ne 0 ]
then
	exit 0
fi

echo "$AUTHOR may not commit revision $NEXT_REV" 1>&2
exit 1


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

RE: Post commit script for losers who steal even revisions

Posted by "Young, Jason (GE Indust, GE Fanuc)" <Ja...@ge.com>.
Awesome, that's great.  I see this is becoming a global epidemic.

Thanks! 

-----Original Message-----
From: rooneg@gmail.com [mailto:rooneg@gmail.com] On Behalf Of Garrett
Rooney
Sent: Thursday, August 24, 2006 4:44 PM
To: Young, Jason (GE Indust, GE Fanuc)
Cc: users@subversion.tigris.org; Sopata, Dan (GE Indust, GE Fanuc);
Riesterer, Shawn (GE Indust, GE Fanuc)
Subject: Re: Post commit script for losers who steal even revisions

On 8/24/06, Young, Jason (GE Indust, GE Fanuc) <Ja...@ge.com>
wrote:
> We have a user here that watches the revision numbers, and when it's 
> 1000, 2000, 3000, etc, he'll just change one character in the file, 
> and then check it in.  Does anyone have a post-commit script for 
> Windows that can check if the revision is divisible by 1000 and 
> checked in by a certain person?  I want those commits to fail, so that

> he can no longer steal the glory.

There's one in the svn tree that does most of that:

http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/commit-block-
joke.py

-garrett

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


Re: Post commit script for losers who steal even revisions

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On 8/24/06, Young, Jason (GE Indust, GE Fanuc) <Ja...@ge.com> wrote:
> We have a user here that watches the revision numbers, and when it's
> 1000, 2000, 3000, etc, he'll just change one character in the file, and
> then check it in.  Does anyone have a post-commit script for Windows
> that can check if the revision is divisible by 1000 and checked in by a
> certain person?  I want those commits to fail, so that he can no longer
> steal the glory.

There's one in the svn tree that does most of that:

http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/commit-block-joke.py

-garrett

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