Merge branch 'master' of github.com:github/gollum

This commit is contained in:
eston
2011-01-18 22:59:51 -08:00
28 changed files with 451 additions and 192 deletions
+2 -7
View File
@@ -1,13 +1,8 @@
require 'albino'
class Gollum::Albino < Albino
def self.bin
Albino.bin
end
def bin
Albino.bin
end
self.bin = ::Albino.bin
self.default_encoding = ::Albino.default_encoding
def colorize(options = {})
html = super.to_s
+15 -11
View File
@@ -44,7 +44,7 @@ module Precious
get '/edit/*' do
@name = params[:splat].first
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
if page = wiki.page(@name)
@page = page
@content = page.raw_data
@@ -55,11 +55,11 @@ module Precious
end
post '/edit/*' do
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
page = wiki.page(params[:splat].first)
name = params[:rename] || page.name
msg = commit_message
update_wiki_page(wiki, page, params[:content], msg, name,
update_wiki_page(wiki, page, params[:content], msg, name,
params[:format])
update_wiki_page(wiki, page.footer, params[:footer], msg) if params[:footer]
update_wiki_page(wiki, page.sidebar, params[:sidebar], msg) if params[:sidebar]
@@ -69,7 +69,7 @@ module Precious
post '/create' do
name = params[:page]
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
format = params[:format].intern
@@ -83,7 +83,7 @@ module Precious
end
post '/revert/:page/*' do
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@name = params[:page]
@page = wiki.page(@name)
shas = params[:splat].first.split("/")
@@ -103,7 +103,7 @@ module Precious
end
post '/preview' do
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@name = "Preview"
@page = wiki.preview_page(@name, params[:content], params[:format])
@content = @page.formatted_data
@@ -112,7 +112,7 @@ module Precious
get '/history/:name' do
@name = params[:name]
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@page = wiki.page(@name)
@page_num = [params[:page].to_i, 1].max
@versions = @page.versions :page => @page_num
@@ -134,16 +134,20 @@ module Precious
get '/compare/:name/:version_list' do
@name = params[:name]
@versions = params[:version_list].split(/\.{2,3}/)
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@page = wiki.page(@name)
diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path)
@diff = diffs.first
mustache :compare
end
get %r{^/(javascript|css|images)} do
halt 404
end
get %r{/(.+?)/([0-9a-f]{40})} do
name = params[:captures][0]
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
if page = wiki.page(name, params[:captures][1])
@page = page
@name = name
@@ -156,7 +160,7 @@ module Precious
get '/search' do
@query = params[:q]
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@results = wiki.search @query
@name = @query
mustache :search
@@ -167,7 +171,7 @@ module Precious
end
def show_page_or_file(name)
wiki = Gollum::Wiki.new(settings.gollum_path)
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
if page = wiki.page(name)
@page = page
@name = name
+22 -7
View File
@@ -2,7 +2,15 @@ module Gollum
# Controls all access to the Git objects from Gollum. Extend this class to
# add custom caching for special cases.
class GitAccess
def initialize(path)
# Initializes the GitAccess instance.
#
# path - The String path to the Git repository that holds the
# Gollum site.
# page_file_dir - String the directory in which all page files reside
#
# Returns this instance.
def initialize(path, page_file_dir = nil)
@page_file_dir = page_file_dir
@path = path
@repo = Grit::Repo.new(path)
clear
@@ -15,7 +23,7 @@ module Gollum
@repo.git.exist?
end
# Public: Converts a given Git reference to a SHA, using the cache if
# Public: Converts a given Git reference to a SHA, using the cache if
# available.
#
# ref - a String Git reference (ex: "master")
@@ -29,7 +37,7 @@ module Gollum
end
end
# Public: Gets a recursive list of Git blobs for the whole tree at the
# Public: Gets a recursive list of Git blobs for the whole tree at the
# given commit.
#
# ref - A String Git reference or Git SHA to a commit.
@@ -144,10 +152,17 @@ module Gollum
#
# Returns an Array of BlobEntry instances.
def tree!(sha)
tree = @repo.git.native(:ls_tree,
tree = @repo.git.native(:ls_tree,
{:r => true, :l => true, :z => true}, sha)
tree.split("\0").inject([]) do |items, line|
items << parse_tree_line(line)
items = tree.split("\0").inject([]) do |memo, line|
memo << parse_tree_line(line)
end
if dir = @page_file_dir
regex = /^#{dir}\//
items.select { |i| i.path =~ regex }
else
items
end
end
@@ -201,7 +216,7 @@ module Gollum
# Parses a line of output from the `ls-tree` command.
#
# line - A String line of output:
# "100644 blob 839c2291b30495b9a882c17d08254d3c90d8fb53 Home.md"
# "100644 blob 839c2291b30495b9a882c17d08254d3c90d8fb53 Home.md"
#
# Returns an Array of BlobEntry instances.
def parse_tree_line(line)
+50 -40
View File
@@ -13,6 +13,7 @@ module Gollum
@name = page.filename
@data = page.text_data
@version = page.version.id
@format = page.format
@dir = ::File.dirname(page.path)
@tagmap = {}
@codemap = {}
@@ -28,8 +29,8 @@ module Gollum
#
# Returns the formatted String content.
def render(no_follow = false)
sanitize = no_follow ?
@wiki.history_sanitizer :
sanitize = no_follow ?
@wiki.history_sanitizer :
@wiki.sanitizer
data = extract_tex(@data.dup)
@@ -120,7 +121,18 @@ module Gollum
if $1 == "'" && $3 != "'"
"[[#{$2}]]#{$3}"
elsif $2.include?('][')
$&
if $2[0..4] == 'file:'
pre = $1
post = $3
parts = $2.split('][')
parts[0][0..4] = ""
link = "#{parts[1]}|#{parts[0].sub(/\.org/,'')}"
id = Digest::SHA1.hexdigest(link)
@tagmap[id] = link
"#{pre}#{id}#{post}"
else
$&
end
else
id = Digest::SHA1.hexdigest($2)
@tagmap[id] = $2
@@ -134,32 +146,28 @@ module Gollum
# final markup.
#
# data - The String data (with placeholders).
# no_follow - Boolean that determines if rel="nofollow" is added to all
# <a> tags.
#
# Returns the marked up String data.
def process_tags(data, no_follow = false)
def process_tags(data)
@tagmap.each do |id, tag|
data.gsub!(id, process_tag(tag, no_follow))
data.gsub!(id, process_tag(tag))
end
data
end
# Process a single tag into its final HTML form.
#
# tag - The String tag contents (the stuff inside the double
# tag - The String tag contents (the stuff inside the double
# brackets).
# no_follow - Boolean that determines if rel="nofollow" is added to all
# <a> tags.
#
# Returns the String HTML version of the tag.
def process_tag(tag, no_follow = false)
def process_tag(tag)
if html = process_image_tag(tag)
html
elsif html = process_file_link_tag(tag, no_follow)
elsif html = process_file_link_tag(tag)
html
else
process_page_link_tag(tag, no_follow)
process_page_link_tag(tag)
end
end
@@ -171,6 +179,8 @@ module Gollum
# if it is not.
def process_image_tag(tag)
parts = tag.split('|')
return if parts.size.zero?
name = parts[0].strip
path = if file = find_file(name)
::File.join @wiki.base_path, file.path
@@ -252,15 +262,15 @@ module Gollum
# Attempt to process the tag as a file link tag.
#
# tag - The String tag contents (the stuff inside the double
# tag - The String tag contents (the stuff inside the double
# brackets).
# no_follow - Boolean that determines if rel="nofollow" is added to all
# <a> tags.
#
# Returns the String HTML if the tag is a valid file link tag or nil
# if it is not.
def process_file_link_tag(tag, no_follow = false)
def process_file_link_tag(tag)
parts = tag.split('|')
return if parts.size.zero?
name = parts[0].strip
path = parts[1] && parts[1].strip
path = if path && file = find_file(path)
@@ -271,33 +281,30 @@ module Gollum
nil
end
tag = if name && path && file
if name && path && file
%{<a href="#{::File.join @wiki.base_path, file.path}">#{name}</a>}
elsif name && path
%{<a href="#{path}">#{name}</a>}
else
nil
end
if tag && no_follow
tag.sub! /^<a/, '<a ref="nofollow"'
end
tag
end
# Attempt to process the tag as a page link tag.
#
# tag - The String tag contents (the stuff inside the double
# tag - The String tag contents (the stuff inside the double
# brackets).
# no_follow - Boolean that determines if rel="nofollow" is added to all
# <a> tags.
#
# Returns the String HTML if the tag is a valid page link tag or nil
# if it is not.
def process_page_link_tag(tag, no_follow = false)
def process_page_link_tag(tag)
parts = tag.split('|')
name = parts[0].strip
cname = @wiki.page_class.cname((parts[1] || parts[0]).strip)
tag = if name =~ %r{^https?://} && parts[1].nil?
parts.reverse! if @format == :mediawiki
name, page_name = *parts.compact.map(&:strip)
cname = @wiki.page_class.cname(page_name || name)
if name =~ %r{^https?://} && page_name.nil?
%{<a href="#{name}">#{name}</a>}
else
presence = "absent"
@@ -310,10 +317,6 @@ module Gollum
link = ::File.join(@wiki.base_path, CGI.escape(link_name))
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
end
if tag && no_follow
tag.sub! /^<a/, '<a ref="nofollow"'
end
tag
end
# Find the given file in the repo.
@@ -335,7 +338,7 @@ module Gollum
#
# cname - The String canonical page name.
#
# Returns a Gollum::Page instance if a page is found, or an Array of
# Returns a Gollum::Page instance if a page is found, or an Array of
# [Gollum::Page, String extra] if a page without the extra anchor data
# is found.
def find_page_from_name(cname)
@@ -359,11 +362,11 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_code(data)
data.gsub!(/^``` ?(.+?)\r?\n(.+?)\r?\n```\r?$/m) do
data.gsub!(/^``` ?([^\r\n]+)?\r?\n(.+?)\r?\n```\r?$/m) do
id = Digest::SHA1.hexdigest($2)
cached = check_cache(:code, id)
@codemap[id] = cached ?
{ :output => cached } :
@codemap[id] = cached ?
{ :output => cached } :
{ :lang => $1, :code => $2 }
id
end
@@ -379,12 +382,19 @@ module Gollum
def process_code(data)
@codemap.each do |id, spec|
formatted = spec[:output] || begin
lang = spec[:lang]
code = spec[:code]
lang = spec[:lang]
if code.lines.all? { |line| line =~ /\A\r?\n\Z/ || line =~ /^( |\t)/ }
code.gsub!(/^( |\t)/m, '')
end
formatted = Gollum::Albino.new(code, lang).colorize
formatted = begin
lang && Gollum::Albino.colorize(code, lang)
rescue ::Albino::ShellArgumentError, ::Albino::Process::TimeoutExceeded,
::Albino::Process::MaximumOutputExceeded
end
formatted ||= "<pre><code>#{CGI.escapeHTML(code)}</code></pre>"
update_cache(:code, id, formatted)
formatted
end
@@ -393,7 +403,7 @@ module Gollum
data
end
# Hook for getting the formatted value of extracted tag data.
# Hook for getting the formatted value of extracted tag data.
#
# type - Symbol value identifying what type of data is being extracted.
# id - String SHA1 hash of original extracted tag data.
+35 -24
View File
@@ -41,6 +41,40 @@ module Gollum
filename =~ /^_/ ? false : match
end
# Public: The format of a given filename.
#
# filename - The String filename.
#
# Returns the Symbol format of the page. One of:
# [ :markdown | :textile | :rdoc | :org | :rest | :asciidoc | :pod |
# :roff ]
def self.format_for(filename)
case filename.to_s
when /\.(md|mkdn?|mdown|markdown)$/i
:markdown
when /\.(textile)$/i
:textile
when /\.(rdoc)$/i
:rdoc
when /\.(org)$/i
:org
when /\.(creole)$/i
:creole
when /\.(re?st(\.txt)?)$/i
:rest
when /\.(asciidoc)$/i
:asciidoc
when /\.(pod)$/i
:pod
when /\.(\d)$/i
:roff
when /\.(media)?wiki$/i
:mediawiki
else
nil
end
end
# Reusable filter to turn a filename (without path) into a canonical name.
# Strips extension, converts spaces to dashes.
#
@@ -143,30 +177,7 @@ module Gollum
# [ :markdown | :textile | :rdoc | :org | :rest | :asciidoc | :pod |
# :roff ]
def format
case @blob.name
when /\.(md|mkdn?|mdown|markdown)$/i
:markdown
when /\.(textile)$/i
:textile
when /\.(rdoc)$/i
:rdoc
when /\.(org)$/i
:org
when /\.(creole)$/i
:creole
when /\.(re?st(\.txt)?)$/i
:rest
when /\.(asciidoc)$/i
:asciidoc
when /\.(pod)$/i
:pod
when /\.(\d)$/i
:roff
when /\.(media)?wiki$/i
:mediawiki
else
nil
end
self.class.format_for(@blob.name)
end
# Public: The current version of the page.
+158 -53
View File
@@ -59,7 +59,7 @@ module Gollum
end
end
# Gets the default sanitization options for current pages used by
# Gets the default sanitization options for current pages used by
# instances of this Wiki.
def sanitization
if @sanitization.nil?
@@ -68,7 +68,7 @@ module Gollum
@sanitization
end
# Gets the default sanitization options for older page revisions used by
# Gets the default sanitization options for older page revisions used by
# instances of this Wiki.
def history_sanitization
if @history_sanitization.nil?
@@ -94,17 +94,21 @@ module Gollum
# Gets the sanitization options for older page revisions used by this Wiki.
attr_reader :history_sanitization
# Gets the String directory in which all page files reside.
attr_reader :page_file_dir
# Public: Initialize a new Gollum Repo.
#
# repo - The String path to the Git repository that holds the Gollum
# path - The String path to the Git repository that holds the Gollum
# site.
# options - Optional Hash:
# :base_path - String base path for all Wiki links.
# Default: "/"
# :page_class - The page Class. Default: Gollum::Page
# :file_class - The file Class. Default: Gollum::File
# :markup_class - The markup Class. Default: Gollum::Markup
# :sanitization - An instance of Sanitization.
# :base_path - String base path for all Wiki links.
# Default: "/"
# :page_class - The page Class. Default: Gollum::Page
# :file_class - The file Class. Default: Gollum::File
# :markup_class - The markup Class. Default: Gollum::Markup
# :sanitization - An instance of Sanitization.
# :page_file_dir - String the directory in which all page files reside
#
# Returns a fresh Gollum::Repo.
def initialize(path, options = {})
@@ -112,15 +116,16 @@ module Gollum
options[:access] = path
path = path.path
end
@path = path
@access = options[:access] || GitAccess.new(path)
@base_path = options[:base_path] || "/"
@page_class = options[:page_class] || self.class.page_class
@file_class = options[:file_class] || self.class.file_class
@markup_class = options[:markup_class] || self.class.markup_class
@repo = @access.repo
@sanitization = options[:sanitization] || self.class.sanitization
@history_sanitization = options[:history_sanitization] ||
@path = path
@page_file_dir = options[:page_file_dir]
@access = options[:access] || GitAccess.new(path, @page_file_dir)
@base_path = options[:base_path] || "/"
@page_class = options[:page_class] || self.class.page_class
@file_class = options[:file_class] || self.class.file_class
@markup_class = options[:markup_class] || self.class.markup_class
@repo = @access.repo
@sanitization = options[:sanitization] || self.class.sanitization
@history_sanitization = options[:history_sanitization] ||
self.class.history_sanitization
end
@@ -257,6 +262,82 @@ module Gollum
sha1
end
# Public: Applies a reverse diff for a given page. If only 1 SHA is given,
# the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs
# are given, the reverse diff is taken from SHA1...SHA2.
#
# page - The Gollum::Page to delete.
# sha1 - String SHA1 of the earlier parent if two SHAs are given,
# or the child.
# sha2 - Optional String SHA1 of the child.
# commit - The commit Hash details:
# :message - The String commit message.
# :name - The String author full name.
# :email - The String email address.
#
# Returns a String SHA1 of the new commit, or nil if the reverse diff does
# not apply.
def revert_page(page, sha1, sha2 = nil, commit = {})
if sha2.is_a?(Hash)
commit = sha2
sha2 = nil
end
pcommit = @repo.commit('master')
patch = full_reverse_diff_for(page, sha1, sha2)
commit[:parent] = [pcommit]
commit[:tree] = @repo.git.apply_patch(pcommit.sha, patch)
return false unless commit[:tree]
index = nil
sha1 = commit_index(commit) { |i| index = i }
@access.refresh
files = []
if page
files << [page.path, page.name, page.format]
else
# Grit::Diff can't parse reverse diffs.... yet
lines = patch.split("\n")
while line = lines.shift
if line =~ %r{^diff --git b/.+? a/(.+)$}
path = $1
ext = ::File.extname(path)
name = ::File.basename(path, ext)
if format = ::Gollum::Page.format_for(ext)
files << [path, name, format]
end
end
end
end
files.each do |(path, name, format)|
dir = ::File.dirname(path)
dir = '' if dir == '.'
update_working_dir(index, dir, name, format)
end
sha1
end
# Public: Applies a reverse diff to the repo. If only 1 SHA is given,
# the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs
# are given, the reverse diff is taken from SHA1...SHA2.
#
# sha1 - String SHA1 of the earlier parent if two SHAs are given,
# or the child.
# sha2 - Optional String SHA1 of the child.
# commit - The commit Hash details:
# :message - The String commit message.
# :name - The String author full name.
# :email - The String email address.
#
# Returns a String SHA1 of the new commit, or nil if the reverse diff does
# not apply.
def revert_commit(sha1, sha2 = nil, commit = {})
revert_page(nil, sha1, sha2, commit)
end
# Public: Lists all pages for this wiki.
#
# treeish - The String commit ID or ref to find (default: master)
@@ -266,7 +347,7 @@ module Gollum
tree_list(treeish || 'master')
end
# Public: Returns the number of pages accessible from a commit
# Public: Returns the number of pages accessible from a commit
#
# ref - A String ref that is either a commit SHA or references one.
#
@@ -285,10 +366,10 @@ module Gollum
#
# Returns an Array with Objects of page name and count of matches
def search(query)
# See: http://github.com/Sirupsen/gollum/commit/f0a6f52bdaf6bee8253ca33bb3fceaeb27bfb87e
search_output = @repo.git.grep({:c => query}, 'master')
args = [{:c => query}, 'master', '--']
args << '--' << @page_file_dir if @page_file_dir
search_output.split("\n").collect do |line|
@repo.git.grep(*args).split("\n").map! do |line|
result = line.split(':')
file_name = Gollum::Page.canonicalize_filename(::File.basename(result[1]))
@@ -310,28 +391,6 @@ module Gollum
@repo.log('master', nil, log_pagination_options(options))
end
def revert_page(page, sha1, sha2 = nil, commit = {})
if sha2.is_a?(Hash)
commit = sha2
sha2 = nil
end
pcommit = @repo.commit('master')
patch = full_reverse_diff_for(page, sha1, sha2)
commit[:parent] = [pcommit]
commit[:tree] = @repo.git.apply_patch(pcommit.sha, patch)
return false unless commit[:tree]
index = nil
sha1 = commit_index(commit) { |i| index = i }
dir = ::File.dirname(page.path)
dir = '' if dir == '.'
@access.refresh
update_working_dir(index, dir, page.name, page.format)
sha1
end
# Public: Refreshes just the cached Git reference data. This should
# be called after every Gollum update.
#
@@ -340,7 +399,7 @@ module Gollum
@access.refresh
end
# Public: Creates a Sanitize instance using the Wiki's sanitization
# Public: Creates a Sanitize instance using the Wiki's sanitization
# options.
#
# Returns a Sanitize instance.
@@ -350,7 +409,7 @@ module Gollum
end
end
# Public: Creates a Sanitize instance using the Wiki's history sanitization
# Public: Creates a Sanitize instance using the Wiki's history sanitization
# options.
#
# Returns a Sanitize instance.
@@ -416,13 +475,17 @@ module Gollum
# Returns nothing.
def update_working_dir(index, dir, name, format)
unless @repo.bare
path =
if dir == ''
page_file_name(name, format)
else
::File.join(dir, page_file_name(name, format))
if @page_file_dir
dir = dir.size.zero? ? @page_file_dir : File.join(dir, @page_file_dir)
end
path =
if dir == ''
page_file_name(name, format)
else
::File.join(dir, page_file_name(name, format))
end
Dir.chdir(::File.join(@repo.path, '..')) do
if file_path_scheduled_for_deletion?(index.tree, path)
@repo.git.rm({'f' => true}, '--', path)
@@ -517,7 +580,7 @@ module Gollum
dir = '/' if dir.strip.empty?
fullpath = ::File.join(dir, path)
fullpath = ::File.join(*[@page_file_dir, dir, path].compact)
fullpath = fullpath[1..-1] if fullpath =~ /^\//
if index.current_tree && tree = index.current_tree / dir
@@ -536,6 +599,14 @@ module Gollum
index.add(fullpath, normalize(data))
end
# Commits to the repo. This is a common method used by Gollum for
# creating, updating, and deleting pages. There are typically three steps:
# building an index with the current tree, yielding the index for
# modification, and then writing the commit.
#
# options - Hash of option
#
# Returns the String SHA of the new Commit.
def commit_index(options = {})
normalize_commit(options)
parents = [options[:parent] || @repo.commit('master')]
@@ -549,13 +620,38 @@ module Gollum
end
yield index if block_given?
options[:name] = default_committer_name if options[:name].to_s.empty?
options[:email] = default_committer_email if options[:email].to_s.empty?
actor = Grit::Actor.new(options[:name], options[:email])
index.commit(options[:message], parents, actor)
end
# Creates a reverse diff for the given SHAs on the given Gollum::Page.
#
# page - The Gollum::Page to scope the patch to, or a String Path.
# sha1 - String SHA1 of the earlier parent if two SHAs are given,
# or the child.
# sha2 - Optional String SHA1 of the child.
#
# Returns a String of the reverse Diff to apply.
def full_reverse_diff_for(page, sha1, sha2 = nil)
sha1, sha2 = "#{sha1}^", sha1 if sha2.nil?
repo.git.native(:diff, {:R => true}, sha1, sha2, '--', page.path)
args = [{:R => true}, sha1, sha2]
if page
args << '--' << (page.respond_to?(:path) ? page.path : page.to_s)
end
repo.git.native(:diff, *args)
end
# Creates a reverse diff for the given SHAs.
#
# sha1 - String SHA1 of the earlier parent if two SHAs are given,
# or the child.
# sha2 - Optional String SHA1 of the child.
#
# Returns a String of the reverse Diff to apply.
def full_reverse_diff(sha1, sha2 = nil)
full_reverse_diff_for(nil, sha1, sha2)
end
# Ensures a commit hash has all the required fields for a commit.
@@ -573,17 +669,26 @@ module Gollum
end
# Gets the default name for commits.
#
# Returns the String name.
def default_committer_name
@default_committer_name ||= \
@repo.config['user.name'] || self.class.default_committer_name
end
# Gets the default email for commits.
#
# Returns the String email address.
def default_committer_email
@default_committer_email ||= \
@repo.config['user.email'] || self.class.default_committer_email
end
# Gets the commit object for the given ref or sha.
#
# ref - A string ref or SHA pointing to a valid commit.
#
# Returns a Grit::Commit instance.
def commit_for(ref)
@access.commit(ref)
rescue Grit::GitRuby::Repository::NoSuchShaFound