Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I graph the Lines of Code history for git repo?

Basically I want to get the number of lines-of-code in the repository after each commit.

The only (really crappy) ways I have found is to use git filter-branch to run wc -l *, and a script that runs git reset --hard on each commit, then runs wc -l

To make it a bit clearer, when the tool is run, it would output the lines of code of the very first commit, then the second and so on. This is what I want the tool to output (as an example):

me@something:~/$ gitsloc --branch master 10 48 153 450 1734 1542 

I've played around with the ruby 'git' library, but the closest I found was using the .lines() method on a diff, which seems like it should give the added lines (but does not: it returns 0 when you delete lines for example)

require 'rubygems' require 'git'  total = 0 g = Git.open(working_dir = '/Users/dbr/Desktop/code_projects/tvdb_api')      last = nil g.log.each do |cur|   diff = g.diff(last, cur)   total = total + diff.lines   puts total   last = cur end 
like image 481
dbr Avatar asked Aug 23 '08 03:08

dbr


People also ask

How do I see code of lines in GitHub?

GitHub Codesearch can be found at github.com/codesearch and will let you type in anything you're looking for in source code and get highlighted results of any files in our public repositories that match. You will also get a sidebar with the facet counts of language breakdown of the results and repository breakdowns.


1 Answers

You might also consider gitstats, which generates this graph as an html file.

like image 179
cboettig Avatar answered Sep 17 '22 23:09

cboettig