SVN code statistics Tool

Source: Internet
Author: User
Tags svn client code chart

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.

  1. <Logfile> path to the svn logfile of the module
  2. <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:

  1. Some options:
  2. -Version print the version information and exit
  3. -Output-Dir <dir> directory where HTML suite will be saved
  4. -Include <pattern> include only files matching pattern, e.g. **/*. C; **/*. h
  5. -Exclude <pattern> exclude matching files, e.g. Tests/**; docs /**
  6. -Tags <Regexp> show matching tags in lines of code chart, e.g. Version -.*
  7. -Title <title> project title to be used in reports
  8. -Viewvc <URL> integrate with viewvc installation at <URL>
  9. -Trac <URL> integrate with trac at <URL>
  10. -Bugzilla <URL> integrate with Bugzilla installation at <URL>
  11. -Username <svnusername> username to pass to SVN
  12. -Password <svnpassword> password to pass to SVN
  13. -Verbose print extra progress information
  14. -Xdoc optional switch output to xdoc
  15. -XML optional switch output to XML
  16. -Threads <int> How many threads for SVN diff (default: 25)
  17. -Concurrency-threshold <millisec> switch to concurrent SVN diff if 1st call> threshol
  18. -Dump the repository content on Console
  19. -Charset <charset> specify the charset to use for HTML/xdoc
  20. -Tags-Dir <directory> optional, specifies the director for tags (default '/tags /')
  21. 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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.