Ticket #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@… |
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
Change History
Changed 6 years ago by ivanoe
- attachment trac-pre-commit-hook added
Changed 6 years ago by ivanoe
- attachment trac-post-commit-hook added
changed contrib/trac-post-commit-hook to support message in the file
Changed 6 years ago by ivanoe
- attachment pre-commit.bat added
hooks\pre-commit.bat on Windows to support TRAC integration
Changed 6 years ago by ivanoe
- attachment post-commit.bat added
hooks\post-commit.bat on Windows to support TRAC integration
comment:1 Changed 6 years ago by cmlenz
- Keywords contrib windows added; subversion removed
- Milestone changed from 0.8 to 0.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 Changed 6 years ago by ivanoe
- Milestone changed from 0.9 to 0.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.
Changed 6 years ago by ivanoe
- attachment trac-post-commit-hook.diff added
trac-post-commit-hook diff file
Changed 6 years ago by ivanoe
- attachment trac-pre-commit-hook.diff added
trac-pre-commit-hook diff file
Changed 6 years ago by ivanoe
- attachment trac-post-commit-hook.svn.diff added
svn diff version of post-commit
Changed 6 years ago by ivanoe
- attachment trac-pre-commit-hook.svn.diff added
svn diff version of pre-commit
comment:5 Changed 6 years ago by anonymous
- Milestone changed from 0.8 to 0.9
I have no idea why the milestone has changed - changed it back to 0.8
Changed 6 years ago by nir.mor@…
- attachment post-commit.cmd added
post-commit.cmd fow windows hook (no need to change any thing in trac)
Changed 6 years ago by anonymous
- attachment pre-commit.cmd added
pre-commit hook (no need to change anything in trac)
comment:7 Changed 6 years ago by nir.mor@…
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 Changed 6 years ago by achim@…
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 Changed 6 years ago by achim@…
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 Changed 5 years ago by anonymous
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 Changed 5 years ago by anonymous
Using the hooks and they work perfectly, except for the amail notification, but why is this ticket still open ?
comment:12 Changed 5 years ago by mgood
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 Changed 5 years ago by anonymous
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 Changed 5 years ago by coreywangler@…
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 Changed 5 years ago by cmlenz
- Priority changed from high to low
- Status changed from new to closed
- Resolution set to duplicate
- Milestone 0.9 deleted
Even though this is the original ticket, discussion should continue in #1602, and I'm marking this one as duplicate.



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