[cvsnt] Using VBScript from the loginfo file

Onur Civi ocivi at afsimage.com
Wed Jan 11 15:50:34 GMT 2006


Thank you for your feedback.

According to my limited observation, cvs is behaving differently on
windows. I don't think the documentation applies (and I very well might
be wrong) to the cases where cvsnt is reading verifymsg and triggering a
script. By the way, after reading little bit more, I learned that a
script called within loginfo can not actually stop the commit since
loginfo is called after commit takes place, so I switched to verifymsg.

Here is what I have observed using verifymsg on windows.
When a script is called within verifymsg, the only argument passed to
the script is the name of a temporary file which includes the text of
the commit message. I figured out this by echoing the arguments to a
text file that the script received. Is this a correct observation?

Having seen this, I have read the contents of this temp file into a
variable so that my variable has the commit message then I looked for
"no message" string in this variable.

This seemed to work to this point, some debugging lines I put into the
script showed that the script correctly determined whether the commit
message was empty or not, but I was never able to prevent commit. The
logic I used was that if the "no message" existed, the script should
quit with a non-zero exit code (Wscript.Quit (999)), but CVS allowed the
commit even if the execution reached the portion of the script where
Wscript.Quit command was executed with non-zero exit code. The complete
script is at the bottom of the email. Any help you can provide will be
appreciated. I am having a hard time finding documentation\samples for
cvs operations and scripting on windows so even if you can direct me to
a location where I can see some samples, it would be a great help.

Here is the script
************************************************************************
**

'Define the variables & constants

Const ForReading = 1, ForWriting = 2, ForAppending = 8

'Define the file system object

Set objFSO = CreateObject("Scripting.FileSystemObject")

'Parse the argument and assign the temp file which contains the commit
message to a string

Set objArgs = WScript.Arguments

strLogTxt = objArgs(0)

'Open the temp file and read the contents into a variable

Set f = objfso.GetFile(strLogTxt)

Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)

TextStreamTest = ts.ReadAll

'WScript.Echo TextStreamTest

'If the variable text has "no message" in it, exit with non-zero exit
code, if it is not, exit with zero exit code

MyPos = Instr(1, TextStreamTest, "no message", 1) 
	
If MyPos <> 0 Then
	
 		'WScript.Echo TextStreamTest
		WScript.Echo "The commit message is empty. Please enter
a description of the commit purpose"
		Wscript.Quit (999)
	
	Else
	
		'WScript.Echo TextStreamTest
		WScript.Echo "The commit message is not empty.
Successful Commit"
		Wscript.Quit (0)
End If

ts.Close

************************************************************************
****



-----Original Message-----
From: Bo Berglund [mailto:Bo.Berglund at system3r.se] 
Sent: Tuesday, January 10, 2006 11:29 AM
To: Onur Civi; cvsnt at cvsnt.org
Subject: RE: [cvsnt] Using VBScript from the loginfo file

First,
change the loginfo line to use forward slashes instead:
 
ALL cscript.exe C:/CvsMailer/AdminScripts/VerifyLog.vbs

Then, by what I see you are expecting the log message to 
come to you "by magic"...

This is not so. Everything you want to examine you have to 
specify on the loginfo line like:

ALL cscript.exe C:/CvsMailer/AdminScripts/VerifyLog.vbs {sVv} $USER
.....

And furthermore, the log message does not come in on the 
arguments list at all. You have to grab that from the STDIN instead.

Read the CVSNT documentation for the administrative files 
to find out what you need to do.
It is available in any standard CVSNT installation as a helpfile.

Best regards,

Bo Berglund


-----Original Message-----
From: cvsnt-bounces at cvsnt.org [mailto:cvsnt-bounces at cvsnt.org] On Behalf
Of Onur Civi
Sent: den 10 januari 2006 17:54
To: cvsnt at cvsnt.org
Subject: [cvsnt] Using VBScript from the loginfo file

Hi,

 

I am trying to force all CVS users enter a log message during commits.
We are using CVSNT on Windows platform, so what I thought I could do was
to write a simple vbscript that examines the message entry and if it is
"no message", quits with a non-zero exit code. The following line is
what I have in my loginfo file.

 

ALL cscript.exe C:\\CvsMailer\\AdminScripts\\VerifyLog.vbs

 

And the following is the script text. Needless to say, it doesn't do
what I want it to do. Any help would be appreciated.

 

Thanks

 

************************************************************************
**********************************************************************

'Define the variables & constants

Const ForAppending = 8

'Define the file system object that we will use for logging the log text
passed to the script

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile _

    ("C:\WUTemp\Log.txt", ForAppending, True)    

'Parse the argument and assign the log text argument to a string 

Set objArgs = WScript.Arguments

For I = 0 to objArgs.Count - 1

   objTextFile.WriteLine(objArgs(I) & vbTab)

   strLogTxt = objArgs(I)

Next

objTextFile.Close

'If the text is empty, exit with non-zero exit code, if it is not, exit
with zero exit code

If StrLogTxt = "no message" Then

            Wscript.Quit (1)

Else

            Wscript.Quit (0)

End If

_______________________________________________
cvsnt mailing list
cvsnt at cvsnt.org
http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt



More information about the cvsnt mailing list