Edgewall Software
Modify

Opened 20 years ago

Closed 19 years ago

#897 closed enhancement (duplicate)

Support contrib pre&post-commit hooks for SVN(subversion) on Windows

Reported by: ivanoe Owned by:
Priority: low Milestone:
Component: general Version: devel
Severity: normal Keywords: contrib hook windows
Cc: ivanoe@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Windows shell has some differences compare to the linux ones. One of the limitations is the unability (at least I did not find how to do it) to assign return values from calling other commands. To solve this problem, temporary files can be introduced. In attached files the changes to TRAC as I implemented it. I would like TRAC dev-team to take a review and possibly marge those into trunk, since those can be useful for other users on Windows as well.

The examples of the pre-commit.bat and post-commit.bat in the subversion repositories are also embedded into header comments in the trac-pre-commit-hook and trac-post-commit-hook files.

Also attached are my own subversion hooks.

Note: I am not sure if the component 'general' is correct one. Shall there be 'integration' or something. ivanoe|at|ivanoe.net

Attachments (10)

trac-pre-commit-hook (3.0 KB ) - added by ivanoe 20 years ago.
changed contrib/trac-post-commit-hook to support message in the file
trac-post-commit-hook (8.3 KB ) - added by ivanoe 20 years ago.
changed contrib/trac-post-commit-hook to support message in the file
pre-commit.bat (475 bytes ) - added by ivanoe 20 years ago.
hooks\pre-commit.bat on Windows to support TRAC integration
post-commit.bat (759 bytes ) - added by ivanoe 20 years ago.
hooks\post-commit.bat on Windows to support TRAC integration
trac-post-commit-hook.diff (1.8 KB ) - added by ivanoe 20 years ago.
trac-post-commit-hook diff file
trac-pre-commit-hook.diff (1.5 KB ) - added by ivanoe 20 years ago.
trac-pre-commit-hook diff file
trac-post-commit-hook.svn.diff (3.1 KB ) - added by ivanoe 20 years ago.
svn diff version of post-commit
trac-pre-commit-hook.svn.diff (2.1 KB ) - added by ivanoe 20 years ago.
svn diff version of pre-commit
post-commit.cmd (1.9 KB ) - added by nir.mor@… 20 years ago.
post-commit.cmd fow windows hook (no need to change any thing in trac)
pre-commit.cmd (2.5 KB ) - added by anonymous 20 years ago.
pre-commit hook (no need to change anything in trac)

Download all attachments as: .zip

Change History (25)

by ivanoe, 20 years ago

Attachment: trac-pre-commit-hook added

changed contrib/trac-post-commit-hook to support message in the file

by ivanoe, 20 years ago

Attachment: trac-post-commit-hook added

changed contrib/trac-post-commit-hook to support message in the file

by ivanoe, 20 years ago

Attachment: pre-commit.bat added

hooks\pre-commit.bat on Windows to support TRAC integration

by ivanoe, 20 years ago

Attachment: post-commit.bat added

hooks\post-commit.bat on Windows to support TRAC integration

comment:1 by Christopher Lenz, 20 years ago

Keywords: contrib windows added; subversion removed
Milestone: 0.80.9

Too late for 0.8.

Please include the diffs to trac-pre-commit-hook and trac-post-commit-hook instead of the full files so that it is easier to see what you changed.

comment:2 by ivanoe, 20 years ago

Milestone: 0.90.8

cmlenz

You could copy the files into your working environment and see then the differences compare to the base, since I changed the trunk. If you would not like to do that for some reason, I will include the diffs.

by ivanoe, 20 years ago

Attachment: trac-post-commit-hook.diff added

trac-post-commit-hook diff file

by ivanoe, 20 years ago

Attachment: trac-pre-commit-hook.diff added

trac-pre-commit-hook diff file

comment:3 by ivanoe, 20 years ago

cmlenz

Files added. Hope those are the ones you expect.

by ivanoe, 20 years ago

svn diff version of post-commit

by ivanoe, 20 years ago

svn diff version of pre-commit

comment:4 by ivanoe, 20 years ago

I guess the files required were the ones marked *.svn.diff

comment:5 by anonymous, 20 years ago

Milestone: 0.80.9

I have no idea why the milestone has changed - changed it back to 0.8

comment:6 by anonymous, 20 years ago

Owner: Jonas Borgström removed

by nir.mor@…, 20 years ago

Attachment: post-commit.cmd added

post-commit.cmd fow windows hook (no need to change any thing in trac)

by anonymous, 20 years ago

Attachment: pre-commit.cmd added

pre-commit hook (no need to change anything in trac)

comment:7 by nir.mor@…, 20 years ago

I have attached pre-commit.cmd and post-commit.cmd files they should be in the svn hook directory You have to set the variables:

SET SVN_DIR=C:\Program Files\Subversion SET PYTHON_DIR=C:\Program Files\Python23 SET HOOKS_DIR=C:\… the hook folder of the repository …\hooks SET TRAC_ENV=C:\… trac folder …\trac.db

inside pre-commit.cmd and post-commit.cmd

The use of FOR /F "usebackq delims==" %%i IN (windows command line call) DO SET PARM=%%i

Is the windows strange way of returning resault in variable ( only works on nt and up in CMD mode)

Nir.

comment:8 by achim@…, 20 years ago

The scripts do not support multiple projects within one repository. May be there is a way to replace a part of the TRAC_ENV path variable with a part of the repository path. So it would be possible to support multiple projects. I wrote such a script in python but only for my special purposes. I have no idea how to make it more general…

comment:9 by achim@…, 20 years ago

What about this one?

REM This is the repository path. (you get it with %1)

SET repospath=c:\svn\test

REM This is the main trac path where the trac projects should be located REM within the same directories like the projects of the multiple repository

SET tracmainpath=c:\trac

REM Replace a part of the repository path you get from subversion.

CALL SET TRAC_ENV=%%repospath:c:\svn=%tracmainpath%%%

comment:10 by anonymous, 20 years ago

You can test the return value from a program using IF.

my_pre_commit_hook.exe
if errorlevel 1 goto failed
my_second_commit_hook.exe
if errorlevel 1 goto failed

rem etc...

Use IF/? for help from CMD.

comment:11 by anonymous, 20 years ago

Using the hooks and they work perfectly, except for the amail notification, but why is this ticket still open ?

comment:12 by Matthew Good, 20 years ago

The ticket is open until the necessary files have been included in the Trac source so that they are distributed with the release.

comment:13 by anonymous, 20 years ago

I'd like to recommend that you folks have a look at http://freshmeat.net/projects/scmbug/, and in particular bug 76 (http://bugzilla.mkgnu.net/show_bug.cgi?id=76#c33).

The issue of integration from an SCM system to ANY bug-tracker is solved by this project, including writing Windows hooks. You are already duplicating effort that does not belong to the codebase of a bug-tracker.

Please let's solve the "integration" problem once and for all http://www.public.asu.edu/~makrists/scmbug/latest_manual/html/c121.html#GOALS

comment:14 by coreywangler@…, 20 years ago

The .bat and .com files given here did not work, so I fixed them (and cleaned them up a bit).

To make it clear what is going on I've created a new ticket (#1602) and attached the altered files there.

Hopefully that makes it easier to understand that the .bat files need to use the altered python hook scripts given in this ticket, while the .com files work with the standard python hook scripts available at branches/0.8-stable/contrib/

comment:15 by Christopher Lenz, 19 years ago

Milestone: 0.9
Priority: highlow
Resolution: duplicate
Status: newclosed

Even though this is the original ticket, discussion should continue in #1602, and I'm marking this one as duplicate.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.