Tuesday, July 6. 2004
CVSNT loginfo data from stdin
I am building a quickie script to deal with CVS commit email notifications. According to the CVSNT docco, you just set up a line in your loginfo like this:
PHP is my scripting language of choice, (although there is a vast cornucopia of languages that would work nicely as well). So I just make cmd be "C:\path\to\php.exe c:\path\to\script.php %{sVv}"
The {%sVv} tells CVSNT to replace it with the current module name (i.e. mymodule/subdir/subsub) the files committed, and their previous and current versions in a format something like this:
CVSNT also sends a bunch of information to stdin, its format looks something like this:
A few pointers:
DEFAULT cmdwhere DEFAULT means the default action and cmd is the command you are sending. Dirt easy, right? You could replace DEFAULT with mymodule/subdir/subsub... to only send emails to a particular module, or ALL to send emails for EVERY module, along with any other loginfo action. See the CVSNT docs for details.
PHP is my scripting language of choice, (although there is a vast cornucopia of languages that would work nicely as well). So I just make cmd be "C:\path\to\php.exe c:\path\to\script.php %{sVv}"
The {%sVv} tells CVSNT to replace it with the current module name (i.e. mymodule/subdir/subsub) the files committed, and their previous and current versions in a format something like this:
myModule/sandbox/CommitLogTests README.txt,1.4,1.5 test.txt,1.2,1.3So with some regex and/or explosion magick, one can easily tear that apart, using PHP's builtin $argv[] variable.
CVSNT also sends a bunch of information to stdin, its format looks something like this:
Update of H:/Full/Path/Tp/CVSRepository/cvs/myModule/sandbox/CommitLogTests In directory computername:H:\\CVSTemp\\cvs-serv223a\\sandbox\\CommitLogTests Modified Files: README.txt test.txt Log Message: Test of a commitIt is a simple case of grabbing the STDIN filehandle, and read bytes till feof() is hit. After that, 'splosion and regex magick again work well. I just 'sploded and searched for "Log Message:" in the array myself.
A few pointers:
- Do: run your script through php lint (php(.exe) -l [script])
- Do: test your script by calling it directly, and redirecting a text file that has contents similar to above.
- Do NOT: blindly hook it into your live CVSNT server without giving it a good testing. You might hose things badly enough to require a service shutdown, and manual lockfile removal in your repository.
Listening to:
Breakbeat Show 7-15-02 prt 1 - Hybrid (0:-1)
Wednesday, May 26. 2004
Getting a list of changed files in CVS without updating
I had a bit of a hard time finding out (i.e. googling) how to list changed files in CVS using the command line.
The answer of course is easy:
There you go. (The spellchecker didn't accept "foo"!)
The answer of course is easy:
cvs -n update foo-n means "Don't change files". So you do the update, which lists the changed files (both on the repository and on your local copy) but the update isn't actually performed.
There you go. (The spellchecker didn't accept "foo"!)
(Page 1 of 1, totaling 2 entries)




