Daily transaction report for svn

I have a message commit hook that will save the svn log as an XML file. Next, I need to do formatting to display the data in the form of a tabular report, which will contain the following data: 1) Order number 2) File name 2) Filepath 3) Revision number 4) Owner 5) Lead time

This report should be sent to the group every day at 17:00 by e-mail. I need an example code for reference.

+4
source share
3 answers

It all depends on the language you use.

Many languages ​​have modules for reading XML files. For example, Perl has an XML :: Simple module.

If this is a daily report that you need for your Subversion repository at 5pm every day, you'd better just run the report once every 5pm using some kind of planning software. On Unix systems, you can use the cron daemon to schedule the launch of your system script. On Windows, you can use the Task Scheduler Wizard .

Running a report can be very simple. All you need is something like this:

svn log -v '{'$YESTERDAY'}':HEAD http://path/to/repository 

You need to calculate that $YESTERDAY , and put it in the format YYYYMMDD , and you have a report!

How do you get yesterday's date? Depends on your programming language. Most operating systems store dates as the number of seconds from epoc (In Unix, this is January 1, 1970). You use your programming language date subroutines.

This will be indicated in the order of the change set with the list of files changed in each change set. If you need a different format, you can use the --xml switch and get the report in XML format. The format for this XML output is fairly straightforward and so regular in structure that you can even parse it without using the XML parsing module.

I can’t help you anymore. I don’t know the OS, the language you use, or even what you need in your report. All I can tell you is that you do not need a hook after fixing - just run svn log at the right time with the right parameters, and in a few minutes you will have the whole report ready to be sent.

And, since it uses svn , all you need is a Subversion client. You don’t even need to create this report on a specific machine if there is a Subversion command-line client on this machine (downloadable from many places) and somehow indicates when the report can be run.

+2
source

There is no reason to use the post-commit hook, because you can just get the data using svn log -v --xml . You can request changes by date; for example svn log -v --xml -r "$(date +'{%Y-%m-%d}'):HEAD" to get changes today. Remember also that svn log can display url instead of local check.

Whatever programming language you are familiar with, you have XML parsing libraries that you can use to transform XML into your report.

Then you just need to configure your program to be called once a day. On Unix, you will use cron. On Windows, you can use the task scheduler.

Other than that, you ask for something dangerously close to "write my code for me."

+2
source

I think the wrong SVN task is used for this job. After all this only works after each commit (what if you have hundreds of commits per day, what if no one commits around 5pm?). Instead, I should write a cron task (linux) or a scheduled task (windows) to do this every day at 5pm. You can use the svn command line tools to request the log from the repository, reformat it, and then send it by email.

+1
source

All Articles