zoukankan      html  css  js  c++  java
  • svn代码统计工具的金额

    StatSVN介绍

    StatSVN是Java写开源统计程序,从statCVS从移植。从能Subversion版本号来获取信息库,该项目开发的叙述性说明,然后生成各种表格和图表。例:时间线。针对每一个开发人员的代码行数;开发人员的活跃程度;开发人员近期所提交的;文件数量;平均文件大小;最大文件。哪个文件是改动最多次数的;文件夹大小;带有文件数量和代码行数的Repository tree。

    StatSVN当前版本号能够生成一组包含表格与图表的静态HTML文档。


    StatSVN下载

    StartSVN官网地址为:http://www.statsvn.org/index.html 

    StartSVN的下载页面为:http://www.statsvn.org/downloads.html

    如今官网上最新的版本号为:statsvn-0.7.0


    StatSVN使用

    使用须知 

    StatSVN的执行须要Java的执行环境支持。所以大家须要安装Java的执行环境(Java Runtime Environment)。JRE能够从Sun的站点上下载。

    Statsvn在使用中须要使用SVN的client,因此须要确保机器上能够訪问到SVN的client命令

    Checkout工作拷贝 

    首先从SVN仓库中checkout一个须要统计的路径(假设在工作文件夹下进行统计。首先请更新。保证工作区中的版本号是最新的版本号。确保统计结果的准确性),比如我把我的某个路径下的工程checkout在我的电脑上的 D:MyProjects 路径下。

    生成svn log文件 

    首先通过命令行进入工作文件夹:D:MyProjects ,再使用svn log -v --xml > logfile.log的命令,当中 logfile.log为log文件的名称,能够依据须要自行定义。

    这样就在工作拷贝的文件夹下生成一个名称为logfile.log的文件。

    注:要在命令行中使用svn命令,在安装TortoiseSVN时必须选择安装commend组件,能够在cmd命令行里输入svn help測试一下该组件是否安装。假设未安装是无法使用svn log命令的。

    假设能够操作svn server的话也能够直接在服务器上生成svn log然后下载到本地来使用

    调用StatSVN进行统计 

    首先我们把从官网上下载的statsvn-0.7.0.zip包解压缩到D:statsvn-0.7.0文件夹下

    通过命令行进入D:statsvn-0.7.0文件夹

    调用命令java -jar statsvn.jar D:MyProjectslogfile.log D:MyProjects,命令执行成功即完毕了统计工作。

    该命令的格式是java -jar statsvn.jar [options] <logfile> <checked-out-module>

    參数<logfile>为前一步中生成的svn log文件。<checked-out-module>为checkout工作复制文件夹,注意两个參数都要列出正确的全路径,否则会提示错误如logfile.log找不到等等 

    1. <logfile>          path to the svn logfile of the module  
    2. <directory>        path to the directory of the checked out module  

     [options]为可选參数,该參数格式及使用方法例如以下:

    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 (default25)  
    17. -concurrency-threshold <millisec> switch to concurrent svn diff if 1st call>threshol  
    18. -dump               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. 先导出svn log

       svn log -v --xml -rStartrevision:Endrevision > svn.log local_project
       当中Startrevision和Endrevision用来导出一个revision段的svn日志.local_project是svn上的project checkout到本地的结果.


    2. 通过statsvn工具做分析
      java -jar statsvn.jar svn.log local_project
      执行完毕后,就会在$PWD(unix下)或者%CD%(windows下)下生成相应的分析文件,在index.html文件里就有代码量统计.



    #!/bin/bash
    
    svn_dir='/home/homer/work/code_svn/weiguan'
    statsvn_dir='/home/homer/work/tool-server/statsvn-0.7.0/statsvn.jar'
    
    log_dir=svnstat
    log_file="$log_dir/svnstat.log"
    log_day="$log_dir/2014-01-01_00:00:00"
    
    version_start=4150
    version_end=4159
    
    function 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


    參考推荐:

    statsvn统计svn中的代码量

    统计svn上代码量的方法--使用statsvn工具

    统计分析svn用户每天提交的代码数

    一个基于SVN 的代码提交量统计工具

    StatSVN


    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    加载时间分析与优化
    t
    linux 3389
    切片声明 切片在内存中的组织方式 reslice
    从模版生成 uri Golang 的 html/template 包不太适合于这种情况
    负载均衡实现,一个域名对应多个IP地址
    京东首页 淘宝首页 图片加载 单域名 多域名 图片服务
    Reduce DNS Lookups 减少DNS查找
    Make Fewer HTTP Requests 减少HTTP请求
    What the 80/20 Rule Tells Us about Reducing HTTP Requests
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/4624239.html
Copyright © 2011-2022 走看看