You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by René Vestergaard <rv...@techno-matic.dk> on 2005/10/12 06:53:05 UTC

Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

I need af way to prevent changes/commits to branches under:
  SomeProject/tags/

The script/hook examples I found do not work for me,
because the subversion server run on a PC with Windows Server 2003.

How can i make a precommit-script that prevents commits to Tags?

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

Re: SV: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Ron Bieber <ro...@bieberlabs.com>.
We use mod_svn_authz to limit commits to the /tags/ area to one user. That
'buildmaster' user can create tags from the automated build, but no other
user is allowed to use this area for modifications.

Hope this helps.

-- Ron

On 10/12/05, Greg Thomas <th...@omc.bt.co.uk> wrote:
>
> On Wed, 12 Oct 2005 12:24:03 +0200, Miha Vitorovic <mv...@nil.si>
> wrote:
>
> >Actually, what you need to do is, is check if the svnlook result contains
> >"/tags/" (as you do), and if the flags are U (update) or D (delete)
>
> I don't believe that is sufficient. I can still add stuff to an
> existing tag - this will appear as
>
> A /tags/release-1.0/new-file-added.txt
>
> So you can still change an existing tag.
>
> Greg
> --
> This post represents the views of the author and does
> not necessarily accurately represent the views of BT.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>


--
----------------------------------------
http://www.bieberlabs.com

Re: SV: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Christopher Ness <ch...@nesser.org>.
On Wed, 2005-10-12 at 11:40 +0100, Greg Thomas wrote:
> On Wed, 12 Oct 2005 12:24:03 +0200, Miha Vitorovic <mv...@nil.si>
> wrote:
> 
> >Actually, what you need to do is, is check if the svnlook result contains 
> >"/tags/" (as you do), and if the flags are U (update) or D (delete) 
> 
> I don't believe that is sufficient. I can still add stuff to an
> existing tag - this will appear as
> 
> A    /tags/release-1.0/new-file-added.txt
> 
> So you can still change an existing tag.

Strip the path to the directory above /tags which in the above example
is "/tags/release-1.0/"

If this dir exists in SVN ("svn info file:///path/tags/release-1.0/")
bounce the commit.

Variances on this idea will be needed for your repositories /tag dir
structure.

Chris
-- 
http://www.nesser.org


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

Re: SV: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Greg Thomas <th...@omc.bt.co.uk>.
On Wed, 12 Oct 2005 12:24:03 +0200, Miha Vitorovic <mv...@nil.si>
wrote:

>Actually, what you need to do is, is check if the svnlook result contains 
>"/tags/" (as you do), and if the flags are U (update) or D (delete) 

I don't believe that is sufficient. I can still add stuff to an
existing tag - this will appear as

A    /tags/release-1.0/new-file-added.txt

So you can still change an existing tag.

Greg
-- 
This post represents the views of the author and does
not necessarily accurately represent the views of BT.

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

Re: SV: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Miha Vitorovic <mv...@nil.si>.
René Vestergaard <rv...@techno-matic.dk> wrote on 12.10.2005 12:12:14:

> Now the "/tags/"-repository-paths can't be commit'ed (fine),
> but they can not be created either (bad)
> (created = create a branch/tag to "/tags/v1.0").
> 
> Is there any way to allow Branch/Tag-command to execute, but permit
> commit's?
> 

Actually, what you need to do is, is check if the svnlook result contains 
"/tags/" (as you do), and if the flags are U (update) or D (delete) . If 
you want to translate it into windows CMD, you are going to need some 
string parsing tools (preferably ones that support regular expressions)

Here is a little perl script that I use (on Windows):

[--- cut 'ere ---]
#!c:/perl/bin/Perl.exe

use strict;

my $svnlook = "C:/Progra~1/Subver~1/bin/svnlook.exe";
my $repo_path = $ARGV[ 0 ];
my $txn_name = $ARGV[ 1 ];

open( INPUT, "$svnlook changed -t $txn_name $repo_path|" );

while( <INPUT> ){
  if( /^[UD]\s*?.*?\/?tags\/.*/i ) {
    printf STDERR "Cannot modify a tag.\n";
    close INPUT;
    exit 1;
  }
}

close INPUT;
exit 0;
[--- cut 'ere ---]

---
  Miha Vitorovic
  Inženir v tehničnem področju
  Customer Support Engineer

   NIL Data Communications,  Tivolska cesta 48,  1000 Ljubljana,  Slovenia
   Phone +386 1 4746 500      Fax +386 1 4746 501     http://www.NIL.si

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


SV: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by René Vestergaard <rv...@techno-matic.dk>.
Now the "/tags/"-repository-paths can't be commit'ed (fine),
but they can not be created either (bad)
(created = create a branch/tag to "/tags/v1.0").

Is there any way to allow Branch/Tag-command to execute, but permit
commit's?


The pre-commit.cmd script/hook file on the server:
--------------------------------------------------
rem Documentation:
rem  PercentChar1   = D:/Data/Subversion
rem  PercentChar2   = 90-1
rem  svnlook dirs-changed -t VERSION PATH  = extract the repository-path
rem  find "/tags/"  = if "/tags/" is in repository-path then set
errorlevel=1

c:\subversion\svnlook dirs-changed -t %2 %1 | find "/tags/"

rem If Sucessed then execute: exit 0
if errorlevel 1 exit 0

rem If Failed then execute: exit 1
exit 1
--------------------------------------------------




-----Oprindelig meddelelse-----
Fra: Greg Thomas [mailto:thomasgd@omc.bt.co.uk]
Sendt: 12. oktober 2005 10:21
Til: René Vestergaard
Cc: users@subversion.tigris.org
Emne: Re: SV: Request Tag-PreCommit-Script/hook for use at the OS:
Windows Server 2003


On Wed, 12 Oct 2005 10:03:52 +0200, René Vestergaard
<rv...@techno-matic.dk> wrote:

>Now I get this error:
>---------------------
>"Commit failed,
> pre-commit hook failed,
> svnlook: missing argument: t"
>
>I wrote the following in the pre-commit.cmd file on the server:
>---------------------------------------------------------------
>c:\subversion\svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
>if errorlevel 1 exit 1
>exit 0

I've no idea if the idea will work, but the syntax you need is

c:\subversion\svnlook dirs-changed -t %1 %2 | find "/tags/"

HTH,

Greg
--
This post represents the views of the author and does
not necessarily accurately represent the views of BT.

---------------------------------------------------------------------
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: SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Greg Thomas <th...@omc.bt.co.uk>.
On Wed, 12 Oct 2005 10:03:52 +0200, René Vestergaard
<rv...@techno-matic.dk> wrote:

>Now I get this error:
>---------------------
>"Commit failed,
> pre-commit hook failed,
> svnlook: missing argument: t"
>
>I wrote the following in the pre-commit.cmd file on the server:
>---------------------------------------------------------------
>c:\subversion\svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
>if errorlevel 1 exit 1
>exit 0

I've no idea if the idea will work, but the syntax you need is

c:\subversion\svnlook dirs-changed -t %1 %2 | find "/tags/"

HTH,

Greg
-- 
This post represents the views of the author and does
not necessarily accurately represent the views of BT.

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

SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by René Vestergaard <rv...@techno-matic.dk>.
Now I get this error:
---------------------
"Commit failed,
 pre-commit hook failed,
 svnlook: missing argument: t"

I wrote the following in the pre-commit.cmd file on the server:
---------------------------------------------------------------
c:\subversion\svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
if errorlevel 1 exit 1
exit 0


Could it be because the variables %TRANS% and %REPOS% do not exist?

What did i do wrong?


-----Oprindelig meddelelse-----
Fra: Steve Williams [mailto:stevewilliams@kromestudios.com]
Sendt: 12. oktober 2005 09:04
Til: René Vestergaard
Cc: users@subversion.tigris.org
Emne: Re: Request Tag-PreCommit-Script/hook for use at the OS: Windows
Server 2003


René Vestergaard wrote:
> I need af way to prevent changes/commits to branches under:
>   SomeProject/tags/
>
> The script/hook examples I found do not work for me,
> because the subversion server run on a PC with Windows Server 2003.
>
> How can i make a precommit-script that prevents commits to Tags?

This may work.

svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
if errorlevel 1 exit 1

--
Sly


This message and its attachments may contain legally privileged or
confidential information. This message is intended for the use of the
individual or entity to which it is addressed. If you are not the addressee
indicated in this message, or the employee or agent responsible for
delivering the message to the intended recipient, you may not copy or
deliver this message or its attachments to anyone. Rather, you should
permanently delete this message and its attachments and kindly notify the
sender by reply e-mail. Any content of this message and its attachments,
which does not relate to the official business of the sending company must
be taken not to have been sent or endorsed by the sending company or any of
its related entities. No warranty is made that the e-mail or attachment(s)
are free from computer virus or other defect.

---------------------------------------------------------------------
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

SV: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003 (repository-path in the Pre-Commit hook)

Posted by René Vestergaard <rv...@techno-matic.dk>.
>> René Vestergaard wrote:
>>
>> Subject = Request Tag-PreCommit-Script/hook for use at the OS: Windows
Server 2003
>>
>> I need af way to prevent changes/commits to branches under:
>>   SomeProject/tags/
>>
>> The script/hook examples I found do not work for me,
>> because the subversion server run on a PC with Windows Server 2003.
>>
>> How can i make a precommit-script that prevents commits to Tags?

> Steve Williams  wrote:
>This may work.
>
>svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
>if errorlevel 1 exit 1

When the command "svnlook dirs-changed" is runned in the Pre-Commit hook
it returns the repository-path of the last completed/preformed commit action
and Not the repository-path of commit that is about to be done,
which was what i needed in the first place.

How can I get the repository-path in the Pre-Commit hook
of commit action that is about to be preform?


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

Re: Request Tag-PreCommit-Script/hook for use at the OS: Windows Server 2003

Posted by Steve Williams <st...@kromestudios.com>.
René Vestergaard wrote:
> I need af way to prevent changes/commits to branches under:
>   SomeProject/tags/
> 
> The script/hook examples I found do not work for me,
> because the subversion server run on a PC with Windows Server 2003.
> 
> How can i make a precommit-script that prevents commits to Tags?

This may work.

svnlook dirs-changed -t %TRANS% %REPOS% | find "/tags/"
if errorlevel 1 exit 1

-- 
Sly


This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

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