Class: Duffy::Git
- Inherits:
-
Object
- Object
- Duffy::Git
- Defined in:
- lib/duffy/git.rb
Overview
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.
Class Method Summary collapse
-
.branch ⇒ Object
Display the current branch.
-
.count ⇒ Object
I tend use the commit count / 1000.0 as a version for my applications.
-
.email ⇒ Object
Read the git committer’s email.
-
.log ⇒ Object
Produce tab separated listing of current git log.
Class Method Details
.branch ⇒ Object
Display the current branch
32 33 34 |
# File 'lib/duffy/git.rb', line 32 def branch `git rev-parse --abbrev-ref HEAD`.strip.presence rescue nil end |
.count ⇒ Object
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.
20 21 22 |
# File 'lib/duffy/git.rb', line 20 def count `git rev-list HEAD --count`.presence.to_i rescue nil end |
.email ⇒ Object
Read the git committer’s email. Uses local if present, otherwise global (git default procedure) nil if unset
27 28 29 |
# File 'lib/duffy/git.rb', line 27 def email `git config --get user.email`.strip.presence rescue nil end |
.log ⇒ Object
Produce tab separated listing of current git log. Useful for displaying a development history page.
14 15 16 |
# File 'lib/duffy/git.rb', line 14 def log `git log --pretty=format:"%ad%x09%an%x09%s" --date=short`.strip.presence rescue nil end |