首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Git和SVN存储库上的语言演化统计

Git和SVN存储库上的语言演化统计
EN

Software Recommendation用户
提问于 2014-06-26 22:11:32
回答 1查看 276关注 0票数 3

我正在寻找一个程序,它可以显示Git或SVN存储库中随时间而使用的编程语言的演变。输出可以如下所示:

到目前为止,我已经尝试过:

1) 氯丁醇:输出仅显示当前的语言细分:

2) StatSVN:它生成许多统计数据,如代码行数随时间的演变(我花了2个小时在TortoiseSVN项目上:

代码语言:javascript
复制
svn checkout http://tortoisesvn.googlecode.com/svn/trunk/ tortoisesvn-read-only
svn log --xml -v > svn.log'
cd c:\statsvn
java -jar statsvn.jar C:\temp\svn\tortoisesvn\svn.log C:\temp\svn\tortoisesvn

)

提交单词标记:

很多用户统计等等,但不是我想要的。

EN

回答 1

Software Recommendation用户

发布于 2014-06-27 12:25:17

对于git存储库,我将使用python中的CLOC & git组合,运行在git存储库中的以下脚本将生成季度csv文件,然后这些文件可以被任何电子表格程序使用,也可以与python csv和matplotlib库一起绘制。

代码语言:javascript
复制
#!/usr/bin/env python
#coding:utf-8
# Author:  Steve Barnes --<gadgetsteve@hotmail.com>
# Purpose: Create cloc counts across years
# Created: 27/06/14
"""
This python script aims to run cloc multiple times on a git VCS as at quarterly
time intervals.

Usage:
   python histcloc.py start_year [end_year]
"""
import sys
import csv
import os
import subprocess
import datetime

def GetNextQuaterDateStr(startyear, endyear):
    """ Generator for the date strings of each quarter."""
    quaterstartmonth = [1, 3, 6, 9]
    first_year = int(startyear)
    stop_at = int(endyear) + 1
    for year in xrange(first_year, stop_at):
        for month in quaterstartmonth:
            yield '%04d-%02d-01' % (year, month)

def SetAsDate(datstr):
    """
    For a specified repository set it to the state of the trunk on the specified
    date
    """
    commands = ['git', 'checkout',
                "`git rev-list -n 1 --before=\"%s\" master`"% datstr]
    print 'CMD:', ' '.join(commands)
    #result = subprocess.call(commands) # This does'n work for some reason
    result = os.system(' '.join(commands))
    return result

def DoCloc(datsr):
    """ Perform the cloc placing the results in a file specified by datestr."""
    commands = ['perl',
                '~/Downloads/cloc-1.60.pl',  # Replace this to the cloc path
                '.', '--csv', '--out=%s.csv' % datsr]
    result = os.system(' '.join(commands))
    return result

if __name__=='__main__':
    if len(sys.argv) < 2:
        print __doc__
        sys.exit(1)
    elif len(sys.argv) < 3:
        sys.argv.append(datetime.datetime.now().year)
    for y in GetNextQuaterDateStr(sys.argv[1], sys.argv[2]):
        print 'Processing for:', y
        SetAsDate(y)
        DoCloc(y)

对于SVN,我强烈建议首先使用svn存储库的git克隆,然后使用上面的内容--除非您有T1连接,否则它可能比多个svn签出操作更快。

票数 2
EN
页面原文内容由Software Recommendation提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://softwarerecs.stackexchange.com/questions/7327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档