Hi,
I am a newbie to Subversion and have no clue to writing scripts!!!
I am trying to write a script for windows so that it forces users to add a bug reference id during a commit.
Now for starters
I want to know if its possible to write the hook script directly as a bat file and get it to work or must I to use sth else like Python?
Sb helped me write the script in python and in trying to execute it,
I realised that the I don’t have the utility SVNLOOK installed , so to resolve this I manually copied the file across the bin directory.
I still get errors. I don’t know why.
This is the python script written for the hook and the corresponding error message
---------------------------------------------------------------------------
#!/usr/bin/python
# commit acceptance python client for SVN
import os
import re
import sys
import urlparse
# configure svnlook path
svnlookPath = '\"C:\\Program Files\\VisualSVN Server\\bin\\svnlook.exe\"'
# get committer
try:
f = os.popen(svnlookPath + ' author -t ' + sys.argv[2] + ' ' + sys.argv[1])
committer = f.read()
if f.close():
raise 1
committer = committer.rstrip("\n\r")
except:
print >> sys.stderr, 'Unable to get committer with svnlook.'
print >> sys.stderr, svnlookPath
print >> sys.stderr, sys.argv[1]
print >> sys.stderr, sys.argv[2]
sys.exit(1)
# get commit message
try:
f = os.popen(svnlookPath + ' log -t ' + sys.argv[2] + ' ' + sys.argv[1])
commitMessage = f.read()
if f.close():
raise 1
commitMessage = commitMessage.rstrip('\n\r')
except:
print >> sys.stderr, 'Unable to get commit message with svnlook.'
print >> sys.stderr, svnlookPath
print >> sys.stderr, sys.argv[1]
print >> sys.stderr, sys.argv[2]
sys.exit(1)
# print arguments
# print >> sys.stderr, 'Committer: ' + committer
print >> sys.stderr, 'Commit message: "' + commitMessage + '"'
if (re.match('^[a-zA-Z]+-[0-9]+([\s]+|$)',commitMessage)):
print >> sys.stderr, 'Commit accepted.'
sys.exit(0)
else:
print >> sys.stderr, 'Commit rejected: This repository requires a commit message to begin with a REF issue number.\n\reg REFPRJ-1'
sys.exit(1)
Commit Error Msg
Command: Commit
Modified: data\TEST\added2.sql
Sending content: data\TEST\added2.sql
Error: Commit failed (details follow):
Error: Commit blocked by pre-commit hook (exit code 1) with output:
Error: Unable to get committer with svnlook.
Error: "C:\Program Files\TortoiseSVN\bin\svnlook.exe"
Error: C:\data2
Error: 80-1
Finished!:
Any help will be appreciated to resolving this.
Thanks
... Cast your burdens upon the Lord for He cares for you ...
Enough to die for you!!!
_________________________________________________________________
Invite your Facebook friends to chat on Messenger
http://clk.atdmt.com/UKM/go/101719649/direct/01/
Received on 2008-07-04 14:04:34 CEST