seratch's weblog in Japanese

About Scala, Java and Ruby programming in Japaense. If you need English information, go to http://blog.seratch.net/

JGit を Scala から使う

こちらのスライドを読んでいて気になったので JGit でちょっとサンプルを書いてみました。

http://www.eclipse.org/jgit/

http://jgit.info/javadoc/

何かいいアイデアが思いついたら JGit を使った何かをつくってみたい気になりました。

build.sbt

// http://www.eclipse.org/jgit/download/

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "[2.1,)"

sample.scala

import org.eclipse.jgit.api._
import scala.collection.JavaConverters._

val cloneCommand = new CloneCommand().setURI("git://github.com/seratch/scalikejdbc.git")
val git = cloneCommand.call()
val logs = git.log.call()
logs.asScala.take(10).foreach { l => println(l) }