Last active
December 28, 2015 19:09
-
-
Save billdueber/7548043 to your computer and use it in GitHub Desktop.
Playing around with JGit in JRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'jgit-3.1.0.jar' | |
dirpath = '.' | |
# get the repo | |
dir = java.io::File.new(dirpath) | |
frb = org.eclipse.jgit.storage.file.FileRepositoryBuilder.new | |
frb.set_work_tree dir | |
frb.find_git_dir | |
frb.build | |
repo = org.eclipse.jgit.internal.storage.file::FileRepository.new(frb) | |
git = org.eclipse.jgit.api::Git.new(repo) | |
HEAD = org.eclipse.jgit.lib::Constants::HEAD | |
head = repo.resolve(HEAD) | |
commits = git.log.add(head).set_max_count(10).call | |
commits.each do |c| | |
dt = Time.at( c.commit_time).to_datetime | |
author = c.author_ident.name | |
msg = c.full_message | |
puts "#{dt} #{author} #{msg}" | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment