Skip to content

Instantly share code, notes, and snippets.

@tuttinator
Created September 21, 2011 13:21
Show Gist options
  • Save tuttinator/1232019 to your computer and use it in GitHub Desktop.
Save tuttinator/1232019 to your computer and use it in GitHub Desktop.
Grit example methods
require 'grit'
repo = Grit::Repo.new("/Users/Caleb/Documents/Rails Projects/welcomemat")
# loop through all git commits
puts repo.commits.each do |commit|
puts commit.author #author
puts commit.authored_date #datestamp
puts commit.message #git commit message
end
# loop through the file structure
repo.tree.contents.each { |item| puts item.name }
# get all files
all_files = repo.status.map { |stat_file| stat_file.path }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment