whitespace plugin

This commit is contained in:
rick
2011-01-10 16:44:07 -08:00
parent cc85879810
commit 0fd639a149
3 changed files with 33 additions and 30 deletions
+17 -14
View File
@@ -536,6 +536,12 @@ 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
def commit_index(options = {})
normalize_commit(options)
parents = [options[:parent] || @repo.commit('master')]
@@ -549,6 +555,8 @@ 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
@@ -558,32 +566,27 @@ module Gollum
repo.git.native(:diff, {:R => true}, sha1, sha2, '--', page.path)
end
# Ensures a commit hash has all the required fields for a commit.
#
# commit - The commit Hash details:
# :message - The String commit message.
# :name - The String author full name.
# :email - The String email address.
#
# Returns the commit Hash
def normalize_commit(commit = {})
commit[:name] = default_committer_name if commit[:name].to_s.empty?
commit[:email] = default_committer_email if commit[:email].to_s.empty?
commit
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