lib/gitolite/gitolite_admin.rb in jbox-gitolite-1.2.3 vs lib/gitolite/gitolite_admin.rb in jbox-gitolite-1.2.4
- old
+ new
@@ -7,10 +7,13 @@
CONF_DIR = "conf"
KEY_DIR = "keydir"
DEBUG = false
TIMEOUT = 10
+ # See here form mode details :https://github.com/gitlabhq/grit/blob/master/lib/grit/git.rb#L283
+ RAISE_ERROR = true
+
# Gitolite gem's default commit message
DEFAULT_COMMIT_MSG = "Committed by the gitolite gem"
class << self
@@ -78,12 +81,15 @@
@path = path
@config_file = options[:config_file] || CONFIG_FILE
@conf_dir = options[:conf_dir] || CONF_DIR
@key_dir = options[:key_dir] || KEY_DIR
- @env = options[:env] || {}
+ git_env = options[:env] || {}
+ git_raise = options[:raise] || RAISE_ERROR
+ @git_options = {:env => git_env, :raise => git_raise}
+
@config_file_path = File.join(@path, @conf_dir, @config_file)
@conf_dir_path = File.join(@path, @conf_dir)
@key_dir_path = File.join(@path, @key_dir)
Grit::Git.git_timeout = options[:timeout] || TIMEOUT
@@ -123,12 +129,12 @@
# This method will destroy all local tracked changes, resetting the local gitolite
# git repo to HEAD and reloading the entire repository
# Note that this will also delete all untracked files
def reset!
- @gl_admin.git.native(:reset, {:env => @env, :hard => true}, 'HEAD')
- @gl_admin.git.native(:clean, {:env => @env, :d => true, :q => true, :f => true})
+ @gl_admin.git.native(:reset, @git_options.merge(:hard => true), 'HEAD')
+ @gl_admin.git.native(:clean, @git_options.merge(:d => true, :q => true, :f => true))
reload!
end
# This method will destroy the in-memory data structures and reload everything
@@ -144,29 +150,29 @@
def save(commit_message = DEFAULT_COMMIT_MSG, options = {})
#Process config file (if loaded, i.e. may be modified)
if @config
new_conf = @config.to_file(@conf_dir_path)
- @gl_admin.git.native(:add, {:env => @env}, new_conf)
+ @gl_admin.git.native(:add, @git_options, new_conf)
end
#Process ssh keys (if loaded, i.e. may be modified)
if @ssh_keys
files = list_keys.map{|f| File.basename f}
keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten
to_remove = (files - keys).map { |f| File.join(@key_dir, f) }
to_remove.each do |key|
- @gl_admin.git.native(:rm, {:env => @env}, key)
+ @gl_admin.git.native(:rm, @git_options, key)
end
@ssh_keys.each_value do |key|
# Write only keys from sets that has been modified
next if key.respond_to?(:dirty?) && !key.dirty?
key.each do |k|
new_key = k.to_file(@key_dir_path)
- @gl_admin.git.native(:add, {:env => @env}, new_key)
+ @gl_admin.git.native(:add, @git_options, new_key)
end
end
end
args = []
@@ -177,17 +183,17 @@
if options.has_key?(:author) && !options[:author].empty?
args << "--author='#{options[:author]}'"
end
- @gl_admin.git.native(:commit, {:env => @env}, *args)
+ @gl_admin.git.native(:commit, @git_options, *args)
end
# Push back to origin
def apply
- @gl_admin.git.native(:push, {:env => @env}, "origin", "master")
+ @gl_admin.git.native(:push, @git_options, "origin", "master")
end
# Commits all staged changes and pushes back to origin
def save_and_apply(commit_message = DEFAULT_COMMIT_MSG)
@@ -200,10 +206,10 @@
def update(options = {})
options = {:reset => true, :rebase => false}.merge(options)
reset! if options[:reset]
- @gl_admin.git.native(:pull, {:env => @env, :rebase => options[:rebase]}, "origin", "master")
+ @gl_admin.git.native(:pull, @git_options.merge(:rebase => options[:rebase]), "origin", "master")
reload!
end