class Duffy::Git
I like to have a git log in the admin section of my websites. I use these in my capistrano tasks to generate what I need and upload along with the deployment. If for some reason you don't have git installed, each method returns nil.
Public Class Methods
branch()
click to toggle source
Display the current branch
# File lib/duffy/git.rb, line 35 def branch `git rev-parse --abbrev-ref HEAD`.strip.presence rescue nil end
count()
click to toggle source
I tend use the commit count / 1000.0 as a version for my applications. You wouldn't want to do that if you're building a gem used by others.
# File lib/duffy/git.rb, line 19 def count `git rev-list HEAD --count`.presence.to_i rescue nil end
email()
click to toggle source
Read the git committer's email. Uses local if present, otherwise global (git default procedure) nil if unset
# File lib/duffy/git.rb, line 28 def email `git config --get user.email`.strip.presence rescue nil end
log()
click to toggle source
Produce tab separated listing of current git log. Useful for displaying a development history page.
# File lib/duffy/git.rb, line 11 def log `git log --pretty=format:"%ad%x09%an%x09%s" --date=short`.strip.presence rescue nil end