3

I am looking for a program that could display the evolution of the programming languages used over time in a Git or SVN repository. The output could be like the following:

enter image description here

So far, I have tried:

1) CLOC: the output only shows the current language breakdown:

enter image description here

2) StatSVN: it generates many statistics like evolution of number of lines of code over time (took me 2 hours on the TortoiseSVN project with:

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

)

enter image description here

commit word tags:

enter image description here

a lot of user statistics and so on but not what I want.

  • What is wrong with the solutions you've found? What exactly do you mean by "evolution of programming languages"? – ATG Jun 26 '14 at 22:16
  • 1
    @ATG I would think he means like in December 2012 the repo was 50% Python, 30% C++, 15% Batch Script and 5% other, December 2013 the repo was 45% Python, 40$ C++, 10% Batch Script and 5% Other - with graphical or text output – Nick Wilde Jun 26 '14 at 22:30
  • @ATG Did you see the first graph, right at the beginning of my question? The solutions I've found don't allow to extract the data from a repository. I can add all StatSVN's output graphs but some might complain again about scroll-based RSI :) – Franck Dernoncourt Jun 26 '14 at 22:44
  • Gotcha, so you want the numbers that are used to produce the first graph, basically. Thanks for clarifying. – ATG Jun 27 '14 at 11:56
2

For git repositories I would use a combination of CLOC & git from python, the following script, run in a git repository, would produce the quarterly csv files, these could then be used by any spreadsheet program or plotted with the python csv and matplotlib libraries.

#!/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)

For SVN I would strongly recommend taking a git clone of the svn repository first and then using the above on that - unless you have a T1 connection it will probably be quicker than multiple svn check out operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.