You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Pieter <pi...@hotmail.com> on 2007/07/11 13:45:36 UTC

pre-commit hook: dont allow given diretory's and file-types

Hi,

I would like to have a pre-commit hook, that doesn't allow the commit if 
some special directroy's are in it, neither some file-types.
So in order to do the commit, the user has first to ignore them.

I'm not really experienced in perl, so it would be great if someone could 
help me with this? I searched in the mailinglist, but didn't find anything 
:-(

The directory's to ignore are:
    \bin
    \debug
end the file-types to ignore are:
    *.suo
    *.user


Any help will be really appreciated, thanks a lot in advance,

Pieter 



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

RE: pre-commit hook: dont allow given diretory's and file-types

Posted by Dong Jiwei <do...@keithley.com>.
Hi all,

	Svn perms is perfect, it has more accurate privilege control.
	But if you want a simple control according to the file type, hope
the following pseudo code can helps:
	[code]
	for FILE in `svnlook changed -t "$TXN" "$REPOS"`
	do
  		FLAG=`echo $FILE | grep -c '.txt$'`
  		if [ $FLAG -gt 0 ]; then
    			# Do you right check here, exit 1 if not pass
   		fi
	done
	[/code]
	Note, it's of bash shell.

Regards,

Roy Dong

-----Original Message-----
From: Ryan Schmidt [mailto:subversion-2007b@ryandesign.com] 
Sent: 2007年7月12日 16:29
To: Pieter
Cc: users@subversion.tigris.org
Subject: Re: pre-commit hook: dont allow given diretory's and file-types

On Jul 12, 2007, at 03:07, Pieter wrote:

> Ryan Schmidt wrote:
>
>> This shouldn't be too difficult. In the pre-commit hook, you'll  
>> want  to
>> run "svnlook changed" on the transaction, and for each line of   
>> output,
>> see if it matches one of the things you want to disallow.
>>
>> Or you may be able to just write a configuration file for  
>> svnperms.py  to
>> do this for you.
>>
>> http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/
>
> Thanks, but... err..., this is difficult for me, hehe I don't have  
> a clue to
> do such a thing with Perl :-) Isn't there anybody who could help me  
> a little
> bit with such a script?

Then have you looked into svnperms? All you would need to do there is  
look at their example configuration file and see if you can use that  
information to write a configuration file that meets your needs. And,  
well, you would need to write a one-line hook script which calls  
svnperms, and you'd need to install Python if you don't already have  
it on your server.


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


____________________________________________________________________________
_
Scanned by IBM Email Security Management Services powered by MessageLabs.
For more information please visit http://www.ers.ibm.com
____________________________________________________________________________
_



_____________________________________________________________________________
Scanned by IBM Email Security Management Services powered by MessageLabs. For more information please visit http://www.ers.ibm.com
_____________________________________________________________________________

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


Re: How to Modify the transaction file

Posted by Andy Levy <an...@gmail.com>.
On 7/12/07, Dong Jiwei <do...@keithley.com> wrote:
> Hi all,
>
>         I want to write a hook that can modify the file to be committed, for
> example, it the file is a shell script, then I want to add one line "echo
> $END_DATE" at the file end.
>         How can I got the file and modify it in hooks?

Don't.

>         And one more question is will this operation cause the inconsistence
> between the WC and REOPS?

Yes, and that's why you shouldn't do it. When the user commits a file
to the repository, upon completion of the commit, the version in their
WC should match what's in the repository. If you do this, that will be
broken.

IOW, you'll be forcing your users to run svn up after every commit,
because they won't have any idea what their file actually looks like
after the commit - which they should.

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

Re: How to Modify the transaction file

Posted by Talden <ta...@gmail.com>.
> >       And one more question is will this operation cause the inconsistence
> > between the WC and REOPS?

> That's exactly why you mustn't modify a transaction: the working copy
> will think it has a file at, say, revision 42, but the repository
> will think revision 42 looks different. When you later try to update,
> things will blow up.

Technically I suppose it would be possible to change the transaction
handshaking such that rather than updating the Working Copy to the
committed revision it is reverted to the pre-commit revision if the
transaction is server-side modified - and notifying the user of the
need to pull the commit from the server.  This might make it possible
to perform such actions - it sounds like an ugly workflow to me
(though of course only applies when servers change a transaction).

Best to just make it a pre-commit condition with feedback and get the
user to apply the changes locally and recommit.

I'm not sure you want to be inserting that text every time though...
Doing this on trunk and branch would ensure merge conflicts as both
would have differing changes in the file at the same position.

--
Aaron

> >       I think the Subversion svn:keywords auto substitution may work of
> > the same mechanism? Any one tell me how to do this?
>
> Keyword substitution works differently. It works on the client side
> only. The keywords are only expanded to their actual values upon
> checkout or export; they're not stored that way in the repository.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>

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

Re: How to Modify the transaction file

Posted by Erik Huelsmann <eh...@gmail.com>.
On 7/16/07, Arnauld Van Muysewinkel <ar...@gmail.com> wrote:
> 2007/7/12, Ryan Schmidt <su...@ryandesign.com>:
> > On Jul 12, 2007, at 04:32, Dong Jiwei wrote:
> > >       I want to write a hook that can modify the file to be committed, for
> > > example, it the file is a shell script, then I want to add one line
> > > "echo
> > > $END_DATE" at the file end.
> > >       How can I got the file and modify it in hooks?
> >
> > Don't do that. Instead, you can write a pre-commit hook which rejects
> > the commit of any file that doesn't end with that line. Then instruct
> > your developers to add that line themselves before committing.
> >
> > >       And one more question is will this operation cause the inconsistence
> > > between the WC and REOPS?
> >
> > That's exactly why you mustn't modify a transaction: the working copy
> > will think it has a file at, say, revision 42, but the repository
> > will think revision 42 looks different. When you later try to update,
> > things will blow up.
> >
> > >       I think the Subversion svn:keywords auto substitution may work of
> > > the same mechanism? Any one tell me how to do this?
> >
> > Keyword substitution works differently. It works on the client side
> > only. The keywords are only expanded to their actual values upon
> > checkout or export; they're not stored that way in the repository.
>
> Is there anything like "client-side hooks" ? Hooks that would check
> and/or modify the WC files *before* committing them ?

Only if you add wrapper programs to your svn executable, but not
something which automatically comes with a repository configuration.
It would be an extreme security risk to introduce them built into
Subversion (what I mean by that is that it's very hard to do
correctly).

The standard procedure here is to reject commits which are improperly
formatted or missing vital parts.

bye,


Erik.

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

Re: How to Modify the transaction file

Posted by Arnauld Van Muysewinkel <ar...@gmail.com>.
2007/7/12, Ryan Schmidt <su...@ryandesign.com>:
> On Jul 12, 2007, at 04:32, Dong Jiwei wrote:
> >       I want to write a hook that can modify the file to be committed, for
> > example, it the file is a shell script, then I want to add one line
> > "echo
> > $END_DATE" at the file end.
> >       How can I got the file and modify it in hooks?
>
> Don't do that. Instead, you can write a pre-commit hook which rejects
> the commit of any file that doesn't end with that line. Then instruct
> your developers to add that line themselves before committing.
>
> >       And one more question is will this operation cause the inconsistence
> > between the WC and REOPS?
>
> That's exactly why you mustn't modify a transaction: the working copy
> will think it has a file at, say, revision 42, but the repository
> will think revision 42 looks different. When you later try to update,
> things will blow up.
>
> >       I think the Subversion svn:keywords auto substitution may work of
> > the same mechanism? Any one tell me how to do this?
>
> Keyword substitution works differently. It works on the client side
> only. The keywords are only expanded to their actual values upon
> checkout or export; they're not stored that way in the repository.

Is there anything like "client-side hooks" ? Hooks that would check
and/or modify the WC files *before* committing them ?

-- 
Ir. Arnauld Van Muysewinkel

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

Re: How to Modify the transaction file

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 12, 2007, at 04:32, Dong Jiwei wrote:

> 	I want to write a hook that can modify the file to be committed, for
> example, it the file is a shell script, then I want to add one line  
> "echo
> $END_DATE" at the file end.
> 	How can I got the file and modify it in hooks?

Don't do that. Instead, you can write a pre-commit hook which rejects  
the commit of any file that doesn't end with that line. Then instruct  
your developers to add that line themselves before committing.

> 	And one more question is will this operation cause the inconsistence
> between the WC and REOPS?

That's exactly why you mustn't modify a transaction: the working copy  
will think it has a file at, say, revision 42, but the repository  
will think revision 42 looks different. When you later try to update,  
things will blow up.

> 	I think the Subversion svn:keywords auto substitution may work of
> the same mechanism? Any one tell me how to do this?

Keyword substitution works differently. It works on the client side  
only. The keywords are only expanded to their actual values upon  
checkout or export; they're not stored that way in the repository.



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

How to Modify the transaction file

Posted by Dong Jiwei <do...@keithley.com>.
Hi all,

	I want to write a hook that can modify the file to be committed, for
example, it the file is a shell script, then I want to add one line "echo
$END_DATE" at the file end. 
	How can I got the file and modify it in hooks?
	And one more question is will this operation cause the inconsistence
between the WC and REOPS?

	I think the Subversion svn:keywords auto substitution may work of
the same mechanism? Any one tell me how to do this?

	Thank you in advance!

Regards,

Roy Dong





_____________________________________________________________________________
Scanned by IBM Email Security Management Services powered by MessageLabs. For more information please visit http://www.ers.ibm.com
_____________________________________________________________________________

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

Re: pre-commit hook: dont allow given diretory's and file-types

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 12, 2007, at 03:07, Pieter wrote:

> Ryan Schmidt wrote:
>
>> This shouldn't be too difficult. In the pre-commit hook, you'll  
>> want  to
>> run "svnlook changed" on the transaction, and for each line of   
>> output,
>> see if it matches one of the things you want to disallow.
>>
>> Or you may be able to just write a configuration file for  
>> svnperms.py  to
>> do this for you.
>>
>> http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/
>
> Thanks, but... err..., this is difficult for me, hehe I don't have  
> a clue to
> do such a thing with Perl :-) Isn't there anybody who could help me  
> a little
> bit with such a script?

Then have you looked into svnperms? All you would need to do there is  
look at their example configuration file and see if you can use that  
information to write a configuration file that meets your needs. And,  
well, you would need to write a one-line hook script which calls  
svnperms, and you'd need to install Python if you don't already have  
it on your server.


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

Re: pre-commit hook: dont allow given diretory's and file-types

Posted by Pieter <pi...@hotmail.com>.
Thanks, but... err..., this is difficult for me, hehe I don't have a clue to 
do such a thing with Perl :-) Isn't there anybody who could help me a little 
bit with such a script?

"Ryan Schmidt" <su...@ryandesign.com> wrote in message 
news:5A991DB4-28D4-4BDE-9A94-2B0467DDCE43@ryandesign.com...
> This shouldn't be too difficult. In the pre-commit hook, you'll want  to 
> run "svnlook changed" on the transaction, and for each line of  output, 
> see if it matches one of the things you want to disallow.
>
> Or you may be able to just write a configuration file for svnperms.py  to 
> do this for you.
>
> http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ 



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

Re: pre-commit hook: dont allow given diretory's and file-types

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 11, 2007, at 08:45, Pieter wrote:

> I would like to have a pre-commit hook, that doesn't allow the  
> commit if
> some special directroy's are in it, neither some file-types.
> So in order to do the commit, the user has first to ignore them.
>
> I'm not really experienced in perl, so it would be great if someone  
> could
> help me with this? I searched in the mailinglist, but didn't find  
> anything
> :-(
>
> The directory's to ignore are:
>     \bin
>     \debug
> end the file-types to ignore are:
>     *.suo
>     *.user

This shouldn't be too difficult. In the pre-commit hook, you'll want  
to run "svnlook changed" on the transaction, and for each line of  
output, see if it matches one of the things you want to disallow.

Or you may be able to just write a configuration file for svnperms.py  
to do this for you.

http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/



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

Re: pre-commit hook: dont allow given diretory's and file-types

Posted by Pieter <pi...@hotmail.com>.
Thank you but that's not quite what I am looking for: These Runtime 
Configuration Area is on theclient side, but I need something on the server 
side so it works whichever client using it...

So only possibility: pre-commit hook I guess...

"Trevor Spackman" <ts...@myriad.com> wrote in message 
news:BE94BD347940C8439B3217BAF58195A5B355C7@EXCHANGE.mygn.myriad.com...
Look at this:

http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.props.
special.ignore

HTH,
Trevor




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

RE: pre-commit hook: dont allow given diretory's and file-types

Posted by Trevor Spackman <ts...@myriad.com>.
Look at this:

http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.advanced.props.
special.ignore

HTH,
Trevor

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Pieter
Sent: Wednesday, July 11, 2007 7:46 AM
To: users@subversion.tigris.org
Subject: pre-commit hook: dont allow given diretory's and file-types

Hi,

I would like to have a pre-commit hook, that doesn't allow the commit if

some special directroy's are in it, neither some file-types.
So in order to do the commit, the user has first to ignore them.

I'm not really experienced in perl, so it would be great if someone
could 
help me with this? I searched in the mailinglist, but didn't find
anything 
:-(

The directory's to ignore are:
    \bin
    \debug
end the file-types to ignore are:
    *.suo
    *.user


Any help will be really appreciated, thanks a lot in advance,

Pieter 



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



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