StatSVN

May 15, 2007 13:42

Well, just as I was preparing to post the code for my quick-and-dirty stats solution, Jason Kealey was nice enough to send me a link that clearly indicated I was attempting to reinvent the wheel. StatSVN pulls together some great statistics on Subversion projects and outputs them to flat HTML files. I've set up these stats to run on an hourly basis at the following URL:

http://monk.thelonio.us/statsvn

If you're still interested, here's how I pulled and published the initial stats:

 
private void BindGrid() { DataSet ds = new DataSet(); string filePath = Request.PhysicalApplicationPath + "log.xml"; if(Cache["refresh"] == null || !File.Exists(filePath)) { Cache.Insert("refresh", true, null, DateTime.Now.AddMinutes(1), TimeSpan.Zero); if (File.Exists(filePath)) { File.Delete(filePath); } string command = Server.MapPath("svn.exe"); string args = @"log --xml http://subsonicproject.googlecode.com/svn/trunk/"; ProcessStartInfo psi = new ProcessStartInfo(command, args); psi.CreateNoWindow = true; psi.UseShellExecute = false; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; Process proc = Process.Start(psi); proc.Start(); string content = proc.StandardOutput.ReadToEnd(); File.WriteAllText(filePath, content); proc.StandardOutput.Close(); proc.Close(); } ds.ReadXml(filePath); grid.DataSource = ds; grid.DataBind(); }
 

It's a total hack, with just enough dumb caching to keep the server from getting pounded, but it gets the job done. However, now that StatSVN is running, I doubt I'll be putting much more effort into embellishing the code...


5 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Related posts

Comments

May 15. 2007 18:24

Christopher Karper

Just awesome. This really makes it nice and easy to see what's going on.

I'd like to see automatic linking when an http:// URL is specified in the change log.

Christopher Karper

May 15. 2007 18:31

Eric Kemp

Thanks Chris, I hope it proves useful.

Jason and team have put together a great application in SVNstat. The idea of enabling the links is a great one and I hope they consider it for a future release...

Eric Kemp

May 16. 2007 05:49

AsbjornM

Maybe you should exclude binary files from stats?

AsbjornM

May 16. 2007 17:11

kevin

Too bad fckeditor probably adds about 20% to the top of your "lines of code" stats.

When you see 150k lines of code for a project it appears daunting.

But its obviously not.

good stuff though. thx.

kevin

May 21. 2007 18:55

Eric Kemp

Good point... I've excluded FCKEditor from stat generation.

Eric Kemp

Comments are closed