Statsvn Introduction
Statsvn is an open-source code statistics program written in Java. It is transplanted from statcvs and can obtain information from the Subversion database, and then generate various tables and charts describing project development. For example, the timeline of the number of lines of code; the number of lines of code for each developer; the developer's activity level; the developer's recent submissions; the number of files; average file size; maximum file size; which file is modified most times; directory size; repository tree with the number of files and number of lines of code. The current statsvn version can generate a set of Static HTML documents including tables and charts.
Download statsvn
Startsvn official site address: http://www.statsvn.org/index.html
Startsvn download page is: http://www.statsvn.org/downloads.html
Now the latest version of the official website: statsvn-0.7.0
Use statsvn
Usage instructions
The running of statsvn requires the support of the Java Runtime Environment, so you need to install the Java Runtime Environment (Java Runtime Environment ). JRE can be downloaded from Sun's website.
Statsvn uses the svn client in use. Therefore, make sure that the client commands of SVN can be accessed on the machine.
Checkout copy
First, check the svn repository for a path for Statistics (if statistics are performed in the working directory, update it first to ensure that the version in the workspace is the latest version and that the statistical results are accurate ), for example, if I put the project checkout in a path under my computer under D: \ myprojects path.
Generate SVN Log File
First, enter the working directory: D: \ myprojects through the command line, and then use SVN log-V -- XML> logfile. logfile. log is the name of the log file, which can be customized as needed. In this way, a file named logfile. log is generated under the working copy directory.
Note: To use the svn command in the command line, you must install the commend component when installing tortoisesvn. You can enter SVN help in the command line to test whether the component is installed, the SVN log command cannot be used if it is not installed. If you can operate the svn server, you can directly generate the svn log on the server and then download it to your local computer for use.
Call statsvn for Statistics
First we extract the statsvn-0.7.0.zip package downloaded from the official network to the D: \ statsvn-0.7.0 directory
Enter the D: \ statsvn-0.7.0 directory through the command line
Call the Java-jar statsvn. Jar D: \ myprojects \ logfile. Log D: \ myprojects command to complete the statistical work.
The command is in the format of Java-jar statsvn. Jar [Options] <logfile> <checked-out-module>
The <logfile> parameter is the svn log file generated in the previous step and the <checked-out-module> parameter is the directory for copying checkout jobs. Note that both parameters must list the correct full path, otherwise, an error such as logfile is prompted. log not found, etc.
- <Logfile> path to the svn logfile of the module
- <Directory> path to the directory of the checked out Module
[Options] is an optional parameter. The format and usage of this parameter are as follows:
- Some options:
- -Version print the version information and exit
- -Output-Dir <dir> directory where HTML suite will be saved
- -Include <pattern> include only files matching pattern, e.g. **/*. C; **/*. h
- -Exclude <pattern> exclude matching files, e.g. Tests/**; docs /**
- -Tags <Regexp> show matching tags in lines of code chart, e.g. Version -.*
- -Title <title> project title to be used in reports
- -Viewvc <URL> integrate with viewvc installation at <URL>
- -Trac <URL> integrate with trac at <URL>
- -Bugzilla <URL> integrate with Bugzilla installation at <URL>
- -Username <svnusername> username to pass to SVN
- -Password <svnpassword> password to pass to SVN
- -Verbose print extra progress information
- -Xdoc optional switch output to xdoc
- -XML optional switch output to XML
- -Threads <int> How many threads for SVN diff (default: 25)
- -Concurrency-threshold <millisec> switch to concurrent SVN diff if 1st call> threshol
- -Dump the repository content on Console
- -Charset <charset> specify the charset to use for HTML/xdoc
- -Tags-Dir <directory> optional, specifies the director for tags (default '/tags /')
- Full options list: http://www.statsvn.org
1. Export SVN log first
SVN log-V -- XML-rstartrevision: endrevision> SVN. Log local_project
Here, startrevision and endrevision are used to export SVN logs of a revision segment. local_project is the result of project checkout on SVN to local.
2. Use the statsvn tool for analysis
Java-jar statsvn. Jar SVN. Log local_project
After the operation is completed, the corresponding analysis file will be generated under mongopwd( unicdcd%(under windows), and the code volume statistics will be available in the index.html file.
#!/bin/bashsvn_dir=‘/home/homer/work/code_svn/weiguan‘statsvn_dir=‘/home/homer/work/tool-server/statsvn-0.7.0/statsvn.jar‘log_dir=svnstatlog_file="$log_dir/svnstat.log"log_day="$log_dir/2014-01-01_00:00:00"version_start=4150version_end=4159function statsvn() { cd $svn_dir svn up if [ ! -d $log_dir ];then mkdir $log_dir fi date=$(date "+%Y-%m-%d_%H:%M:%S") echo "$date" lines=`find . -name *.java | xargs wc -l | sort -n` echo "total code lines : $lines" version_end=`svn log -l1 | sed -n 2p | awk ‘{print $1}‘ | cut -d "r" -f2` echo "version_start : $version_start; version_end : $version_end" svn log -v --xml -r$version_start:$version_end > $log_file log_day="$log_dir/$date" java -jar $statsvn_dir $log_file . -output-dir $log_day > /dev/null 2>&1 google-chrome $log_day/index.html &}statsvn
Reference recommendations:
Statsvn counts the amount of code in SVN
Measure the amount of code on SVN-use the statsvn Tool
Statistical analysis of the number of codes submitted by SVN users per day
Svn-based code submission statistics Tool
Statsvn