Method: Git::Base.init
- Defined in:
- lib/git/base.rb
.init(working_dir, opts = {}) ⇒ Object
initializes a git repository
options:
:bare
:index
:repository
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/git/base.rb', line 46 def self.init(working_dir, opts = {}) opts[:working_directory] ||= working_dir opts[:repository] ||= File.join(opts[:working_directory], '.git') FileUtils.mkdir_p(opts[:working_directory]) if opts[:working_directory] && !File.directory?(opts[:working_directory]) init_opts = { :bare => opts[:bare] } opts.delete(:working_directory) if opts[:bare] # Submodules have a .git *file* not a .git folder. # This file's contents point to the location of # where the git refs are held (In the parent repo) if File.file?('.git') git_file = File.open('.git').read[8..-1].strip opts[:repository] = git_file opts[:index] = git_file + '/index' end Git::Lib.new(opts).init(init_opts) self.new(opts) end |