Skip to content

Instantly share code, notes, and snippets.

@geelen
Created August 31, 2009 01:59
Show Gist options
  • Save geelen/178250 to your computer and use it in GitHub Desktop.
Save geelen/178250 to your computer and use it in GitHub Desktop.
#!/bin/sh
exec scala -cp /home/glen/src/gitwatch/lib/jgit.jar $0 $@
!#
import java.io.File
import org.spearce.jgit.lib.{Commit => GitCommit, Repository}
val repo = new Repository(new File(args(0)))
val head = repo.mapCommit("HEAD")
def history(c: GitCommit): List[GitCommit] = {
c :: c.getParentIds.take(1).map(repo.mapCommit(_)).flatMap(history(_)).toList
}
println(history(head).take(args(1).toInt).map(_.getMessage).mkString(""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment